Skip to Content
A N

ALV GRID and ALV List Header Headings Issue

Dear Experts,

I am facing a problem which is explained below.
I have a report with the ALV GRID OUTPUT. It contains the header text as shown in the attached screenshot.
When I want to see the print preview of it. The Header text is not shown in LIST OUTPUT as it appears on GRID OUTPUT.

Other issue is I want to display 10 rows per page and want to get print. How to achieve this.


Please advice,

Thanks,
MAN

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Oct 19, 2016 at 09:44 AM

    You already build an instance of CL_DD_DOCUMENT in your I_CALLBACK_HTML_TOP_OF_PAGE form, do something similar in a I_CALLBACK_TOP_OF_PAGE form, you could even consider the method PRINT_DOCUMENT if you feel confident or use good old WRITE statements of course.

    Regards,
    Raymond

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 19, 2016 at 08:28 AM

    Hi

    the printpreview is an ALV list, so you should manage the event top-of-list and/or top-of-page for writin

    You should try to use a condition in order to break the page after 10 row (you could try to use a hidden field for the sorting)

    Add a comment
    10|10000 characters needed characters exceeded

    • Dear Max,

      Can you please share code for this. I tried at my level but unable to achieve it.

      Below is my code :

      *&---------------------------------------------------------------------*
      *& Report Z_TEST
      *&
      *&---------------------------------------------------------------------*
      *&
      *&
      *&---------------------------------------------------------------------*

      *REPORT Z_TEST.

      REPORT ZALVTEST.
      TABLES VBAK.
      * type pools
      TYPE-POOLS SLIS.
      * types and internal tables
      *Data Declaration
      TYPES: BEGIN OF T_VBAK,
      PAGEBRK(5) TYPE n,
      VBELN TYPE VBAK-VBELN,
      ERDAT TYPE VBAK-ERDAT,
      ERNAM TYPE VBAK-ERNAM,
      AUDAT TYPE VBAK-AUDAT,
      VBTYP TYPE VBAK-VBTYP,
      NETWR TYPE VBAK-NETWR,
      VKORG TYPE VBAK-VKORG,
      VKGRP TYPE VBAK-VKGRP,
      END OF T_VBAK.
      DATA : IT_VBAK TYPE STANDARD TABLE OF T_VBAK INITIAL SIZE 0,
      w_vbak like LINE OF it_vbak.

      *ALV Data Declaration
      DATA: FLDCAT TYPE SLIS_T_FIELDCAT_ALV,
      W_FLDCAT TYPE SLIS_FIELDCAT_ALV,
      GD_LAYOUT TYPE SLIS_LAYOUT_ALV," OCCURS 0,
      W_LAYOUT TYPE SLIS_LAYOUT_ALV,
      GD_REPID TYPE SY-REPID.
      DATA: DATE1(10).

      DATA:
      T_SORT TYPE slis_sortinfo_alv occurs 1,
      FS_SORT like line of t_sort.

      *data: it_sortcat type slis_sortinfo_alv occurs 1,
      * wa_sort like line of it_sortcat.

      * selection screen design
      SELECT-OPTIONS: VBELN FOR VBAK-VBELN.
      * start of selection
      START-OF-SELECTION.

      SET PF-STATUS 'STATUS'.
      *SET TITLEBAR 'MAIN'.

      PERFORM DATA_RETRIEVAL.
      PERFORM BLD_FLDCAT.
      PERFORM BLD_LAYOUT.
      PERFORM T_SORT USING 'VBELN' 'IT_VBAK' '' '*'.
      * PERFORM T_SORT.
      PERFORM DISPLAY_ALV_REPORT.

      DATA: g_row TYPE lvc_s_row.


      *-----------------------------------------------------------------------
      * build catalog
      *-----------------------------------------------------------------------
      *Build Field Catalog for ALV Report
      FORM BLD_FLDCAT.
      W_FLDCAT-fieldname = 'PAGEBRK'.
      W_FLDCAT-no_out = 'X'.
      *W_FLDCAT-KEY = 'X'.
      *W_FLDCAT-ICON = 'X'.
      *W_FLDCAT-COL_POS = 0.
      APPEND W_FLDCAT TO FLDCAT.

      W_FLDCAT-FIELDNAME = 'VBELN'.
      W_FLDCAT-SELTEXT_M = 'Sales_Document'.
      W_FLDCAT-COL_POS = 1.
      W_FLDCAT-OUTPUTLEN = 15.
      W_FLDCAT-KEY = 'X'.
      W_FLDCAT-ICON = 'X'.
      APPEND W_FLDCAT TO FLDCAT.
      CLEAR W_FLDCAT.
      W_FLDCAT-FIELDNAME = 'ERDAT'.
      W_FLDCAT-SELTEXT_L = 'Record_Date_created'.
      W_FLDCAT-COL_POS = 2.
      W_FLDCAT-KEY = 'X'.
      APPEND W_FLDCAT TO FLDCAT.
      CLEAR W_FLDCAT.
      W_FLDCAT-FIELDNAME = 'ERNAM'.
      W_FLDCAT-SELTEXT_L = 'Cteated_Person_Name'.
      W_FLDCAT-COL_POS = 3.
      W_FLDCAT-EMPHASIZE = 'C011'.
      APPEND W_FLDCAT TO FLDCAT.
      CLEAR W_FLDCAT.
      W_FLDCAT-FIELDNAME = 'AUDAT'.
      W_FLDCAT-SELTEXT_M = 'Document_Date'.
      W_FLDCAT-COL_POS = 4.
      W_FLDCAT-EMPHASIZE = 'C110'.
      APPEND W_FLDCAT TO FLDCAT.
      CLEAR W_FLDCAT.
      W_FLDCAT-FIELDNAME = 'VBTYP'.
      W_FLDCAT-SELTEXT_L = 'SDDocument_category'.
      W_FLDCAT-COL_POS = 5.
      APPEND W_FLDCAT TO FLDCAT.
      CLEAR W_FLDCAT.
      W_FLDCAT-FIELDNAME = 'NETWR'.
      W_FLDCAT-SELTEXT_L = 'Net_Value'.
      W_FLDCAT-COL_POS = 6.
      W_FLDCAT-OUTPUTLEN = 10.
      W_FLDCAT-DO_SUM = 'X'.
      W_FLDCAT-DATATYPE = 'CURR'.
      APPEND W_FLDCAT TO FLDCAT.
      CLEAR W_FLDCAT.
      W_FLDCAT-FIELDNAME = 'VKORG'.
      W_FLDCAT-SELTEXT_L = 'Sales_Organization'.
      W_FLDCAT-COL_POS = 7.
      APPEND W_FLDCAT TO FLDCAT.
      CLEAR W_FLDCAT.
      W_FLDCAT-FIELDNAME = 'VKGRP'.
      W_FLDCAT-SELTEXT_M = 'Sales_Group'.
      W_FLDCAT-COL_POS = 8.
      W_FLDCAT-EMPHASIZE = 'C801'.
      APPEND W_FLDCAT TO FLDCAT.
      CLEAR W_FLDCAT.
      ENDFORM. "BLD_FLDCAT
      *-----------------------------------------------------------------------
      * display fatalog
      *-----------------------------------------------------------------------
      "Build Layout for ALV Grid Report
      FORM BLD_LAYOUT.
      * GD_LAYOUT-NO_INPUT = 'X'.
      * GD_LAYOUT-BOX_FIELDNAME = 'VBELN'.


      Data: gv_title(70) type c.
      GV_title+1(20) = 'First Title'.
      gd_LAYOUT-window_titlebar = 'First Title'.
      *APPEND GD_LAYOUT.

      *gd_LAYOUT-window_titlebar+40(20) = 'Second Title'.
      *gd_layout-window_titlebar = 'Second Title'. "GV_title.

      *APPEND W_layout TO GD_LAYOUT.
      ENDFORM. "BLD_LAYOUT



      FORM T_SORT USING l_FIELD l_TABLE l_UP l_group.
      DATA : L_POS TYPE I.

      ADD 1 TO L_POS.
      FS_SORT-SPOS = L_POS.
      FS_SORT-FIELDNAME = 'VBELN'.
      FS_SORT-TABNAME = 'IT_VBAK'.
      FS_SORT-UP = 'X'.
      FS_SORT-group = '*'.
      APPEND FS_SORT to T_SORT.

      data : l_tot(8) TYPE n,
      l_lin(2) TYPE n,
      l_pag(2) TYPE N.
      BREAK IDADMIN.
      SORT it_vbak by vbeln.
      DESCRIBE TABLE it_vbak LINES l_tot.
      l_lin = 15. "“ "Initial page record length.
      l_pag = 1.
      LOOP AT it_vbak INTO w_vbak.
      IF sy-tabix LE l_tot.
      IF sy-tabix LE l_lin.
      w_vbak-pagebrk = l_pag.
      MODIFY it_vbak FROM w_vbak INDEX sy-tabix
      TRANSPORTING pagebrk.
      ELSE.
      l_lin = l_lin + 15. "“Break after 15 records.
      l_pag = l_pag + 1.
      w_vbak-pagebrk = l_pag.
      MODIFY IT_VBAK FROM w_VBAK INDEX sy-tabix
      TRANSPORTING pagebrk.
      ENDIF.
      ENDIF.
      ENDLOOP.


      ENDFORM.

      *Display report using ALV grid
      FORM DISPLAY_ALV_REPORT.
      GD_REPID = SY-REPID.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
      I_CALLBACK_PROGRAM = GD_REPID
      IS_LAYOUT = GD_LAYOUT
      I_CALLBACK_HTML_TOP_OF_PAGE = 'TOP_OF_PAGE_SPLIT'
      IT_SORT = T_SORT[]
      IT_FIELDCAT = FLDCAT[]
      TABLES
      T_OUTTAB = IT_VBAK.
      ENDFORM. "DISPLAY_ALV_REPORT
      *-----------------------------------------------------------------------
      * get data
      *-----------------------------------------------------------------------
      *Retrieve data from VBAK table and populate itab IT_VBAK
      FORM DATA_RETRIEVAL.
      break idadmin.
      SELECT VBELN
      ERDAT
      ERNAM
      AUDAT
      VBTYP
      NETWR
      VKORG
      FROM VBAK
      INTO CORRESPONDING FIELDS OF TABLE IT_VBAK
      WHERE VBELN IN VBELN.
      ENDFORM. "DATA_RETRIEVAL
      *-----------------------------------------------------------------------
      * build header for alv
      *-----------------------------------------------------------------------
      FORM TOP_OF_PAGE_SPLIT USING R_TOP TYPE REF TO CL_DD_DOCUMENT.
      DATA: S_TAB TYPE SDYDO_TEXT_TABLE,
      C_AREA TYPE REF TO CL_DD_AREA,
      TEXT TYPE SDYDO_TEXT_ELEMENT.
      TYPES: BEGIN OF TAB_TEXT,
      TEXT TYPE SDYDO_TEXT_ELEMENT,
      END OF TAB_TEXT.
      DATA: I_TEXT TYPE TABLE OF TAB_TEXT.
      DATA: W_TEXT TYPE TAB_TEXT.

      DATA : V_PAGNO TYPE N.
      * break idadmin.
      V_PAGNO = sy-pagno.
      * CASE SY-UCOMM.
      * WHEN 'P+'.
      * V_PAGNO = V_PAGNO + 1.
      * ENDCASE.


      * break idadmin.
      * V_PAGNO = SY-CPAGE."SY-PAGNO.
      CALL METHOD R_TOP->INITIALIZE_DOCUMENT.
      CALL METHOD R_TOP->VERTICAL_SPLIT
      EXPORTING
      SPLIT_AREA = R_TOP
      SPLIT_WIDTH = '80%'
      IMPORTING
      RIGHT_AREA = C_AREA.
      CONCATENATE SY-DATUM+4(2)
      '-'
      SY-DATUM+6(2)
      '-'
      SY-DATUM(4)
      INTO DATE1.
      CONCATENATE 'DATE'
      DATE1
      INTO W_TEXT-TEXT
      SEPARATED BY ':'.
      APPEND W_TEXT TO I_TEXT.
      CONCATENATE 'Page No:' V_PAGNO INTO W_TEXT .
      APPEND W_TEXT TO I_TEXT.

      S_TAB[] = I_TEXT[].
      CALL METHOD C_AREA->ADD_TEXT
      EXPORTING
      TEXT_TABLE = S_TAB
      FIX_LINES = 'X'
      SAP_FONTSIZE = CL_DD_DOCUMENT=>MEDIUM
      SAP_EMPHASIS = CL_DD_DOCUMENT=>STRONG.
      CALL METHOD R_TOP->ADD_GAP
      EXPORTING
      WIDTH = 90.
      * TEXT = 'Arshad Textile Mills Limited'.
      TEXT = 'XXX Group of Companies'.
      CALL METHOD R_TOP->ADD_TEXT
      EXPORTING
      TEXT = TEXT
      SAP_EMPHASIS = 'STRONG'.
      CALL METHOD R_TOP->NEW_LINE.
      CALL METHOD R_TOP->ADD_GAP
      EXPORTING
      WIDTH = 86.
      * TEXT = 'Arshad Corporation(Pvt) Limited'.
      TEXT = 'YYY Report'.
      CALL METHOD R_TOP->ADD_TEXT
      EXPORTING
      TEXT = TEXT
      SAP_EMPHASIS = 'STRONG'.
      CALL METHOD R_TOP->NEW_LINE.
      CALL METHOD R_TOP->ADD_GAP
      EXPORTING
      WIDTH = 100.
      * TEXT = 'Human Resource'.
      TEXT = 'XXX Period'.
      CALL METHOD R_TOP->ADD_TEXT
      EXPORTING
      TEXT = TEXT
      SAP_EMPHASIS = 'STRONG'.

      ENDFORM. "TOP_OF_PAGE_SPLIT

  • author's profile photo Former Member
    Former Member
    Posted on Oct 19, 2016 at 12:23 PM

    Hi

    if you use PAGEBRK instead of VBELN you should have what you need:

      ADD 1 TO L_POS.
      FS_SORT-SPOS     = L_POS.
      FS_SORT-FIELDNAME = 'PAGEBRK'.
      FS_SORT-TABNAME   = 'IT_VBAK'.
      FS_SORT-UP        = 'X'.
      FS_SORT-GROUP     = '*'.
      APPEND FS_SORT TO T_SORT.

    Max

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.