Subscribe

RSS Feed (xml)



Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Tuesday, November 16, 2010

Hiding the print info of the ALV list in the spool

Whenever we execute an ALV list (using the function module REUSE_ALV_LIST_DISPLAY), the spool would look as follows (Program used: SAPBC405_408OTHD_FB_ALV_LIST):

We have additional information regarding the Records passed (Data statistics). This information might not be required to the end-users (in fact, might be confusing) and can be hidden.

For our demo purpose, let's take a copy of the program SAPBC405_408OTHD_FB_ALV_LIST.

Make the following changes as highlighted:

To hide the data statistics, we have set the parameter no_print_listinfos in slis_print_alv to 'X'.

Here is the final output:

Create, Modify and Delete entries dynamically from any custom table by using Object Oriented ALV

Objective:

This program is used to create, modify and delete entries dynamically from any custom table by using object oriented ALV.

Step by Step procedure

1. Go to SE80-> create a program and write the following code

TYPE-POOLS:
vimty.
TYPES :
BEGIN OF ty_mod,
row TYPE i,
END OF ty_mod.
DATA:
g_container TYPE scrfname VALUE 'CUSTOM_CONTAINER',
grid1 TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container.
DATA:
i_table TYPE REF TO data,
wa_all TYPE REF TO data.
DATA:
org_crit_inst TYPE vimty_oc_type,
old_rc LIKE sy-subrc,
act_level LIKE authb-actvt,
only_show_allowed TYPE c,
i_exclude TYPE ui_functions.
DATA :
i_mod TYPE STANDARD TABLE OF ty_mod,
i_del TYPE STANDARD TABLE OF ty_mod.
FIELD-SYMBOLS:
TYPE table,
TYPE ANY.
DATA: BEGIN OF header OCCURS 1.
INCLUDE STRUCTURE vimdesc.
DATA: END OF header.
DATA: BEGIN OF namtab OCCURS 50.
INCLUDE STRUCTURE vimnamtab.
DATA: END OF namtab.
DATA: vim_wheretab LIKE vimwheretb OCCURS 10.
DATA: dba_sellist LIKE vimsellist OCCURS 10.
SELECTION-SCREEN BEGIN OF BLOCK bb WITH FRAME TITLE text-100.
PARAMETER: viewname TYPE tvdir-tabname.
SELECTION-SCREEN SKIP 2.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN PUSHBUTTON 20(10) text-101 USER-COMMAND b1. "Display
SELECTION-SCREEN PUSHBUTTON 36(10) text-102 USER-COMMAND b2. "Change
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK bb.
AT SELECTION-SCREEN.
CASE sy-ucomm.
WHEN 'B1'.
SET PF-STATUS 'ALV'.
CALL SCREEN 9001.
WHEN 'B2'.
SET PF-STATUS 'ALV1'.
CALL SCREEN 9001.
ENDCASE.
* Class used to get changed data
CLASS lcl_event_handler DEFINITION .
PUBLIC SECTION .
METHODS: handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed.
ENDCLASS. "lcl_event_handler DEFINITION
* Class used to get changed data
CLASS lcl_event_handler IMPLEMENTATION .
* Handle Data Changed
METHOD handle_data_changed .
PERFORM handle_data_changed USING er_data_changed .
ENDMETHOD. "handle_data_changed
ENDCLASS.                    "lcl_event_handler IMPLEMENTATION 

Save and activate.

2. Create a screen 9001 with custom container.

Screen 9001 flow logic looks like the following

3. In the PBO event (Module STATUS_9001), write the following code.

*&---------------------------------------------------------------------*
*& Module STATUS_9001 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_9001 OUTPUT.
DATA :
gr_event_handler TYPE REF TO lcl_event_handler .
* Creating an instance for the event handler
CREATE OBJECT gr_event_handler .
  TRY.
CREATE DATA i_table TYPE TABLE OF (viewname).
ASSIGN i_table->* TO .
      CREATE DATA wa_all LIKE LINE OF .
ASSIGN wa_all->* TO .
*     Selecting data dynamically
SELECT * FROM (viewname) INTO TABLE .
*     Building the fieldcatelog
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = viewname
CHANGING
ct_fieldcat = li_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*     Making fields editable except key fields
IF sy-ucomm = 'UPD' OR sy-ucomm = 'CHANGE'.
LOOP AT li_fieldcat INTO lwa_fieldcat.
IF lwa_fieldcat-key = space.
lwa_fieldcat-edit = 'X'.
MODIFY li_fieldcat FROM lwa_fieldcat.
ENDIF.
ENDLOOP.
      ENDIF.
*     Making fields editable
IF sy-ucomm = 'NEW'.
LOOP AT li_fieldcat INTO lwa_fieldcat.
lwa_fieldcat-edit = 'X'.
MODIFY li_fieldcat FROM lwa_fieldcat.
ENDLOOP.
lh_flag = 'X'.
CLEAR : .
DO 100 TIMES.
APPEND TO .
ENDDO.
ENDIF.
*     Exclude buttons
PERFORM exclude_tb_functions CHANGING i_exclude.
      IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING
container_name = g_container.
CREATE OBJECT grid1
EXPORTING
i_parent = g_custom_container.
ENDIF.
* Making all fields non-editable if display mode
IF sy-ucomm = 'SHOW'.
LOOP AT li_fieldcat INTO lwa_fieldcat.
lwa_fieldcat-edit = ' '.
MODIFY li_fieldcat FROM lwa_fieldcat.
ENDLOOP.
ENDIF.
IF sy-ucomm = 'SAVE'.
LOOP AT li_fieldcat INTO lwa_fieldcat.
IF lwa_fieldcat-key NE space.
lwa_fieldcat-edit = space.
MODIFY li_fieldcat FROM lwa_fieldcat.
ENDIF.
ENDLOOP.
ENDIF.
* Displaying ALV Grid
CALL METHOD grid1->set_table_for_first_display
EXPORTING
i_structure_name = viewname
it_toolbar_excluding = i_exclude
CHANGING
it_outtab =
it_fieldcatalog = li_fieldcat.
      IF sy-subrc NE 0.
EXIT.
ENDIF.
*      Getting the changed data
SET HANDLER gr_event_handler->handle_data_changed FOR grid1 .
    CATCH cx_sy_create_data_error.
  ENDTRY.
ENDMODULE.                 " STATUS_9001  OUTPUT

4. In the PAI Event (Module USER_COMMAND_9001), write the following code

*&------------------------------------------------------------* *& Module USER_COMMAND_9001 INPUT *&------------------------------------------------------------* * text *-------------------------------------------------------------* MODULE user_command_9001 INPUT. DATA : lh_norec TYPE i, lh_total(5) TYPE c, lh_succ(40) TYPE c, lwa_del TYPE ty_mod, lwa_mod TYPE ty_mod, lh_totdel TYPE i, lh_flag TYPE c, li_fieldcat TYPE lvc_t_fcat, lwa_fieldcat TYPE lvc_s_fcat. CASE sy-ucomm. WHEN 'CHANGE'. SET PF-STATUS 'ALV1'. WHEN 'SAVE'. * Lock the table CALL FUNCTION 'ENQUEUE_E_TABLE' EXPORTING mode_rstable = 'E' tabname = viewname EXCEPTIONS foreign_lock = 1 system_failure = 2 OTHERS = 3. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. IF NOT grid1 IS INITIAL . CALL METHOD grid1->check_changed_data . ENDIF . SORT i_mod BY row. DELETE ADJACENT DUPLICATES FROM i_mod COMPARING row. lh_norec = LINES( i_mod ). lh_total = lh_norec. SHIFT lh_total LEFT DELETING LEADING space. * Standard Table Update IF i_mod[] IS NOT INITIAL. LOOP AT i_mod INTO lwa_mod. READ TABLE INTO INDEX lwa_mod-row. IF sy-subrc = 0 . IF lh_flag NE 'X'. MODIFY (viewname) FROM . ELSE. INSERT (viewname) FROM . IF sy-subrc NE 0. MESSAGE e009. ENDIF. ENDIF. ENDIF. ENDLOOP. CONCATENATE lh_total ' ' text-s01 INTO lh_succ SEPARATED BY space. MESSAGE i000 WITH lh_succ. ELSE. MESSAGE i000 WITH text-s02. ENDIF. * Unlock the table CALL FUNCTION 'DEQUEUE_E_TABLE' EXPORTING mode_rstable = 'E' tabname = viewname. CLEAR : i_mod[], lh_flag. WHEN 'DELETE'. * Selecting Selected Rows PERFORM handle_user_command USING sy-ucomm. IF i_del[] IS NOT INITIAL. LOOP AT i_del INTO lwa_del. READ TABLE INTO INDEX lwa_del-row. IF sy-subrc = 0. DELETE (viewname) FROM . ENDIF. ENDLOOP. lh_totdel = LINES( i_del ). MESSAGE i011 WITH lh_totdel. CLEAR : i_del[], lh_totdel . ELSE. MESSAGE i000 WITH text-s03. ENDIF. WHEN 'EXIT' OR 'BACK' OR 'CANCEL'. CLEAR : li_fieldcat[], i_exclude[], i_del[], lh_totdel. LEAVE TO SCREEN 0. ENDCASE. ENDMODULE. " USER_COMMAND_9001 INPUT

5. Write the following forms at the end of the program

*&---------------------------------------------------------------------* *& Form handle_data_changed *&---------------------------------------------------------------------* FORM handle_data_changed USING p_er_data_changed TYPE REF TO cl_alv_changed_data_protocol. DATA : lwa_mod_cell TYPE lvc_s_modi, lwa_mod TYPE ty_mod. LOOP AT p_er_data_changed->mt_good_cells INTO lwa_mod_cell. lwa_mod-row = lwa_mod_cell-row_id. APPEND lwa_mod TO i_mod. ENDLOOP. ENDFORM. " handle_data_changed *&---------------------------------------------------------------------* *& Form exclude_tb_functions *&---------------------------------------------------------------------* FORM exclude_tb_functions CHANGING pt_exclude TYPE ui_functions . DATA: lwa_exclude TYPE ui_func. lwa_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row. APPEND lwa_exclude TO pt_exclude. lwa_exclude = cl_gui_alv_grid=>mc_fc_loc_copy. APPEND lwa_exclude TO pt_exclude. lwa_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row. APPEND lwa_exclude TO pt_exclude. lwa_exclude = cl_gui_alv_grid=>mc_fc_loc_cut. APPEND lwa_exclude TO pt_exclude. lwa_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row. APPEND lwa_exclude TO pt_exclude. lwa_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row. APPEND lwa_exclude TO pt_exclude. lwa_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row. APPEND lwa_exclude TO pt_exclude. lwa_exclude = cl_gui_alv_grid=>mc_fc_loc_paste. APPEND lwa_exclude TO pt_exclude. lwa_exclude = cl_gui_alv_grid=>mc_fc_loc_paste_new_row. APPEND lwa_exclude TO pt_exclude. ENDFORM. "exclude_tb_functions *&---------------------------------------------------------------------* *& Form handle_user_command *&---------------------------------------------------------------------* FORM handle_user_command USING p_ucomm TYPE syucomm. DATA : i_selected_rows TYPE lvc_t_roid . DATA : lwa_selected_row TYPE lvc_s_roid, lwa_del TYPE ty_mod. CALL METHOD grid1->get_selected_rows IMPORTING et_row_no = i_selected_rows. LOOP AT i_selected_rows INTO lwa_selected_row. lwa_del-row = lwa_selected_row-row_id. APPEND lwa_del TO i_del. ENDLOOP. ENDFORM. " handle_user_command

6. Create PF Status like “ALV”



7. Create PF Status “ALV1”

8. Create Text Elements

9. Create transaction for the program (T-code – SE93)

Save and activate

10. Execute the transaction (ZOOALV)

Select any custom table (starting with z or y). Ex- ZZZTESTTIME

Press Display button

Output



Press Change Button

Press Create Button

Type data and SAVE

Press Change Button

Before Changing

Changing Value

Save

After saving

Delete

After Delete





Coloring of the cells in the F4 help of ALV

Report ztests. 
TYPE-POOLS SLIS. 
DATA: BEGIN OF itab OCCURS 0,
BUKRS LIKE T001-BUKRS,
BUTXT LIKE T001-BUTXT,
END OF itab.
PARAMETERS: P_BUKRS TYPE BUKRS. 
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_BUKRS. 
  PERFORM F4_FOR_BUKRS.
*&---------------------------------------------------------------------*
*& Form F4_FOR_BUKRS
*----------------------------------------------------------------------*
FORM F4_FOR_BUKRS.
  DATA: IT_FIELDCAT TYPE  SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
ES_SELFIELD TYPE SLIS_SELFIELD.
* Get data
SELECT BUKRS
BUTXT
FROM T001
INTO TABLE itab
up to 10 rows .
* Get field
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-REPID
I_INTERNAL_TABNAME = 'ITAB'
CHANGING
CT_FIELDCAT = IT_FIELDCAT[].
  LOOP AT IT_FIELDCAT.
IT_FIELDCAT-KEY = SPACE.
IF IT_FIELDCAT-FIELDNAME = 'BUTXT'.
IT_FIELDCAT-EMPHASIZE = 'C710'.
ENDIF.
IF IT_FIELDCAT-FIELDNAME = 'BUKRS'.
IT_FIELDCAT-EMPHASIZE = 'C610'.
ENDIF.
    MODIFY IT_FIELDCAT.
ENDLOOP.
  CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
EXPORTING
I_TITLE = 'THIS IS FOR F4 IN COLOR'
I_TABNAME = 'ITAB'
IT_FIELDCAT = IT_FIELDCAT[]
IMPORTING
ES_SELFIELD = ES_SELFIELD
TABLES
T_OUTTAB = ITAB .
ENDFORM.                    " F4_FOR_BUKRS

When we press F4 on the parameter, the following list appears (in colors):

Printing a line after every subtotaling in ALV

REPORT  ztest_alv.
*---type pools
TYPE-POOLS: slis.
*---internal tables
DATA: BEGIN OF it_flight OCCURS 0,
carrid LIKE sflight-carrid,
connid LIKE sflight-connid,
fldate LIKE sflight-fldate,
seatsmax LIKE sflight-seatsmax,
seatsocc LIKE sflight-seatsocc,
END OF it_flight,
*--internal tables for alv
it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fcat LIKE LINE OF it_fieldcat,
layout TYPE slis_layout_alv,
it_sort type slis_t_sortinfo_alv,
wa_sort like line of it_sort.
*---start-of-selection .
START-OF-SELECTION.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'IT_FLIGHT'
i_inclname = sy-repid
CHANGING
ct_fieldcat = it_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2.
*----get data
SELECT carrid
connid
fldate
seatsmax
seatsocc
FROM sflight
INTO CORRESPONDING FIELDS OF TABLE it_flight
UP TO 20 ROWS.
.
wa_fcat-do_sum = 'X'.
MODIFY it_fieldcat FROM wa_fcat TRANSPORTING do_sum
WHERE fieldname = 'SEATSOCC' .
  wa_sort-fieldname = 'CARRID'.
wa_sort-group = 'UL'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
  wa_sort-fieldname = 'CONNID'.
wa_sort-subtot = 'X'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = layout
it_fieldcat = it_fieldcat
it_sort = it_sort
TABLES
t_outtab = it_flight
EXCEPTIONS
program_error = 1.

The output would be similar to this:

Simple interactive ALV Tree calling ALV list display

*&----------------------------------------------------------------*
*& Simple Interactive alv tree, calling ALV List display
*& Author:Banupriya
*& Published at SAPTechnical.COM
*&----------------------------------------------------------------*
REPORT  yh_alvtreedemo1.
TYPE-POOLS : fibs,stree.
TYPE-POOLS:slis.
DATA : t_node TYPE snodetext.
DATA : it_node LIKE TABLE OF t_node,
wa_node LIKE t_node.
DATA: t_fieldcat    TYPE slis_t_fieldcat_alv,
fs_fieldcat TYPE slis_fieldcat_alv.
DATA:w_repid LIKE sy-repid.
*Internal Table declarations
DATA: BEGIN OF fs_scarr,
carrid LIKE scarr-carrid,
END OF fs_scarr.
DATA:BEGIN OF fs_spfli,
carrid LIKE spfli-carrid,
connid LIKE spfli-connid,
END OF fs_spfli.
DATA:BEGIN OF fs_sflight,
carrid LIKE sflight-carrid,
connid LIKE sflight-connid,
fldate LIKE sflight-fldate,
END OF fs_sflight.
DATA:BEGIN OF fs_sbook,
carrid LIKE sbook-carrid,
connid LIKE sbook-connid,
fldate LIKE sbook-fldate,
bookid LIKE sbook-bookid,
END OF fs_sbook.
DATA:t_scarr LIKE TABLE OF fs_scarr,
t_spfli LIKE TABLE OF fs_spfli,
t_sflight LIKE TABLE OF fs_sflight,
t_sbook LIKE TABLE OF fs_sbook.
START-OF-SELECTION.
  PERFORM get_data.
PERFORM build_tree.
PERFORM display_tree.
*&----------------------------------------------------------------*
*& Form get_data
*&----------------------------------------------------------------*
FORM get_data .
  SELECT carrid
FROM scarr
INTO TABLE t_scarr.
  SELECT carrid
connid
FROM spfli
INTO TABLE t_spfli
FOR ALL ENTRIES IN t_scarr
WHERE carrid EQ t_scarr-carrid.
ENDFORM.                    " get_data
*&----------------------------------------------------------------*
*& Form build_tree
*&----------------------------------------------------------------*
FORM build_tree .
CLEAR: it_node,
wa_node.
  SORT: t_scarr BY carrid,
t_spfli BY carrid connid,
t_sflight BY carrid connid fldate,
t_sbook BY carrid connid fldate bookid.
  wa_node-type = 'T'.
wa_node-name = 'Flight Details'.
wa_node-tlevel = '01'.
wa_node-nlength = '15'.
wa_node-color = '4'.
wa_node-text = 'Flight'.
wa_node-tlength ='20'.
wa_node-tcolor = 3.
APPEND wa_node TO it_node.
CLEAR wa_node.
  LOOP AT t_scarr INTO fs_scarr.
    wa_node-type = 'P'.
wa_node-name = 'CARRID'.
wa_node-tlevel = '02'.
wa_node-nlength = '8'.
wa_node-color = '1'.
wa_node-text = fs_scarr-carrid.
wa_node-tlength ='20'.
wa_node-tcolor = 4.
APPEND wa_node TO it_node.
CLEAR wa_node.
    LOOP AT t_spfli INTO fs_spfli WHERE carrid EQ fs_scarr-carrid.
      wa_node-type = 'P'.
wa_node-name = 'CONNID'.
wa_node-tlevel = '03'.
wa_node-nlength = '8'.
wa_node-color = '1'.
wa_node-text = fs_spfli-connid.
wa_node-tlength ='20'.
wa_node-tcolor = 4.
APPEND wa_node TO it_node.
CLEAR wa_node.
    ENDLOOP.
ENDLOOP.
ENDFORM. " build_tree
*&----------------------------------------------------------------*
*& Form display_tree
*&----------------------------------------------------------------*
FORM display_tree .
CALL FUNCTION 'RS_TREE_CONSTRUCT'
TABLES
nodetab = it_node.
  w_repid = sy-repid.
  CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
EXPORTING
callback_program = w_repid
callback_user_command = 'USER_COMMAND'
callback_gui_status = 'SET_PF'.
ENDFORM. " display_tree
*&----------------------------------------------------------------*
*& Form pick
*&----------------------------------------------------------------*
* -->COMMAND text
* -->NODE text
*-----------------------------------------------------------------*
FORM user_command    TABLES pt_nodes         STRUCTURE seucomm
USING pv_command TYPE c
CHANGING pv_exit TYPE c
pv_list_refresh TYPE c.
  pv_list_refresh = 'X'.
  IF pt_nodes-tlevel = '03'.
    CLEAR t_fieldcat[].
    SELECT carrid
connid
fldate
FROM sflight
INTO TABLE t_sflight
WHERE connid EQ pt_nodes-text.
    fs_fieldcat-col_pos = 1.
fs_fieldcat-fieldname = 'CARRID'.
fs_fieldcat-seltext_m = 'Airlinecarrier'.
fs_fieldcat-key = 'X'.
fs_fieldcat-hotspot = 'X'.
APPEND fs_fieldcat TO t_fieldcat.
CLEAR fs_fieldcat.
    fs_fieldcat-col_pos = 2.
fs_fieldcat-fieldname = 'CONNID'.
fs_fieldcat-seltext_m = 'Connection No'.
fs_fieldcat-key = 'X'.
fs_fieldcat-hotspot = 'X'.
APPEND fs_fieldcat TO t_fieldcat.
CLEAR fs_fieldcat.
    fs_fieldcat-col_pos = 3.
fs_fieldcat-fieldname = 'FLDATE'.
fs_fieldcat-seltext_m = 'Flight Date'.
fs_fieldcat-key = 'X'.
fs_fieldcat-hotspot = 'X'.
APPEND fs_fieldcat TO t_fieldcat.
CLEAR fs_fieldcat.
    w_repid = sy-repid.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = w_repid
it_fieldcat = t_fieldcat[]
TABLES
t_outtab = t_sflight.
ENDIF.
ENDFORM. "pick
*&----------------------------------------------------------------*
*& Form set_pf
*&----------------------------------------------------------------*
* text
*-----------------------------------------------------------------*
FORM set_pf.
SET PF-STATUS 'MYPF'.
ENDFORM. "set_pf

OUTPUT:

Primary Screen:

OUTPUT:

Secondary screen:

Increasing the width of the spool when using ALV List

Whenever an ALV report (with more number of columns) is scheduled in background, the output will be displayed in a zigzag fashion as shown below:

If we try to download the output from the spool or try to view the output, then we observe that the output is not in an appropriate fashion.

To get the right format of output in the spool we generally increase the “no. of columns field” in the Format types”. Have a look at the following screenshot:

Sometimes even when we change this field, we get the output truncated at the end, like last few columns are not displayed. There is certain limitation for this field, so that even if increase this value again, we find no change in the output display in spool.

This value is effective only when we check the check box “Number of columns from list display format” in the SPAD transaction.

Ø GO to SPAD Transaction code

Ø In the menu Settings -> Spool System as shown below…

Ø In the others tab check the first check box in the Output Controller block, SAVE and exit.

Now Schedule the ALV report again by providing the output device and format, and then we get the full output in the spool as shown below:

ALV with user-defined menu on toolbar

REPORT ZALV_INTMENUTOOL.
*Author : Swarna.S.
*AS : Simple ALV with user defined menu in toolbar
* Published at SAPTechnical.COM
*Class declarations
CLASS lcl_event_receiver DEFINITION DEFERRED.
*type pool declarations
TYPE-POOLS : icon.
*Internal table and work area declarations for dd02l
DATA: it_dd02l TYPE TABLE OF dd02l,
wa_dd02l TYPE dd02l.
*Data declaration for alv.
DATA :it_layout TYPE lvc_s_layo,
it_toolbar TYPE stb_button,
c_alv TYPE REF TO cl_gui_alv_grid,
custom_container TYPE REF TO cl_gui_custom_container,
event_receiver TYPE REF TO lcl_event_receiver.
*Select options multiple values no ranges
SELECT-OPTIONS : s_table FOR wa_dd02l-tabname NO INTERVALS.
*Initialization event
INITIALIZATION.
*Start of selection event
START-OF-SELECTION.
*sUBROUTINE FOR ALV DISPLAY
PERFORM alvdisplay.
*Class definition
CLASS lcl_event_receiver DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS:
*handling toolbar for interactive
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive,
*handling menu button
handle_menu_button
FOR EVENT menu_button OF cl_gui_alv_grid
IMPORTING e_object e_ucomm,
*On click of the menu button
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
  PRIVATE SECTION.
ENDCLASS.                    "lcl_event_receiver DEFINITION
*Class implementation
CLASS lcl_event_receiver IMPLEMENTATION.
  METHOD handle_toolbar.
* handle toolbar
    CLEAR it_toolbar.
    MOVE 'DETAIL' TO it_toolbar-function.
MOVE icon_detail TO it_toolbar-icon.
MOVE 2 TO it_toolbar-butn_type.
APPEND it_toolbar TO e_object->mt_toolbar.
  ENDMETHOD.                    "handle_toolbar
  METHOD handle_menu_button.
* handle own menubuttons
IF e_ucomm = 'DETAIL'.
CALL METHOD e_object->add_function
EXPORTING
fcode = 'DISPLAY'
text = 'DISPLAY'.
ENDIF.
ENDMETHOD. "handle_menu_button
  METHOD handle_user_command.
*On click
CASE e_ucomm.
WHEN 'DISPLAY'.
MESSAGE 'Menu Clicked' TYPE 'I'.
    ENDCASE.
ENDMETHOD. "handle_user_command
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
*&-----------------------------------------------------------------*
*& Module PBO OUTPUT
*&-----------------------------------------------------------------*
* text
*------------------------------------------------------------------*
MODULE pbo OUTPUT.
  IF custom_container IS INITIAL.
* select data from table dd02l
PERFORM fetch_dd02l.
* create a custom container control for our ALV Control
CREATE OBJECT custom_container
EXPORTING
container_name = 'CCONT'.
* create an instance of alv control
CREATE OBJECT c_alv
EXPORTING i_parent = custom_container.
* Set a titlebar for the grid control
    it_layout-grid_title = 'TABLE DETAILS'.
*ALV display
CALL METHOD c_alv->set_table_for_first_display
EXPORTING
i_structure_name = 'dd02l'
is_layout = it_layout
CHANGING
it_outtab = it_dd02l.
*Handlers for the events
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_user_command
event_receiver->handle_menu_button
event_receiver->handle_toolbar FOR ALL INSTANCES.
*Calling the interactive toolbar method of ALV
CALL METHOD c_alv->set_toolbar_interactive.
ENDIF.
ENDMODULE.                             " PBO  OUTPUT
*&-----------------------------------------------------------------*
*& Module PAI INPUT
*&-----------------------------------------------------------------*
* text
*-----------------------------------------------------------------*
MODULE pai INPUT.
ENDMODULE.                             " PAI  INPUT
*&----------------------------------------------------------------*
*& form fetch_dd02l
*&----------------------------------------------------------------*
* text
*-----------------------------------------------------------------*
*Subroutine to fetch data
FORM fetch_dd02l.
  SELECT * FROM dd02l INTO CORRESPONDING FIELDS OF TABLE it_dd02l 
  WHERE  tabname IN s_table.
ENDFORM.                               " SELECT_TABLE_dd02l
*&-----------------------------------------------------------------*
*& Form ALVDISPLAY
*&-----------------------------------------------------------------*
* text
*------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*------------------------------------------------------------------*
FORM alvdisplay .
* ALV output
SET SCREEN 600.
ENDFORM.                    " ALVDISPLAY

Selection screen

On F8,

On clicking the DISPLAY