Skip to Content

Standard ALV calls status STANDARD_FULLSCREEN (program SAPLKKBL) in which next/previous/first/last page is deactivated by default. The same program consist another status APPEND which has these buttons activated. Hence we need to overwrite the PF-STATUS call from STANDARD_FULLSCREEN to APPEND.

  1. Copy the APPEND status of program SAPLKKBL to your custom program using t-code SE41. [In this case I have used the same name for status for my program]

Image1.jpg

2. Function codes for the page scrolling already exist. Activate your status.


Image2.png


Changes in the custom program


3. Create subroutine SET_PF_STATUS to set the new PF-STATUS. Note, that this is called dynamically through FM   REUSE_ALV_GRID_DISPLAY


    FORM set_pf_status USING rt_extab TYPE slis_t_extab.

      SET PF-STATUS ‘APPEND’. 
   
ENDFORM
.    
“Set_pf_status


4. Create subroutine USER_COMMAND which will contain the action upon clicking next/previous/first/last page buttons.

Note, function codes for First Page is ‘P–’, Last Page is ‘P++’, Next Page is ‘P+’ and Previous Page is ‘P-’


FORM user_command USING r_ucomm     LIKE syucomm
                        rs_selfield
TYPE slis_selfield.

REFRESH lt_data.
CASE r_ucomm.
WHEN ‘P–‘.    “First Page
  
LOOP AT gt_data INTO lw_data
     
WHERE page = 1.
     
APPEND lw_data TO lt_data.

      ENDLOOP.

   g_page = 1.
WHEN ‘P++’.    “Last Page
  
LOOP AT gt_data INTO lw_data
     
WHERE page = g_lastpage.
     
APPEND lw_data TO lt_data.
     
CLEAR lw_data.
  
ENDLOOP.
   g_page
= g_lastpage.
WHEN ‘P+’.     “Next page
  
IF g_page EQ g_lastpage.
    
EXIT.
  
ELSE.
     g_page
= g_page + 1.
  
ENDIF.
  
LOOP AT gt_data INTO lw_data
     
WHERE page = g_page.
     
APPEND lw_data TO lt_data.
     
CLEAR lw_data.
   
ENDLOOP.
WHEN ‘P-‘.     “Previous Page
IF g_page EQ 1.
  
EXIT.
ELSE.
   g_page
= g_page 1.
ENDIF.
LOOP AT gt_data INTO lw_data
  
WHERE page = g_page.
  
APPEND lw_data TO lt_data.
  
CLEAR lw_data.
ENDLOOP.
ENDCASE.

ENDFORM“User_command


5.  In  REUSE_ALV_GRID_DISPLAY, call the subroutine for new PF-STATUS and USER_COMMAND


CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
i_callback_program         
= sy-repid
is_layout                  
= lw_layout
i_callback_pf_status_set   
= ‘SET_PF_STATUS’
i_callback_user_command    
= ‘USER_COMMAND’


6.  In SET_PF_STATUS, add code to get to selection screen when clicking Back/Exit/Cancel button


FORM set_pf_status USING gt_extab TYPE slis_t_extab .
  SET PF-STATUS ‘APPEND’.
  IF syucomm EQ ‘&F03’
  OR syucomm EQ ‘&F12’
  OR syucomm EQ ‘&F15’.
    SUBMIT ztrading_boe WITH SELECTION-TABLE gt_seltab VIA SELECTIONSCREEN.
  ENDIF.
ENDFORM. “Set_pf_status


7. Populate selection screen values in GT_SELTAB in START-OF-SELECTION. This will retain the selection screen values when clicking Back/Exit/Cancel button


STARTOFSELECTION.
* Get selection screen data
PERFORM get_selections_values.

FORM get_selections_values.

CALL FUNCTION ‘RS_REFRESH_FROM_SELECTOPTIONS’
EXPORTING
  curr_report    
= syrepid
TABLES
  selection_table
= gt_seltab
EXCEPTIONS
  not_found      
= 1
  no_report      
= 2.
IF sysubrc <> 0.
 
MESSAGE ID symsgid TYPE symsgty NUMBER symsgno
 
WITH symsgv1 symsgv2 symsgv3 symsgv4.
ENDIF.
ENDFORM.                    ” GET_SELECTIONS_VALUES


To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply