In a report development using set_table_for_first_display Method of CL_GUI_ALV_GRID class.
I am required to over write the text given in the data elements for all the fields and display customized text, for the ALV column texts.When we display the report , by default we will get the field label text (DDIC Objet )assigned to that field in report output.
Here in this post i am going to explain you, how to customize the column headers.
FM to generate Field catalog :
FM Signature:
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = 'ZSTRUCT' "DDIC object
CHANGING
CT_FIELDCAT = ITAB_FIELDCAT "Field catalog ref to lvc_s_fcat
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
Changing the default display text with customized one.
LOOP AT itab_fieldcat ASSIGNING <fs_fieldcat>. "Fied symbol type lvc_s_fcat
IF <fs_fieldcat>-fieldname = 'CARRID'.
<fs_fieldcat>-reptext = 'Flight'.
<fs_fieldcat>-scrtext_l = 'Flight Name'.
<fs_fieldcat>-scrtext_m = 'Flight Name'.
<fs_fieldcat>-scrtext_s = 'Flight'.
<fs_fieldcat>-outputlen = 10.
ENDIF.
Method to display report output
CALL METHOD obj_grid->set_table_for_first_display
EXPORTING i_structure_name = 'ZSTRUCTURE' "Global Struct
is_layout = wa_layout " Layout
CHANGING
it_outtab = itab_output "Final Internal Table refer to struct
it_fieldcatalog = itab_fieldcatalog "Field catalog
If you run the above report ...
For CARRID column you will get <fs_fieldcat>-scrtext_s text i.e 'Flight' or Medium or Long based the length of Column output value .
If you did n't customize the column headers , you will get ID as column name in Short , in other cases Medium and Long ... it will change according to Field label of CARRID data element.
Note 1 : In order to get customized texts in report output , Short Medium and Long texts should be there.if not,you will get DDIC Reference texts only in output.
Note 2 : If Short text presents , you will get that in output. if not, reptext will get display in output.
I am required to over write the text given in the data elements for all the fields and display customized text, for the ALV column texts.When we display the report , by default we will get the field label text (DDIC Objet )assigned to that field in report output.
Here in this post i am going to explain you, how to customize the column headers.
FM to generate Field catalog :
FM Signature:
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = 'ZSTRUCT' "DDIC object
CHANGING
CT_FIELDCAT = ITAB_FIELDCAT "Field catalog ref to lvc_s_fcat
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
Changing the default display text with customized one.
LOOP AT itab_fieldcat ASSIGNING <fs_fieldcat>. "Fied symbol type lvc_s_fcat
IF <fs_fieldcat>-fieldname = 'CARRID'.
<fs_fieldcat>-reptext = 'Flight'.
<fs_fieldcat>-scrtext_l = 'Flight Name'.
<fs_fieldcat>-scrtext_m = 'Flight Name'.
<fs_fieldcat>-scrtext_s = 'Flight'.
<fs_fieldcat>-outputlen = 10.
ENDIF.
Method to display report output
CALL METHOD obj_grid->set_table_for_first_display
EXPORTING i_structure_name = 'ZSTRUCTURE' "Global Struct
is_layout = wa_layout " Layout
CHANGING
it_outtab = itab_output "Final Internal Table refer to struct
it_fieldcatalog = itab_fieldcatalog "Field catalog
If you run the above report ...
For CARRID column you will get <fs_fieldcat>-scrtext_s text i.e 'Flight' or Medium or Long based the length of Column output value .
If you did n't customize the column headers , you will get ID as column name in Short , in other cases Medium and Long ... it will change according to Field label of CARRID data element.
Note 1 : In order to get customized texts in report output , Short Medium and Long texts should be there.if not,you will get DDIC Reference texts only in output.
Note 2 : If Short text presents , you will get that in output. if not, reptext will get display in output.
No comments:
Post a Comment