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

experts doubt again

Former Member
0 Likes
330

HI

What are the steps to create a dynamic ALV ? can some one help me out.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
312

Its very simple if you understand .

make these declarations

DATA: L_STRUCTURE TYPE REF TO DATA,

L_TABLE TYPE REF TO DATA,

STRUC_DESC TYPE REF TO CL_ABAP_STRUCTDESCR,

LS_LVC_FIELDCATALOGUE TYPE LVC_S_FCAT,

LT_LVC_FIELDCATALOGUE TYPE LVC_T_FCAT.

FIELD-SYMBOLS :

<IT_TABLE> TYPE STANDARD TABLE,

<DYN_STR> TYPE ANY,

<STR_COMP> TYPE ABAP_COMPDESCR.

Then we create the structure dynamically,

Syntax:

  • Dynamic creation of a structure

CREATE DATA L_STRUCTURE TYPE (P_TABLE).

ASSIGN L_STRUCTURE->* TO <DYN_STR>.* Fields Structure

STRUC_DESC ?= CL_ABAP_TYPEDESCR=>DESCRIBE_BY_DATA( <DYN_STR> ).

We build the fieldcatalog by looping the structure :

LOOP AT STRUC_DESC->COMPONENTS ASSIGNING <STR_COMP>.

  • Build Fieldcatalog

LS_LVC_FIELDCATALOGUE-FIELDNAME = <STR_COMP>-NAME.

LS_LVC_FIELDCATALOGUE-REF_TABLE = P_TABLE.

APPEND LS_LVC_FIELDCATALOGUE TO LT_LVC_FIELDCATALOGUE.

  • Build Fieldcatalog

LS_FIELDCATALOGUE-FIELDNAME = <STR_COMP>-NAME.

LS_FIELDCATALOGUE-REF_TABNAME = P_TABLE.

APPEND LS_FIELDCATALOGUE TO LT_FIELDCATALOGUE.

ENDLOOP.

Then we create the dynamic internal table:

CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE

EXPORTING

IT_FIELDCATALOG = LT_LVC_FIELDCATALOGUE

IMPORTING

EP_TABLE = L_TABLE. ASSIGN L_TABLE->* TO <IT_TABLE>.

Then its a dynamic select if required we can Use. rest is the same process.

i will give you a link again

http://www.saptechnical.com/Tutorials/ALV/DynamicALV/Demo.htm

1 REPLY 1
Read only

Former Member
0 Likes
313

Its very simple if you understand .

make these declarations

DATA: L_STRUCTURE TYPE REF TO DATA,

L_TABLE TYPE REF TO DATA,

STRUC_DESC TYPE REF TO CL_ABAP_STRUCTDESCR,

LS_LVC_FIELDCATALOGUE TYPE LVC_S_FCAT,

LT_LVC_FIELDCATALOGUE TYPE LVC_T_FCAT.

FIELD-SYMBOLS :

<IT_TABLE> TYPE STANDARD TABLE,

<DYN_STR> TYPE ANY,

<STR_COMP> TYPE ABAP_COMPDESCR.

Then we create the structure dynamically,

Syntax:

  • Dynamic creation of a structure

CREATE DATA L_STRUCTURE TYPE (P_TABLE).

ASSIGN L_STRUCTURE->* TO <DYN_STR>.* Fields Structure

STRUC_DESC ?= CL_ABAP_TYPEDESCR=>DESCRIBE_BY_DATA( <DYN_STR> ).

We build the fieldcatalog by looping the structure :

LOOP AT STRUC_DESC->COMPONENTS ASSIGNING <STR_COMP>.

  • Build Fieldcatalog

LS_LVC_FIELDCATALOGUE-FIELDNAME = <STR_COMP>-NAME.

LS_LVC_FIELDCATALOGUE-REF_TABLE = P_TABLE.

APPEND LS_LVC_FIELDCATALOGUE TO LT_LVC_FIELDCATALOGUE.

  • Build Fieldcatalog

LS_FIELDCATALOGUE-FIELDNAME = <STR_COMP>-NAME.

LS_FIELDCATALOGUE-REF_TABNAME = P_TABLE.

APPEND LS_FIELDCATALOGUE TO LT_FIELDCATALOGUE.

ENDLOOP.

Then we create the dynamic internal table:

CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE

EXPORTING

IT_FIELDCATALOG = LT_LVC_FIELDCATALOGUE

IMPORTING

EP_TABLE = L_TABLE. ASSIGN L_TABLE->* TO <IT_TABLE>.

Then its a dynamic select if required we can Use. rest is the same process.

i will give you a link again

http://www.saptechnical.com/Tutorials/ALV/DynamicALV/Demo.htm