ALV Utility Program

...Previous  

ALV using Function Module approach - REUSE_ALV_GRID_DISPLAY

1.     Call ALV Function Module for display. Here we are supposed to call I_CALLBACK_HTML_TOP_OF_PAGE for calling Top-of-page routine.  

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      
EXPORTING
        i_callback_program      = g_prog_name
        i_callback_user_command = lc_user_cmd
        it_fieldcat             = gt_fieldcat
        i_default               = lc_default
        I_CALLBACK_HTML_TOP_OF_PAGE = 
'TOP_OF_PAGE'
      
TABLES
        t_outtab                = gt_alvrpt
      
EXCEPTIONS
        program_error           = 
1
        
OTHERS                  = 2.

    
IF sy-subrc NE 0.
      
MESSAGE i000 WITH 'Error while displaying the Grid'(005).
      
LEAVE LIST-PROCESSING.
    
ENDIF.

 2.     The FORM for this ‘TOP_OF_PAGE’ as shown above has to be build as shown below. This FORM will be using a CL_DD_DOCUMENT to build the Top-of-page. Inside this FORM we have to call the Utility class object and the Top-of-page is displayed.  

FORM TOP_OF_PAGE USING p_dyndoc_id TYPE REF TO CL_DD_DOCUMENT.

* Define Object for Utility Class
DATA: obj_sel_opt TYPE REF TO zcl_alv_header_utility.

* Create Object of Utility Class by passing the 
* CL_DD_DOCUMENT object to it
CREATE OBJECT obj_sel_opt
    
EXPORTING
      p_dyndoc_obj = p_dyndoc_id.
* Read the current Report Selection screen
CALL METHOD obj_sel_opt->read_selection_screen
  
EXPORTING
    repid  = sy-repid
    .
* Add any special parameter of Selection Screen(if present) 
CALL METHOD obj_sel_opt->add_special_param
  
EXPORTING
    param_name = 
'S_DATE'
    param_type = 
'D'
    .
* Display the ALV Top of Page by passing the desired Titles
* of the Report

  
CALL METHOD obj_sel_opt->set_grid_top
    
EXPORTING
      title1 = 
'Scheduling Agreement or Contract vs Receipt Tracking'
*      title2 =
*      title3 =
*      title4 =
.
ENDFORM.

 The above code is similar to the Code for OOPs approach and has the same logic for displaying Top-of-page.  

Result:

Program: ZUTILITY_TEST_FM

   

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image