2013 Dec 14 3:43 AM
I'm using salv in my report and use set_list_header to set its title. But when I try to display this salv, its title show up at the top of the report, replacing the report title. As I know, I may have to create a screen and a custom container to contain this salv. But as this is the simple report with only one alv table, I would like to know if there is the alternative way that is simpler than this.
Thank you,
VFP
2013 Dec 16 4:56 AM
Hi,
You can create a header for the ALV.Declare the following and create the object.
DATA: lo_header TYPE REF TO cl_salv_form_layout_grid,
lo_h_label TYPE REF TO cl_salv_form_label.
* Header object
CREATE OBJECT lo_header.
create label after the method factory.o_rslt is the importing parameter of the method factory.
lo_h_label = lo_header->create_label( row = 1 column = 1 ).
lo_h_label->set_text('Title for the ALV').
o_rslt->set_top_of_list( lo_header ).
o_rslt->display( ).
Regards,
Jeffin
2013 Dec 16 4:56 AM
Hi,
You can create a header for the ALV.Declare the following and create the object.
DATA: lo_header TYPE REF TO cl_salv_form_layout_grid,
lo_h_label TYPE REF TO cl_salv_form_label.
* Header object
CREATE OBJECT lo_header.
create label after the method factory.o_rslt is the importing parameter of the method factory.
lo_h_label = lo_header->create_label( row = 1 column = 1 ).
lo_h_label->set_text('Title for the ALV').
o_rslt->set_top_of_list( lo_header ).
o_rslt->display( ).
Regards,
Jeffin
2013 Dec 16 6:22 AM
Hi,
You can create your ALV report along with the header with this simple code. This code contains a to z code for generation of simple ALV. Plz let me know if it is helpfull.
*&---------------------------------------------------------------------*
*& Form F_ALV_REPORT
*&---------------------------------------------------------------------*
* This is a perform for the generation of ALV reporting
*----------------------------------------------------------------------*
FORM f_alv_report USING pt_message_table TYPE gtt_message_table.
*---Local internal table declaration
DATA: lt_layout TYPE slis_layout_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv,
lt_eventexit TYPE slis_t_event_exit.
*---Perform to refresh alv
PERFORM f_event_exits CHANGING lt_eventexit.
*---Perform for building field catalogue
PERFORM f_build_fieldcat CHANGING lt_fieldcat.
*---Perform to build Layout for alv
PERFORM f_build_layout CHANGING lt_layout.
*---Perform to ALV output display
PERFORM f_alv_display USING pt_message_table
lt_layout
lt_fieldcat
lt_eventexit.
ENDFORM. " F_ALV_REPORT
*&---------------------------------------------------------------------*
*& Form F_EVENT_EXITS
*&---------------------------------------------------------------------*
* This Perform is to refresh the alv
*----------------------------------------------------------------------*
FORM f_event_exits CHANGING pt_eventexit TYPE slis_t_event_exit.
*---Local Workarea declaration
DATA: lw_eventexit TYPE slis_event_exit.
*---Local constant declaration
CONSTANTS: lc_ucomm TYPE sy-ucomm VALUE '&REFRESH'.
CLEAR lw_eventexit.
lw_eventexit-ucomm = lc_ucomm. " Refresh
lw_eventexit-after = abap_true.
APPEND lw_eventexit TO pt_eventexit.
ENDFORM. " F_EVENT_EXITS
*&---------------------------------------------------------------------*
*& Form F_BUILD_FIELDCAT
*&---------------------------------------------------------------------*
* This Perform is for building field catalogue
*----------------------------------------------------------------------*
FORM f_build_fieldcat CHANGING pt_fieldcat TYPE slis_t_fieldcat_alv.
*---Local workarea declaration
DATA: lw_fieldcat TYPE slis_fieldcat_alv.
*---Local constant declaration
DATA: lc_tabname TYPE slis_tabname VALUE 'PT_MESSAGE_TABLE',
lc_fieldname_1 TYPE slis_fieldname VALUE 'RESULT',
lc_fieldname_2 TYPE slis_fieldname VALUE 'COUNT'.
CLEAR lw_fieldcat.
lw_fieldcat-row_pos = 1.
lw_fieldcat-col_pos = 1.
lw_fieldcat-fieldname = lc_fieldname_1.
lw_fieldcat-tabname = lc_tabname.
lw_fieldcat-seltext_m = 'Type of Record'.
APPEND lw_fieldcat TO pt_fieldcat.
CLEAR lw_fieldcat.
lw_fieldcat-row_pos = 1.
lw_fieldcat-col_pos = 2.
lw_fieldcat-fieldname = lc_fieldname_2.
lw_fieldcat-tabname = lc_tabname.
lw_fieldcat-seltext_m = 'Number of Records'.
APPEND lw_fieldcat TO pt_fieldcat.
ENDFORM. " F_BUILD_FIELDCAT
*&---------------------------------------------------------------------*
*& Form F_BUILD_LAYOUT
*&---------------------------------------------------------------------*
* This Perform is used to build Layout for alv
*----------------------------------------------------------------------*
FORM f_build_layout CHANGING pt_layout TYPE slis_layout_alv.
pt_layout-zebra = abap_true.
pt_layout-colwidth_optimize = abap_true.
ENDFORM. " F_BUILD_LAYOUT
*&---------------------------------------------------------------------*
*& Form F_ALV_DISPLAY
*&---------------------------------------------------------------------*
* This Perform is used for ALV output display
*----------------------------------------------------------------------*
FORM f_alv_display USING pt_message_table TYPE gtt_message_table
pt_layout TYPE slis_layout_alv
pt_fieldcat TYPE slis_t_fieldcat_alv
pt_eventexit TYPE slis_t_event_exit.
*---Local constant declaration
CONSTANTS: lc_top_of_page TYPE slis_formname VALUE 'TOP-OF-PAGE',
lc_pf_status TYPE slis_formname VALUE 'PFSTATUS'.
*---FM to produce alv display
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_top_of_page = lc_top_of_page
i_callback_pf_status_set = lc_pf_status
it_fieldcat = pt_fieldcat
is_layout = pt_layout
it_event_exit = pt_eventexit
i_screen_start_column = 0
i_screen_start_line = 0
i_screen_end_column = 100
i_screen_end_line = 100
TABLES
t_outtab = pt_message_table.
ENDFORM. " F_ALV_DISPLAY
*---------------------------------------------------------------------*
* FORM PFSTATUS
*---------------------------------------------------------------------*
* This perform for settings the pf status to the alv
*---------------------------------------------------------------------*
FORM pfstatus USING ut_extab TYPE slis_t_extab.
SET PF-STATUS 'STANDARD_FULLSCREEN' OF PROGRAM 'SAPLKKBL'.
ENDFORM. " PF_STATUS_SET
*-------------------------------------------------------------------*
* Form TOP-OF-PAGE *
*-------------------------------------------------------------------*
* Perform for ALV Report Header *
*-------------------------------------------------------------------*
FORM top-of-page.
*---Local Internal Table Declaration
DATA: lt_header TYPE slis_t_listheader.
*---Local Workarea Declaration
DATA: lw_header TYPE slis_listheader.
*---Local constant declaration
CONSTANTS: lc_h TYPE c VALUE 'H'.
*---Report Title
lw_header-typ = lc_h.
lw_header-info = text-010.
APPEND lw_header TO lt_header.
CLEAR lw_header.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = lt_header.
ENDFORM. "top-of-page