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

Creating an internal table dynamic

luscruz
Participant
0 Likes
948

Hi all,

I need to create a dynamic internal table with all the fields of a structure/table and one field of type LVC_T_STYL.

Imagine the following simple program:

PARAMETERS: p_tab  TYPE dd02l-tabname DEFAULT 'SYST'.

DATA: lo_table TYPE REF TO data,
lt_fieldcat TYPE slis_t_fieldcat_alv,
lt_fieldcat1 TYPE lvc_t_fcat.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = p_tab
CHANGING
ct_fieldcat = lt_fieldcat
EXCEPTIONS
OTHERS = 99.

MOVE-CORRESPONDING: lt_fieldcat TO lt_fieldcat1.

CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt_fieldcat1
IMPORTING
ep_table = lo_table
EXCEPTIONS
OTHERS = 99.

ASSIGN lo_table->* TO FIELD-SYMBOL(<wa_tab>).

Now how can I add another column of type LVC_T_STYL ?

Since it's a table I cannot add it to lt_fieldcat, I guess.

Many thanks

3 REPLIES 3
Read only

Sandra_Rossi
Active Contributor
892

Please don't use CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE as explained here: Alternative to CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE | SAP Blogs

Read only

Sandra_Rossi
Active Contributor
0 Likes
892

Pass the parameter I_STYLE_TABLE = 'X'.

Read only

luscruz
Participant
0 Likes
892

Thank you.