SAP_ABAP_FI
동적 InterTable 만들기 본문
Source
DATA: lr_structdescr TYPE REF TO cl_abap_structdescr,
lr_tabledescr TYPE REF TO cl_abap_tabledescr,
lr_int2 TYPE REF TO cl_abap_elemdescr,
lr_int1 TYPE REF TO cl_abap_elemdescr,
lt_comp TYPE cl_abap_structdescr=>component_table,
ls_comp TYPE abap_componentdescr.
DATA: lv_len TYPE i,
lv_intleng TYPE i,
lv_deci TYPE i.
LOOP AT it_dfies INTO DATA(ls_dfies).
ls_comp-name = ls_dfies-fieldname.
lv_len = ls_dfies-leng.
lv_intleng = ls_dfies-intlen.
lv_deci = ls_dfies-decimals.
CASE ls_dfies-inttype.
WHEN 'I'.
ls_comp-type = cl_abap_elemdescr=>get_i( ).
WHEN 'F'.
ls_comp-type = cl_abap_elemdescr=>get_f( ).
WHEN 'D'.
ls_comp-type = cl_abap_elemdescr=>get_d( ).
WHEN 'T'.
ls_comp-type = cl_abap_elemdescr=>get_t( ).
WHEN 'C'.
ls_comp-type = cl_abap_elemdescr=>get_c( lv_len ).
WHEN 'N'.
ls_comp-type = cl_abap_elemdescr=>get_n( lv_len ).
WHEN 'X'.
CASE ls_dfies-datatype.
WHEN 'INT4'.
ls_comp-type = cl_abap_elemdescr=>get_i( ).
WHEN 'INT2'.
lr_int2 ?= cl_abap_elemdescr=>describe_by_name( 'INT2' ).
ls_comp-type = lr_int2.
WHEN 'INT1'.
lr_int1 ?= cl_abap_elemdescr=>describe_by_name( 'INT1' ).
ls_comp-type = lr_int1.
WHEN OTHERS.
ls_comp-type = cl_abap_elemdescr=>get_x( lv_len ).
ENDCASE.
WHEN 'P'.
ls_comp-type = cl_abap_elemdescr=>get_p(
p_length = lv_intleng
p_decimals = lv_deci
).
WHEN 'g'.
ls_comp-type = cl_abap_elemdescr=>get_string( ).
WHEN 'y'.
ls_comp-type = cl_abap_elemdescr=>get_xstring( ).
ENDCASE.
APPEND ls_comp TO lt_comp.
CLEAR: ls_comp,
ls_dfies,
lv_len,
lv_intleng,
lv_deci.
ENDLOOP.
lr_structdescr = cl_abap_structdescr=>create( lt_comp ).
lr_tabledescr = cl_abap_tabledescr=>create( p_line_type = lr_structdescr ).
CREATE DATA er_str TYPE HANDLE lr_structdescr.
CREATE DATA er_table TYPE HANDLE lr_tabledescr.
----> 테스트
it_dfies =
Export
Itab 생성
'SAP_ABAP_Source' 카테고리의 다른 글
ST04-Query Version2 (0) | 2021.09.27 |
---|---|
ABAP_DOMAIN_FIELD값 가져오기 (0) | 2021.09.07 |
ST04-Query부분 발췌 (0) | 2021.09.07 |
Table _INFO 가져오기 (0) | 2021.09.07 |
SAP/TABLE Dynamic Where / File Download (0) | 2021.01.03 |