12-06-2012 6:17 PM
Hi Experts,
Can any one explain me theoretically how to pass values to field catalog?
Thanks in advance,
Venkatesh.
Moderator message: please search for information before posting.
Message was edited by: Thomas Zloch
12-06-2012 6:34 PM
Hi Venkatesh,
I assume you mean the field catalog that can be passed to the ALV object methods such as cl_gui_alv_grid->set_table_for_first_display.
You can modify the ALV field catalog to hide certain fields, set their width in the ALV, customize column header labels, etc. You can see all options that may be customized by looking at DDIC structure LVC_S_FCAT. For example...
* Read field catalog
call function 'LVC_FIELDCATALOG_MERGE'
exporting
i_structure_name = 'THE_ALV_DDIC_STRUCTURE'
changing
ct_fieldcat = lt_fieldcat.
* Modify field catalog as needed
loop at lt_fieldcat assigning <fc>.
case <fc>-fieldname.
when 'FIELD_1'.
<fc>-tech = abap_true.
when 'FIELD_2'.
<fc>-col_opt = abap_false.
when 'FIELD_3'.
<fc>-outputlen = 15.
when 'FIELD_4'.
<fc>-scrtext_l = 'Long Header Label'.
<fc>-scrtext_m = 'Medium Label'.
<fc>-scrtext_s = 'Short Lbl'.
endcase.
endloop. " <fc>
If the ALV data structure doesn't exist in the Data Dictionary, you can also build the catalog from scratch...
data: ls_fieldcat type lvc_s_fcat,
lt_fieldcat type standard table of lvc_s_fcat.
ls_fieldcat-ref_table = 'TABLE_NAME'.
ls_fieldcat-fieldname = 'FIELD_NAME'.
ls_fieldcat-ref_field = 'REF_FIELD'.
ls_fieldcat-coltext = 'Column Text'.
ls_fieldcat-seltext = 'Dialog Text'.
ls_fieldcat-col_opt = abap_true.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-ref_table = 'MARA'.
ls_fieldcat-fieldname = 'MATNR'.
ls_fieldcat-ref_field = 'MATNR'.
ls_fieldcat-coltext = 'Material'.
ls_fieldcat-seltext = 'The Material'.
ls_fieldcat-col_opt = abap_false.
append ls_fieldcat to lt_fieldcat.
...etc...
Cheers,
Amy