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

Populating Field Catalog using Global Classes.

Former Member
0 Likes
1,386

Hi, I'm new to ABAP. I want to display an alv report using oops abap. While populating field catalog I'm defining work area type lvc_s_fcat and an internal table type lvc_t_fcat and doing the field catalog population as follows:

i_fieldcatalog type lvc_s_fcat

t_fieldcatalog type lvc_t_fcat

clear i_fieldcat

i_fieldcatalog-colpos = 1.

i_fieldcatalog-fieldname = 'MATNR'.

i_fieldcatalog-tabname = 'IT_FINAL'.........

...........

append i_fieldcatalog to t_fieldcatalog.

............

.............

in similar manner i'm populating the field catalog internal table and finally calling set_table_for_first_display method and passing structure and internal table to it and I'm getting the alv.

Instead of this manner is there any other manner by which I can populate field catalog i.e., is there any global class which I can use by which when I call that class and pass my internal table to its parameter and my field catalog internal table will be automatically populated ??? Please respond.....

1 ACCEPTED SOLUTION
Read only

aferngas
Active Participant
0 Likes
865

Hi Vidhya,

Your should fill the following fields:

  • FIELDNAME with fieldname of your internal table
  • REF_TABLE with DDIC table name
  • REF_FIELD with DDIC field name of table referenced in REF_TABLE

Also you can use the function 'LVC_FIELDCATALOG_MERGE' or use SALV model.

Best regards,

Alex

2 REPLIES 2
Read only

aferngas
Active Participant
0 Likes
866

Hi Vidhya,

Your should fill the following fields:

  • FIELDNAME with fieldname of your internal table
  • REF_TABLE with DDIC table name
  • REF_FIELD with DDIC field name of table referenced in REF_TABLE

Also you can use the function 'LVC_FIELDCATALOG_MERGE' or use SALV model.

Best regards,

Alex

Read only

hendrik_brandes
Contributor
0 Likes
865

Hello,

have you tried the SALV-Framework? There, you do not have to deal directly with the field-catalog.

Look at the classes CL_SALV_TABLE.

Example:

DATA:

  lt_sflight    TYPE TABLE OF sflight.

DATA:

  lr_columns  TYPE REF TO cl_salv_columns_list,
  lr_funcs       TYPE REF TO cl_salv_functions_list,
  lr_salv         TYPE REF TO cl_salv_table.

SELECT * FROM sflight INTO TABLE lt_sflight.

cl_salv_table=>factory(
IMPORTING r_salv_table   = lr_salv
CHANGING  t_table        = lt_sflight
).
lr_funcs = lr_salv->get_functions( ).
*lr_funcs->set_default( ).
lr_funcs->set_all( ).

lr_columns = lr_salv->GET_COLUMNS( ).

* Modify columns.


lr_salv->display( ).

Kind regards,

Hendrik