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

Dynamic Field catalog

Former Member
0 Likes
2,592

Hello All,

I am creating an ALV using SLIS. The number of columns to be displayed in the ALV are not fixed they are determined using the function module dynamic_table_create. My problem is I want to create the field catalog for the ALV. How can I create the field catalog dynamically.

thanks,

Anju

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,083

Hi ucan do it this way..

For Eg:

DATA: COUNTER TYPE I,

LV_COUNTER TYPE CHAR2,

LV_FIELD TYPE CHAR10.

LOOP AT INT_BUKRS INTO WA_BUKRS.

COUNTER = COUNTER + 1.

LV_COUNTER = COUNTER.

CONCATENATE 'BUKRS' LV_COUNTER INTO LV_FIELD.

CONDENSE LV_FIELD.

IS_LVC_CAT-fieldname = LV_FIELD.

IS_LVC_CAT-SCRTEXT_L = WA_BUKRS.

APPEND IS_LVC_CAT TO IT_LVC_CAT.

IS_FIELDCAT-fieldname = LV_FIELD.

IS_FIELDCAT-OUTPUTLEN = 10.

IS_FIELDCAT-SELTEXT_L = WA_BUKRS.

APPEND IS_FIELDCAT TO IT_FIELDCAT.

ENDLOOP.

  • create dynamic table:

  • Create a new Table

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = IT_LVC_CAT

IMPORTING

ep_table = new_table.

Hope this helps..

There are lot of material in wiki explaining the same..

Best Regards,

navin fernandes.

Hi ucan do it this way..

For Eg:

DATA: COUNTER TYPE I,

LV_COUNTER TYPE CHAR2,

LV_FIELD TYPE CHAR10.

LOOP AT INT_BUKRS INTO WA_BUKRS.

COUNTER = COUNTER + 1.

LV_COUNTER = COUNTER.

CONCATENATE 'BUKRS' LV_COUNTER INTO LV_FIELD.

CONDENSE LV_FIELD.

IS_LVC_CAT-fieldname = LV_FIELD.

IS_LVC_CAT-SCRTEXT_L = WA_BUKRS.

APPEND IS_LVC_CAT TO IT_LVC_CAT.

IS_FIELDCAT-fieldname = LV_FIELD.

IS_FIELDCAT-OUTPUTLEN = 10.

IS_FIELDCAT-SELTEXT_L = WA_BUKRS.

APPEND IS_FIELDCAT TO IT_FIELDCAT.

ENDLOOP.

  • create dynamic table:

  • Create a new Table

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = IT_LVC_CAT

IMPORTING

ep_table = new_table.

Hope this helps..

There are lot of material in wiki explaining the same..

Best Regards,

navin fernandes.

5 REPLIES 5
Read only

Former Member
0 Likes
2,084

Hi ucan do it this way..

For Eg:

DATA: COUNTER TYPE I,

LV_COUNTER TYPE CHAR2,

LV_FIELD TYPE CHAR10.

LOOP AT INT_BUKRS INTO WA_BUKRS.

COUNTER = COUNTER + 1.

LV_COUNTER = COUNTER.

CONCATENATE 'BUKRS' LV_COUNTER INTO LV_FIELD.

CONDENSE LV_FIELD.

IS_LVC_CAT-fieldname = LV_FIELD.

IS_LVC_CAT-SCRTEXT_L = WA_BUKRS.

APPEND IS_LVC_CAT TO IT_LVC_CAT.

IS_FIELDCAT-fieldname = LV_FIELD.

IS_FIELDCAT-OUTPUTLEN = 10.

IS_FIELDCAT-SELTEXT_L = WA_BUKRS.

APPEND IS_FIELDCAT TO IT_FIELDCAT.

ENDLOOP.

  • create dynamic table:

  • Create a new Table

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = IT_LVC_CAT

IMPORTING

ep_table = new_table.

Hope this helps..

There are lot of material in wiki explaining the same..

Best Regards,

navin fernandes.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,083

>

> My problem is I want to create the field catalog for the ALV. How can I create the field catalog dynamically.

You can use the SALV technique to display your dynamic internal table as it doesn't require a field catalog

Refer to my response in this thread:

BR,

Suhas

Read only

MarcinPciak
Active Contributor
0 Likes
2,083

Use fm LVC_TRANSFER_TO_SLIS .

On input pass lvc fieldcatalog (which you used for table generation), on output receive slis one . Then pass your generated table and slis fieldcatalog to REUSE_ALV_GRID_DISPLAY .

Regards

Marcin

Read only

Former Member
0 Likes
2,083

ok

Read only

Former Member
0 Likes
2,083

hello ,

You can use the following code after populating your internaltable ,

LOOP AT IFLDCAT INTO WA_FLDCAT.

IF WA_FLDCAT-FIELDNAME = 'CURRENCY'.

WA_FLDCAT-col_pos = 0.

WA_FLDCAT-EDIT = 'X'.

WA_FLDCAT-seltext_m = 'Curr.of fare'.

WA_FLDCAT-seltext_s = 'Fare in currency'.

MODIFY IFLDCAT FROM WA_FLDCAT .

CLEAR WA_FLDCAT.

ENDIF.

ENDLOOP.

with regards ,

Arvind Venai