How to print more than 60 characters in Top-of-page

Normally in ALV grid in TOP_OF_PAGE event, we cannot display information of more than 60 characters in length. This is due to the limitation of the Function Module REUSE_ALV_COMMENTARY_WRITE. Usually we call this Function module from the subroutine that is linked with TOP_OF_PAGE event.   



   it_list_commentary       =

   i_logo                          =

   i_end_of_list_grid       =

If we need to print more than 60 characters in length in Top-Of-Page event, then we need to follow below set of steps to achieve this requirement:- 

Solution Steps

  • To overcome this limitation we have to use concept of dynamic document – Dynamic document is a HTML document that we use in our program via ABAP methods. Dynamic Document can be implemented through the class CL_DD_DOCUMENT. 
  • As dynamic documents use SAP HTML viewer control so instead of triggering the TOP_OF_PAGE event we should trigger event of HTML TOP_OF_PAGE.  

Step1:- First we will create a subroutine for top of page in HTML format and then send that name in I_CALLBACK_HTML_TOP_OF_PAGE parameter of ALV function module. The input parameter for this subroutine will be a variable of class CL_DD_DOCUMENT.   

 Below is the code snippet for the same:-


*       FORM html_top_of_page                                     *


FORM html_top_of_page USING top TYPE REF TO cl_dd_document.

  data: l_text(255) type c.

do 180 times.

  l_text+sy-index(1) = '*'.


  CALL METHOD top->add_text EXPORTING text = 'Pernr Details '

                                      sap_style = 'heading' .

  CALL METHOD top->add_gap EXPORTING width = 200.

  CALL METHOD top->add_picture EXPORTING picture_id = 'COCO_LOGO'.



  text = l_text.


* Display ALV grid



          i_callback_html_top_of_page = 'HTML_TOP_OF_PAGE'

          i_callback_program          = g_repid


          t_outtab                    = t_tab.


The output will be generated as shown in below snapshot   

SAP ABAP Resources

Limitations: As dynamic documents use SAP HTML Viewer control internally, so whatever limitations exist for SAP HTML Viewer, same limitations hold true for dynamic documents also.

Author: Vivek Kumar

SAP ABAP Technical Consultant/Vistex Technical/CRM Technical Consultant More than 5 years of total IT industry experience encompassing skill set, roles and industry verticals. Experience involved with requirement designing in ERP domain as a technical consultant. Currently Working as ABAP team member. The functional module where provided technical solutions are Order to cash ( OTC/ Sales & Distribution), Procure to Plant ( PTP/Material Management and Production Planning ), Plant to Distribution (PTD/ Production Planning). Knowledge of ABAP Programming Techniques with different modules like Vistex and different functional module. Worked on Social CRM platform as CRM technical consultant and BRF+ Consultant for 1.5 years. Worked on DDIC, Report, Enhancement,screen design, Conversion, Function Module, Interface, Transaction Variant etc. Analyses of Functional Specification, Technical Specification and Unit Test Plan preparation. Experience of 1 implementation, 2 post implementation support, 1 Upgrade project and 2 continuous Enhancement Projects.

Module(s): ABAP, Basis, CRM