Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Help - Dynamic ALV

Former Member
0 Likes
507

Dear all,

I made some changes to this sample program from

My requirement now is the field-symbol should be generated from the internal table.

----


  • FORM CREATE_TABLE *

----


  • Create dynamic table *

----


FORM CREATE_TABLE USING MY_TAB TAB_NAME.

DATA L_STUFF TYPE TY_STUFF.

CREATE DATA DATAREF TYPE (MY_TAB).

ASSIGN DATAREF->* TO <FS>.

DESCR_STRUCT_REF ?= CL_ABAP_TYPEDESCR=>DESCRIBE_BY_DATA( <FS> ).

CLEAN_TABLE IT_FIELDCATALOG.

LOOP AT DESCR_STRUCT_REF->COMPONENTS ASSIGNING <COMPONENT>.

WA_FCAT-FIELDNAME = <COMPONENT>-NAME.

WA_FCAT-REF_TABLE = MY_TAB.

WA_FCAT-REF_FIELD = <COMPONENT>-NAME.

APPEND WA_FCAT TO IT_FIELDCATALOG.

ENDLOOP.

CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE

EXPORTING

IT_FIELDCATALOG = IT_FIELDCATALOG

IMPORTING

EP_TABLE = DATAREF

EXCEPTIONS

OTHERS = 1.

ASSIGN DATAREF->* TO <DYN_TABLE>.

L_STUFF-TABNAME = TAB_NAME.

CREATE DATA L_STUFF-TDREF LIKE LINE OF <DYN_TABLE>.

ASSIGN L_STUFF-TDREF->* TO <DYN_WA>.

ENDFORM. "CREATE_TABLE

Anybody pls shows some light?

i've tried using LVC_FIELDCATALOG_MERGE , REUSE_ALV_FIELDCATALOG_MERGE ,LVC_TRANSFER_FROM_SLIS

but to no avail.........pls help,thank you.

3 REPLIES 3
Read only

Former Member
0 Likes
479
DESCR_STRUCT_REF ?= CL_ABAP_TYPEDESCR=>DESCRIBE_BY_DATA( <FS> ).

CLEAN_TABLE IT_FIELDCATALOG.
"<--Are you getting the components in this, is the loop success....check it once also change the fieldcatalog code..

LOOP AT DESCR_STRUCT_REF->COMPONENTS ASSIGNING <COMPONENT>.
 wa_fcat-fieldname = <component>-name .
    wa_fcat-datatype = <COMPONENT>-_kind.
    wa_fcat-inttype = <COMPONENT>--type_kind.
    wa_fcat-intlen = <COMPONENT>--length.
    wa_fcat-decimals = <COMPONENT>--decimals.

APPEND WA_FCAT TO IT_FIELDCATALOG.
ENDLOOP.
Read only

0 Likes
479

hi Vijay,

FORM CREATE_TABLE USING MY_TAB TAB_NAME.

i run it using PERFORM CREATE_TABLE USING 'Z_TAB' TAB_NAME. where the Z_TAB is my internal table,but it wl give run time error at this point. if i pass in table which is maintain in DDIC like MARA..it won't have any error. Pls advice. Thanks

Edited by: Joan Lee on Aug 12, 2008 3:19 AM

Read only

Former Member
0 Likes
479

solved by my own. thx all