메뉴 건너뛰기

SAP 한국 커뮤니티



필드심볼 사용 예제...

zen 2007.06.30 20:35 조회 수 : 4197

*&---------------------------------------------------------------------*
*& Report  YTEST01
*&
*&---------------------------------------------------------------------*
*& 목적: (1) 동적으로 구조체를 받고,
*&         (2) 해당 구조체의 필드값을 동적으로 받는 프로그램
*&---------------------------------------------------------------------*



report  ytest01.


 


tables: scarr. " Airline


 


*&---- Data 선언부 -------------


data: wa_scarr type scarr.


 


field-symbols:
* type은 가능한 Char등으로 지칭해 주는 것이 좋으나, 불특정인 경우 Any 사용.
* Any  사용시 Performance 는 좋지 않음....
   <fs_table>  type any,
   <fv_fd>      type any.


 


*&------start-of-selection-----------



start-of-selection.


 


*&------(1) 필드심볼 Assign



assign   wa_scarr to <fs_table>.


 


* Case1> <fs_table>이라는 구조체에 존재하는 필드명 CARRID
* Assign   component 'CARRID'  of structure <fs_table> to <fv_fd>.


 


* Case2> <fs_table>이라는 구조체에 존재하는 필드명 CARRID의 위치 ...-> 두번째


assign   component  2  of structure <fs_table> to <fv_fd>.


 


*&------(2) 필드 심볼에 값 넣기. 


select single carrid into <fv_fd>
       from scarr
       where carrid like 'A%'.


 


 


*&------(3) 필드 심볼값 출력


  write:/ <fv_fd>.