Printing page numbers in an ALV report with multiple grids

Hi,
I have developed a report using OO ALV GRID. The output is having multiple grids navigated using a menu button appended to the standard tool bar
(Ref report: BCALV_GRID_07). On navigation, we are able to display specific titles when each grid is displayed.
When we print those individual pages (the grids), we are able to print the page numbers and the title for the first grid but when we display the next grid and print, we are unable to initialise the page number
and print specific title. The page numbers continues from the last printing.
I am looking at identifying the grid when the print event - PRINT_TOP_OF_PAGE is triggered so that a grid specific title can be printed and also page number initialised.
Any suggestions is highly appreciated.
Thanks.
Mani.

You cannot have one event for all the grids as you cannot identify for which grid the event has fired. You need to activate the event for each of the grid and handle the code independently.
regards,
Ravi
Note - Please mark the helpful answers

Similar Messages

  • ALV REPORT WITH MULTIPLE BLOCKS

    To print two blocks in a single ALV report, I have taken the sample and modified to my requirement.  I am having the following problems in this code.
          1.  Columnwise total not appearing.
          2.  Amount and numbers in all the columns are 
              left justified instead of right justified.
    The code written is given below.  Kindly check the same and suggest for corrections.
    --- SAMPLE 1--
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
           EXPORTING
                i_callback_program      = sy-cprog
                i_callback_user_command = 'USER_COMMAND'.
      PERFORM list_append TABLES IT_CTV
                           USING '1'
                                 'IT_CTV'.
      PERFORM list_append TABLES IT_APP
                           USING '2'
                                 'IT_APP'.
      PERFORM f_list_display.
          FORM USER_COMMAND                                             *
    FORM user_command USING i_ucomm     LIKE sy-ucomm
                            is_selfield TYPE slis_selfield.     "#EC CALLED
    ENDFORM.                               " USER_COMMAND
          Form  list_append
    FORM list_append TABLES ut_table
                     USING  u_no      TYPE char1
                            u_tabname TYPE slis_tabname.
      DEFINE m_fieldcat.
        ls_fieldcat-fieldname = &1.
        ls_fieldcat-ref_tabname = &2.
        append ls_fieldcat to lt_fieldcat.
      END-OF-DEFINITION.
      DEFINE m_sort.
        ls_sort-fieldname = &1.
        ls_sort-up        = 'X'.
        append ls_sort to lt_sort.
      END-OF-DEFINITION.
      DATA :
        ls_fieldcat TYPE slis_fieldcat_alv,
        lt_fieldcat TYPE slis_t_fieldcat_alv, " Field catalog
        ls_sort     TYPE slis_sortinfo_alv,
        lt_sort     TYPE slis_t_sortinfo_alv. " Sort table
      DATA:
        lt_events TYPE slis_t_event,
        ls_event  TYPE slis_alv_event,
        ls_layout TYPE slis_layout_alv.
      ls_layout-group_change_edit = 'X'.
      ls_layout-colwidth_optimize = 'X'.
      ls_layout-zebra             = 'X'.
      ls_layout-cell_merge        = 'X'.
      ls_layout-detail_popup      = 'X'.
      ls_layout-get_selinfos      = 'X'.
      ls_layout-max_linesize      = '300'.
      CASE u_no.
        WHEN '1'.
          ls_fieldcat-SELTEXT_L = ' REGION'.
          ls_fieldcat-DO_SUM = 'X'.
          m_fieldcat  'BZIRK' 'IT_CTV'.
          ls_fieldcat-SELTEXT_L = ' CTV STOCK'.
          m_fieldcat  'CTVST' 'IT_CTV'.
          ls_fieldcat-SELTEXT_L = ' CTV VALUE'.
          m_fieldcat  'CTVVL' 'IT_CTV'.
          m_sort  'BZIRK'.
          ls_fieldcat-DO_SUM = 'X'.
        WHEN '2'.
          ls_fieldcat-SELTEXT_L = ' REGION'.
          m_fieldcat  'BZIRK' 'IT_APP'.
          ls_fieldcat-SELTEXT_L = ' RFG STK'.
          m_fieldcat  'RFGST' 'IT_APP'.
          ls_fieldcat-SELTEXT_L = ' RFG VAL'.
          m_fieldcat  'RFGVL' 'IT_APP'.
          ls_fieldcat-SELTEXT_L = ' WM STK'.
          m_fieldcat  'WMCST' 'IT_APP'.
          ls_fieldcat-SELTEXT_L = ' WM VAL'.
          m_fieldcat  'WMCVL' 'IT_APP'.
          ls_fieldcat-SELTEXT_L = ' MCCS STK'.
          m_fieldcat  'MOVST' 'IT_APP'.
          ls_fieldcat-SELTEXT_L = ' MCCS VAL'.
          m_fieldcat  'MOVVL' 'IT_APP'.
          ls_fieldcat-SELTEXT_L = ' APP STK'.
          m_fieldcat  'APPST' 'IT_APP'.
         ls_fieldcat-SELTEXT_L = ' APP VAL'.
         m_fieldcat  'APPVL' 'IT_APP'.
          m_sort  'BZIRK'.
      ENDCASE.
    ls_fieldcat-COL_POS = 1.
    ls_fieldcat-FIELDNAME = 'BZIRK'.
    ls_fieldcat-DO_SUM = 'X'.
    ls_fieldcat-FIX_COLUMN = 'X'.
    APPEND ls_fieldcat TO lT_fieldcat.
      IF u_no CA '13'.
        MOVE        'TOP_OF_PAGE'        TO ls_event-name.
        CONCATENATE 'TOP_OF_PAGE' u_no INTO ls_event-form.
        APPEND ls_event TO lt_events.
      ELSE.
        MOVE        'TOP_OF_LIST'        TO ls_event-name.
        CONCATENATE 'TOP_OF_LIST' u_no INTO ls_event-form.
        APPEND ls_event TO lt_events.
      ENDIF.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
           EXPORTING
                it_fieldcat                = lt_fieldcat
                is_layout                  = ls_layout
                i_tabname                  = u_tabname
                it_events                  = lt_events
                it_sort                    = lt_sort
           TABLES
                t_outtab                   = ut_table
           EXCEPTIONS
                program_error              = 1
                maximum_of_appends_reached = 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.
    ENDFORM.                               " LIST_APPEND
          Form  f_list_display
    FORM f_list_display.
      DATA ls_print TYPE slis_print_alv.
      ls_print-no_print_selinfos  = 'X'.   " Display no selection infos
      ls_print-no_print_listinfos = 'X'.   " Display no listinfos
      ls_print-reserve_lines      = 2.     " Lines reserved for end of page
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
           EXPORTING
                i_interface_check = ' '
                is_print          = ls_print
           EXCEPTIONS
                program_error     = 1
                OTHERS            = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                               " F_LIST_DISPLAY
    Thanks in advance.
    A S VINCENT

    Hai Vincent
    Check the following Code
    *& Report  ZALV_BLOCK                                               *
    REPORT  ZALV_BLOCK NO STANDARD PAGE HEADING
                                    MESSAGE-ID ZZ.
    *..Type Definitions for ALV Report
    TYPE-POOLS SLIS.
    Table Declarations.                                        *
    TABLES: MARA,        "Material Master
            MARC,        "Plant Data for Material
            MARD,        "Storage Location Data for Material
            VBAP,        "Sales Document: Item Data
            VBUP.        "Sales Document: Item Status
    Internal table to store sales orders.......
    DATA: BEGIN OF IT_VBAP OCCURS 0,
            VBELN LIKE VBAP-VBELN,    "Sales Document
            POSNR LIKE VBAP-POSNR,    "Sales Document Item
            KWMENG LIKE VBAP-KWMENG,  "Cumulative order quantity in sales
                                       "                        Units
          END OF IT_VBAP.
    internal table to store final data
    DATA: BEGIN OF IT_FINAL OCCURS 0,
            WERKS LIKE MARD-WERKS,    "Plant
            MATNR LIKE MARD-MATNR,    "Material Number
            LGORT LIKE MARD-LGORT,    "Storage Location
            LABST LIKE MARD-LABST,    "Valuated stock with unrestricted use
            INSME LIKE MARD-INSME,    "Stock in quality inspection
            RETME LIKE MARD-RETME,    "Blocked Stock Returns
            UMLME LIKE MARD-UMLME,    "Stock in transfer
            MAKTX LIKE MAKT-MAKTX,    "Material description
            VBELN LIKE VBAP-VBELN,    "Sales Document
            POSNR LIKE VBAP-POSNR,    "Sales Document Item
            KWMENG LIKE VBAP-KWMENG,  "Cumulative order quantity in sales
                                       "                        Units
          END OF IT_FINAL.
    ALV Type declaration                                                 *
    *..Field Catalog for Basic List.
    DATA : IT_FIELDCAT  TYPE SLIS_T_FIELDCAT_ALV,
           WA_FIELDCAT  TYPE SLIS_FIELDCAT_ALV.
    *..Events For Basic List.
    DATA : IT_EVENTS TYPE SLIS_T_EVENT,
           WA_EVENTS TYPE SLIS_ALV_EVENT.
    *..Layout For Basic List
    DATA : WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
    *..Sort Table For Basic List
    DATA: IT_SORT TYPE SLIS_SORTINFO_ALV OCCURS 0 WITH HEADER LINE.
               DATA DECLARATIONS                                         *
    DATA: V_FLAG,
          VINDEX TYPE SY-TABIX,
          TOTAL TYPE VBAP-KWMENG.     "Open order quantity
    *..To Store Program Name
    DATA: V_REPID  TYPE SYREPID.
    *..To know whether basic list contains any data
    Selection Screen.                                                    *
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-H01.
    SELECT-OPTIONS: S_MATNR FOR MARA-MATNR,
                    S_WERKS FOR MARC-WERKS,
                    S_LGORT FOR MARD-LGORT.
    SELECTION-SCREEN END OF BLOCK B1.
    Event:Initialization                                                 *
    INITIALIZATION.
      V_REPID = SY-REPID.
    AT Selection Screen.                                                 *
    AT SELECTION-SCREEN.
      PERFORM VALIDATIONS.
    Event: Start-of-Selection                                            *
    START-OF-SELECTION.
         To get data from vbap into internal table IT_VBAP
      PERFORM FETCH_OPEN_DATA.
          To get data into final internal table IT_FINAL
      IF V_FLAG = 'X'.
        PERFORM FETCH_FINAL_DATA.
      ENDIF.
      IF V_FLAG = ''.
        MESSAGE I010 WITH 'NO DATA TO BE DISPLAYED'.
        EXIT.
      ELSE.
      --Setting the FIELD CATALOG for ALV
        PERFORM FILL_FIELDCAT_HEADER.
    *-----Setting the LAYOUT for ALV
        PERFORM GET_LAYOUT.
    *-----Getting the ALV Events
        PERFORM GET_EVENT.
    *---- To Sort the list
        PERFORM DO_SORT.
      ENDIF.
    Event: End-of-Selection                                            *
    END-OF-SELECTION.
    *--Generating the ALV LIST DISPLAY
      PERFORM DISPLAY_LIST.
                             FORM DEFINITIONS                            *
    *&      Form  VALIDATIONS
          To validate data in selection screen
    -->  p1        text
    <--  p2        text
    FORM VALIDATIONS.
      PERFORM VALIDATE_MATNR.
      PERFORM VALIDATE_WERKS.
      PERFORM VALIDATE_LGORT.
      IF NOT ( ( MARA-MATNR IS INITIAL ) AND
              ( MARC-WERKS IS INITIAL ) AND
              ( MARD-LGORT IS INITIAL ) ).
        SELECT SINGLE MATNR
                      WERKS
                      LGORT
                      FROM MARD
          INTO (MARD-MATNR, MARD-WERKS, MARD-LGORT)
          WHERE MATNR = MARA-MATNR
            AND WERKS = MARC-WERKS
            AND LGORT = MARD-LGORT.
      ENDIF.
    ENDFORM.                    " VALIDATIONS
    *&      Form  VALIDATE_MATNR
          To validate MATNR
    -->  p1        text
    <--  p2        text
    FORM VALIDATE_MATNR.
      IF NOT S_MATNR[] IS INITIAL.
        SELECT MATNR
               UP TO 1 ROWS
               INTO (MARD-MATNR)
               FROM MARA
               WHERE MATNR IN S_MATNR.
        ENDSELECT.
      ENDIF.
      IF SY-SUBRC NE 0.
        MESSAGE E000 WITH TEXT-001.
      ENDIF.
    ENDFORM.                    " VALIDATE_MATNR
    *&      Form  VALIDATE_WERKS
          To validate plant
    -->  p1        text
    <--  p2        text
    FORM VALIDATE_WERKS.
      IF NOT S_WERKS[] IS INITIAL.
        SELECT WERKS
               UP TO 1 ROWS
               INTO (MARD-WERKS)
               FROM MARC
               WHERE WERKS IN S_WERKS.
        ENDSELECT.
      ENDIF.
      IF SY-SUBRC NE 0.
        MESSAGE E000 WITH TEXT-002.
      ENDIF.
    ENDFORM.                    " VALIDATE_WERKS
    *&      Form  VALIDATE_LGORT
          To validate storage
    -->  p1        text
    <--  p2        text
    FORM VALIDATE_LGORT.
      IF NOT S_LGORT[] IS INITIAL.
        SELECT LGORT
               UP TO 1 ROWS
               INTO (MARD-LGORT)
               FROM MARD
               WHERE LGORT IN S_LGORT.
        ENDSELECT.
      ENDIF.
      IF SY-SUBRC NE 0.
        MESSAGE E000 WITH TEXT-003.
      ENDIF.
    ENDFORM.                    " VALIDATE_LGORT
    *&      Form  FETCH_OPEN_DATA
          To get data into internal table IT_VBAP
    -->  p1        text
    <--  p2        text
    FORM FETCH_OPEN_DATA.
      IF NOT ( ( MARA-MATNR IS INITIAL ) AND
               ( MARC-WERKS IS INITIAL ) AND
               ( MARD-LGORT IS INITIAL ) ).
        SELECT VBELN
               POSNR
               KWMENG
               INTO CORRESPONDING FIELDS OF TABLE IT_VBAP
               FROM VBAP
               WHERE MATNR IN S_MATNR
                 AND WERKS IN S_WERKS
                 AND LGORT IN S_LGORT.
      ENDIF.
      LOOP AT IT_VBAP.
        SELECT * FROM VBUP
                 INTO VBUP
                 WHERE VBELN = IT_VBAP-VBELN
                   AND POSNR = IT_VBAP-POSNR
                   AND LFSTA NE 'C'.
        ENDSELECT.
      ENDLOOP.
      IF SY-SUBRC NE 0.
        REFRESH IT_VBAP.
        MESSAGE E000 WITH TEXT-004.
        EXIT.
      ELSE.
        V_FLAG = 'X'.
      ENDIF.
          To get sum of all quantities as open order quantity
      LOOP AT IT_VBAP.
        TOTAL = TOTAL + IT_VBAP-KWMENG.
      ENDLOOP.
    ENDFORM.                    " FETCH_OPEN_DATA
    *&      Form  FETCH_FINAL_DATA
         To get data into final internal table IT_FINAL
    -->  p1        text
    <--  p2        text
    FORM FETCH_FINAL_DATA.
      SELECT A~MATNR
             A~WERKS
             A~LGORT
             MAKTX
             LABST
             INSME
             RETME
             UMLME
             VBELN
             POSNR
             KWMENG
             INTO CORRESPONDING FIELDS OF TABLE IT_FINAL
             FROM MARD AS A
             INNER JOIN MAKT AS B
             ON AMATNR = BMATNR
              AND SPRAS = 'E'
             INNER JOIN VBAP AS C
             ON AMATNR = CMATNR
             FOR ALL ENTRIES IN IT_VBAP
             WHERE VBELN = IT_VBAP-VBELN
               AND POSNR = IT_VBAP-POSNR
               AND KWMENG = IT_VBAP-KWMENG
               AND A~MATNR IN S_MATNR
               AND A~WERKS IN S_WERKS
               AND A~LGORT IN S_LGORT.
      IF SY-SUBRC NE 0.
        V_FLAG = SPACE.
        MESSAGE E001 WITH 'No data found IN the selection criteria'.
        EXIT.
      ELSE.
        V_FLAG = 'X'.
      ENDIF.
    ENDFORM.                    " FETCH_FINAL_DATA
    *&      Form  FILL_FIELDCAT_HEADER
          text
    -->  p1        text
    <--  p2        text
    FORM FILL_FIELDCAT_HEADER .
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
         I_PROGRAM_NAME               = V_REPID
         I_INTERNAL_TABNAME           = 'IT_FINAL'
      I_STRUCTURE_NAME             =
      I_CLIENT_NEVER_DISPLAY       = 'X'
         I_INCLNAME                   = V_REPID
      I_BYPASSING_BUFFER           =
      I_BUFFER_ACTIVE              =
        CHANGING
          CT_FIELDCAT                  = IT_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.
      LOOP AT IT_FIELDCAT INTO WA_FIELDCAT.
        CASE WA_FIELDCAT-FIELDNAME.
          WHEN 'KWMENG'.
           WA_FIELDCAT-COL_POS = '11'.
           WA_FIELDCAT-OUTPUTLEN = '22'.
           WA_FIELDCAT-SELTEXT_L = 'Net Value'.
            WA_FIELDCAT-DO_SUM    = 'X'.
        ENDCASE.
        MODIFY IT_FIELDCAT FROM WA_FIELDCAT INDEX SY-TABIX.
      ENDLOOP.
    ENDFORM.                    " FILL_FIELDCAT_HEADER
    *&      Form  GET_LAYOUT
          text
    -->  p1        text
    <--  p2        text
    FORM GET_LAYOUT .
      WA_LAYOUT-TOTALS_TEXT = 'TOTAL'.
    ENDFORM.                    " GET_LAYOUT
    *&      Form  GET_EVENT
          text
    -->  p1        text
    <--  p2        text
    FORM GET_EVENT .
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          I_LIST_TYPE     = 0
        IMPORTING
          ET_EVENTS       = IT_EVENTS
        EXCEPTIONS
          LIST_TYPE_WRONG = 1
          OTHERS          = 2.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      LOOP AT IT_EVENTS INTO WA_EVENTS.
        CASE WA_EVENTS-NAME.
          WHEN 'TOP_OF_PAGE'.
            WA_EVENTS-FORM = 'FILL_LIST_HEADER'.
          WHEN 'USER_COMMAND'.
            WA_EVENTS-FORM = 'PROCESS_BASIC_LIST'.
        ENDCASE.
        MODIFY IT_EVENTS FROM WA_EVENTS INDEX SY-TABIX.
      ENDLOOP.
    ENDFORM.                    " GET_EVENT
          FORM FILL_LIST_HEADER                                         *
    FORM FILL_LIST_HEADER.
      WRITE:2'Report :' ,   SY-REPID,
           : 85 '         Intelligroup Asia Pvt Ltd' CENTERED,
           : 159 'Date  :' ,SY-DATUM,
           :/2'User   :',   SY-UNAME,
           : 82 '               Hyderabad         ' CENTERED ,
           : 159 'Pg.No :' ,SY-PAGNO,
           :/86 '           Stock Report    ' CENTERED.
      SKIP 2.
    ENDFORM.                    "FILL_LIST_HEADER
    *&      Form  DISPLAY_LIST
          text
    -->  p1        text
    <--  p2        text
    FORM DISPLAY_LIST .
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK              = ' '
      I_BYPASSING_BUFFER             =
      I_BUFFER_ACTIVE                = ' '
         I_CALLBACK_PROGRAM             = V_REPID
      I_CALLBACK_PF_STATUS_SET       = ' '
      I_CALLBACK_USER_COMMAND        = ' '
      I_STRUCTURE_NAME               =
         IS_LAYOUT                      = WA_LAYOUT
         IT_FIELDCAT                    = IT_FIELDCAT
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
         IT_SORT                        = IT_SORT[]
      IT_FILTER                      =
      IS_SEL_HIDE                    =
      I_DEFAULT                      = 'X'
      I_SAVE                         = ' '
      IS_VARIANT                     =
         IT_EVENTS                      = IT_EVENTS
      IT_EVENT_EXIT                  =
      IS_PRINT                       =
      IS_REPREP_ID                   =
      I_SCREEN_START_COLUMN          = 0
      I_SCREEN_START_LINE            = 0
      I_SCREEN_END_COLUMN            = 0
      I_SCREEN_END_LINE              = 0
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER        =
      ES_EXIT_CAUSED_BY_USER         =
        TABLES
          T_OUTTAB                       = IT_FINAL
       EXCEPTIONS
         PROGRAM_ERROR                  = 1
         OTHERS                         = 2
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " DISPLAY_LIST
    *&      Form  do_sort
          text
    -->  p1        text
    <--  p2        text
    FORM DO_SORT .
    *-- Populating the sort table
      IT_SORT-FIELDNAME = 'MATNR'.
      IT_SORT-TABNAME = 'IT_FINAL'.
      IT_SORT-UP = 'X'.
    it_sort-subtot = 'X'.
      APPEND IT_SORT.
    ENDFORM.                    " do_sort
    Thanks & Regards
    Sreenivasulu P

  • ALV REPORT WITH MULTIPLE BLOCKS - COLUM TOTAL

    Hi friends,
    In the following code, I am not getting the column total.
    --- SAMPLE 1--
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
           EXPORTING
                i_callback_program      = sy-cprog
                i_callback_user_command = 'USER_COMMAND'.
      PERFORM list_append TABLES IT_CTV
                           USING '1'
                                 'IT_CTV'.
      PERFORM list_append TABLES IT_APP
                           USING '2'
                                 'IT_APP'.
      PERFORM f_list_display.
          FORM USER_COMMAND                                             *
    FORM user_command USING i_ucomm     LIKE sy-ucomm
                            is_selfield TYPE slis_selfield.     "#EC CALLED
    ENDFORM.                               " USER_COMMAND
          Form  list_append
    FORM list_append TABLES ut_table
                     USING  u_no      TYPE char1
                            u_tabname TYPE slis_tabname.
      DEFINE m_fieldcat.
        ls_fieldcat-fieldname = &1.
        ls_fieldcat-ref_tabname = &2.
        append ls_fieldcat to lt_fieldcat.
      END-OF-DEFINITION.
    DATA: GT_ZSUM TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE.
      DEFINE m_sort.
        ls_sort-fieldname = &1.
        ls_sort-up        = 'X'.
        append ls_sort to lt_sort.
      END-OF-DEFINITION.
      DATA :
        ls_fieldcat TYPE slis_fieldcat_alv,
        lt_fieldcat TYPE slis_t_fieldcat_alv, " Field catalog
        ls_sort     TYPE slis_sortinfo_alv,
        lt_sort     TYPE slis_t_sortinfo_alv. " Sort table
      DATA:
        lt_events TYPE slis_t_event,
        ls_event  TYPE slis_alv_event,
        ls_layout TYPE slis_layout_alv.
      ls_layout-group_change_edit = 'X'.
      ls_layout-colwidth_optimize = 'X'.
      ls_layout-zebra             = 'X'.
      ls_layout-cell_merge        = 'X'.
      ls_layout-detail_popup      = 'X'.
      ls_layout-get_selinfos      = 'X'.
      ls_layout-max_linesize      = '300'.
      CASE u_no.
        WHEN '1'.
          ls_fieldcat-SELTEXT_L = ' REGION'.
          m_fieldcat  'BZIRK' 'IT_CTV'.
          ls_fieldcat-just = 'R'.
          ls_fieldcat-SELTEXT_L = ' CTV STOCK'.
          m_fieldcat  'CTVST' 'IT_CTV'.
          ls_fieldcat-just = 'R'.
          ls_fieldcat-SELTEXT_L = ' CTV VALUE'.
          m_fieldcat  'CTVVL' 'IT_CTV'.
          ls_fieldcat-DO_SUM = 'X'.
          m_sort  'BZIRK'.
        WHEN '2'.
          ls_fieldcat-SELTEXT_L = ' REGION'.
          m_fieldcat  'BZIRK' 'IT_APP'.
          ls_fieldcat-just = 'R'.
          ls_fieldcat-SELTEXT_L = ' RFG STK'.
          m_fieldcat  'RFGST' 'IT_APP'.
          ls_fieldcat-just = 'R'.
          ls_fieldcat-SELTEXT_L = ' RFG VAL'.
          m_fieldcat  'RFGVL' 'IT_APP'.
          ls_fieldcat-just = 'R'.
          ls_fieldcat-SELTEXT_L = ' WM STK'.
          m_fieldcat  'WMCST' 'IT_APP'.
          ls_fieldcat-just = 'R'.
          ls_fieldcat-SELTEXT_L = ' WM VAL'.
          m_fieldcat  'WMCVL' 'IT_APP'.
          ls_fieldcat-just = 'R'.
          ls_fieldcat-SELTEXT_L = ' MCCS STK'.
          m_fieldcat  'MOVST' 'IT_APP'.
          ls_fieldcat-just = 'R'.
          ls_fieldcat-SELTEXT_L = ' MCCS VAL'.
          m_fieldcat  'MOVVL' 'IT_APP'.
          ls_fieldcat-just = 'R'.
          ls_fieldcat-SELTEXT_L = ' APP STK'.
          m_fieldcat  'APPST' 'IT_APP'.
          ls_fieldcat-just = 'R'.
          ls_fieldcat-SELTEXT_L = ' APP VAL'.
          m_fieldcat  'APPVL' 'IT_APP'.
          ls_fieldcat-just = 'R'.
          ls_fieldcat-DO_SUM = 'X'.
         m_sort  'BZIRK'.
      ENDCASE.
    ls_fieldcat-COL_POS = 1.
    ls_fieldcat-FIELDNAME = 'BZIRK'.
    ls_fieldcat-DO_SUM = 'X'.
    ls_fieldcat-FIX_COLUMN = 'X'.
    APPEND ls_fieldcat TO lT_fieldcat.
      IF u_no CA '13'.
        MOVE        'TOP_OF_PAGE'        TO ls_event-name.
        CONCATENATE 'TOP_OF_PAGE' u_no INTO ls_event-form.
        APPEND ls_event TO lt_events.
      ELSE.
        MOVE        'TOP_OF_LIST'        TO ls_event-name.
        CONCATENATE 'TOP_OF_LIST' u_no INTO ls_event-form.
        APPEND ls_event TO lt_events.
      ENDIF.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
           EXPORTING
                it_fieldcat                = lt_fieldcat
                is_layout                  = ls_layout
                i_tabname                  = u_tabname
                it_events                  = lt_events
                it_sort                    = lt_sort
           TABLES
                t_outtab                   = ut_table
           EXCEPTIONS
                program_error              = 1
                maximum_of_appends_reached = 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.
    ENDFORM.                               " LIST_APPEND
          Form  f_list_display
    FORM f_list_display.
      DATA ls_print TYPE slis_print_alv.
      ls_print-no_print_selinfos  = 'X'.   " Display no selection infos
      ls_print-no_print_listinfos = 'X'.   " Display no listinfos
      ls_print-reserve_lines      = 2.     " Lines reserved for end of page
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
           EXPORTING
                i_interface_check = ' '
                is_print          = ls_print
           EXCEPTIONS
                program_error     = 1
                OTHERS            = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                               " F_LIST_DISPLAY
          FORM top_of_page1                                             *
    FORM top_of_page1.                                          "#EC CALLED
      WRITE 'SALES REPORT'.
      PERFORM TOP_LIST1.
    ENDFORM.
          FORM top_of_list2                                             *
    FORM top_of_list2.                                          "#EC CALLED
      WRITE 'STOCK REPORT'.
      PERFORM top_of_page.
    ENDFORM.
    *-----END OF SAMPLE 1 -
    Could any help me.
    Thanx in advance.
    Regards,
    A S VINCENT

    Hai Vincent
    Check & Run the follow ABAP Code
    *& Report  ZALV_Block                                               *
    REPORT  ZALV_block NO STANDARD PAGE HEADING
                                    MESSAGE-ID ZZ.
    *..Type Definitions for ALV Report
    TYPE-POOLS SLIS.
    Table Declarations.                                        *
    TABLES: MARA,        "Material Master
            MARC,        "Plant Data for Material
            MARD,        "Storage Location Data for Material
            VBAP,        "Sales Document: Item Data
            VBUP.        "Sales Document: Item Status
    Internal table to store sales orders.......
    DATA: BEGIN OF IT_VBAP OCCURS 0,
            VBELN LIKE VBAP-VBELN,    "Sales Document
            POSNR LIKE VBAP-POSNR,    "Sales Document Item
            KWMENG LIKE VBAP-KWMENG,  "Cumulative order quantity in sales
                                       "                        Units
          END OF IT_VBAP.
    internal table to store final data
    DATA: BEGIN OF IT_FINAL OCCURS 0,
            WERKS LIKE MARD-WERKS,    "Plant
            MATNR LIKE MARD-MATNR,    "Material Number
            LGORT LIKE MARD-LGORT,    "Storage Location
            LABST LIKE MARD-LABST,    "Valuated stock with unrestricted use
            INSME LIKE MARD-INSME,    "Stock in quality inspection
            RETME LIKE MARD-RETME,    "Blocked Stock Returns
            UMLME LIKE MARD-UMLME,    "Stock in transfer
            MAKTX LIKE MAKT-MAKTX,    "Material description
            VBELN LIKE VBAP-VBELN,    "Sales Document
            POSNR LIKE VBAP-POSNR,    "Sales Document Item
            KWMENG LIKE VBAP-KWMENG,  "Cumulative order quantity in sales
                                       "                        Units
          END OF IT_FINAL.
    ALV Type declaration                                                 *
    *..Field Catalog for Basic List.
    DATA : IT_FIELDCAT  TYPE SLIS_T_FIELDCAT_ALV,
           WA_FIELDCAT  TYPE SLIS_FIELDCAT_ALV.
    *..Events For Basic List.
    DATA : IT_EVENTS TYPE SLIS_T_EVENT,
           WA_EVENTS TYPE SLIS_ALV_EVENT.
    *..Layout For Basic List
    DATA : WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
    *..Sort Table For Basic List
    DATA: IT_SORT TYPE SLIS_SORTINFO_ALV OCCURS 0 WITH HEADER LINE.
               DATA DECLARATIONS                                         *
    DATA: V_FLAG,
          VINDEX TYPE SY-TABIX,
          TOTAL TYPE VBAP-KWMENG.     "Open order quantity
    *..To Store Program Name
    DATA: V_REPID  TYPE SYREPID.
    *..To know whether basic list contains any data
    Selection Screen.                                                    *
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-H01.
    SELECT-OPTIONS: S_MATNR FOR MARA-MATNR,
                    S_WERKS FOR MARC-WERKS,
                    S_LGORT FOR MARD-LGORT.
    SELECTION-SCREEN END OF BLOCK B1.
    Event:Initialization                                                 *
    INITIALIZATION.
      V_REPID = SY-REPID.
    AT Selection Screen.                                                 *
    AT SELECTION-SCREEN.
      PERFORM VALIDATIONS.
    Event: Start-of-Selection                                            *
    START-OF-SELECTION.
         To get data from vbap into internal table IT_VBAP
      PERFORM FETCH_OPEN_DATA.
          To get data into final internal table IT_FINAL
      IF V_FLAG = 'X'.
        PERFORM FETCH_FINAL_DATA.
      ENDIF.
      IF V_FLAG = ''.
        MESSAGE I010 WITH 'NO DATA TO BE DISPLAYED'.
        EXIT.
      ELSE.
      --Setting the FIELD CATALOG for ALV
        PERFORM FILL_FIELDCAT_HEADER.
    *-----Setting the LAYOUT for ALV
        PERFORM GET_LAYOUT.
    *-----Getting the ALV Events
        PERFORM GET_EVENT.
    *---- To Sort the list
        PERFORM DO_SORT.
      ENDIF.
    Event: End-of-Selection                                            *
    END-OF-SELECTION.
    *--Generating the ALV LIST DISPLAY
      PERFORM DISPLAY_LIST.
                             FORM DEFINITIONS                            *
    *&      Form  VALIDATIONS
          To validate data in selection screen
    -->  p1        text
    <--  p2        text
    FORM VALIDATIONS.
      PERFORM VALIDATE_MATNR.
      PERFORM VALIDATE_WERKS.
      PERFORM VALIDATE_LGORT.
      IF NOT ( ( MARA-MATNR IS INITIAL ) AND
              ( MARC-WERKS IS INITIAL ) AND
              ( MARD-LGORT IS INITIAL ) ).
        SELECT SINGLE MATNR
                      WERKS
                      LGORT
                      FROM MARD
          INTO (MARD-MATNR, MARD-WERKS, MARD-LGORT)
          WHERE MATNR = MARA-MATNR
            AND WERKS = MARC-WERKS
            AND LGORT = MARD-LGORT.
      ENDIF.
    ENDFORM.                    " VALIDATIONS
    *&      Form  VALIDATE_MATNR
          To validate MATNR
    -->  p1        text
    <--  p2        text
    FORM VALIDATE_MATNR.
      IF NOT S_MATNR[] IS INITIAL.
        SELECT MATNR
               UP TO 1 ROWS
               INTO (MARD-MATNR)
               FROM MARA
               WHERE MATNR IN S_MATNR.
        ENDSELECT.
      ENDIF.
      IF SY-SUBRC NE 0.
        MESSAGE E000 WITH TEXT-001.
      ENDIF.
    ENDFORM.                    " VALIDATE_MATNR
    *&      Form  VALIDATE_WERKS
          To validate plant
    -->  p1        text
    <--  p2        text
    FORM VALIDATE_WERKS.
      IF NOT S_WERKS[] IS INITIAL.
        SELECT WERKS
               UP TO 1 ROWS
               INTO (MARD-WERKS)
               FROM MARC
               WHERE WERKS IN S_WERKS.
        ENDSELECT.
      ENDIF.
      IF SY-SUBRC NE 0.
        MESSAGE E000 WITH TEXT-002.
      ENDIF.
    ENDFORM.                    " VALIDATE_WERKS
    *&      Form  VALIDATE_LGORT
          To validate storage
    -->  p1        text
    <--  p2        text
    FORM VALIDATE_LGORT.
      IF NOT S_LGORT[] IS INITIAL.
        SELECT LGORT
               UP TO 1 ROWS
               INTO (MARD-LGORT)
               FROM MARD
               WHERE LGORT IN S_LGORT.
        ENDSELECT.
      ENDIF.
      IF SY-SUBRC NE 0.
        MESSAGE E000 WITH TEXT-003.
      ENDIF.
    ENDFORM.                    " VALIDATE_LGORT
    *&      Form  FETCH_OPEN_DATA
          To get data into internal table IT_VBAP
    -->  p1        text
    <--  p2        text
    FORM FETCH_OPEN_DATA.
      IF NOT ( ( MARA-MATNR IS INITIAL ) AND
               ( MARC-WERKS IS INITIAL ) AND
               ( MARD-LGORT IS INITIAL ) ).
        SELECT VBELN
               POSNR
               KWMENG
               INTO CORRESPONDING FIELDS OF TABLE IT_VBAP
               FROM VBAP
               WHERE MATNR IN S_MATNR
                 AND WERKS IN S_WERKS
                 AND LGORT IN S_LGORT.
      ENDIF.
      LOOP AT IT_VBAP.
        SELECT * FROM VBUP
                 INTO VBUP
                 WHERE VBELN = IT_VBAP-VBELN
                   AND POSNR = IT_VBAP-POSNR
                   AND LFSTA NE 'C'.
        ENDSELECT.
      ENDLOOP.
      IF SY-SUBRC NE 0.
        REFRESH IT_VBAP.
        MESSAGE E000 WITH TEXT-004.
        EXIT.
      ELSE.
        V_FLAG = 'X'.
      ENDIF.
          To get sum of all quantities as open order quantity
      LOOP AT IT_VBAP.
        TOTAL = TOTAL + IT_VBAP-KWMENG.
      ENDLOOP.
    ENDFORM.                    " FETCH_OPEN_DATA
    *&      Form  FETCH_FINAL_DATA
         To get data into final internal table IT_FINAL
    -->  p1        text
    <--  p2        text
    FORM FETCH_FINAL_DATA.
      SELECT A~MATNR
             A~WERKS
             A~LGORT
             MAKTX
             LABST
             INSME
             RETME
             UMLME
             VBELN
             POSNR
             KWMENG
             INTO CORRESPONDING FIELDS OF TABLE IT_FINAL
             FROM MARD AS A
             INNER JOIN MAKT AS B
             ON AMATNR = BMATNR
              AND SPRAS = 'E'
             INNER JOIN VBAP AS C
             ON AMATNR = CMATNR
             FOR ALL ENTRIES IN IT_VBAP
             WHERE VBELN = IT_VBAP-VBELN
               AND POSNR = IT_VBAP-POSNR
               AND KWMENG = IT_VBAP-KWMENG
               AND A~MATNR IN S_MATNR
               AND A~WERKS IN S_WERKS
               AND A~LGORT IN S_LGORT.
      IF SY-SUBRC NE 0.
        V_FLAG = SPACE.
        MESSAGE E001 WITH 'No data found IN the selection criteria'.
        EXIT.
      ELSE.
        V_FLAG = 'X'.
      ENDIF.
    ENDFORM.                    " FETCH_FINAL_DATA
    *&      Form  FILL_FIELDCAT_HEADER
          text
    -->  p1        text
    <--  p2        text
    FORM FILL_FIELDCAT_HEADER .
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
         I_PROGRAM_NAME               = V_REPID
         I_INTERNAL_TABNAME           = 'IT_FINAL'
      I_STRUCTURE_NAME             =
      I_CLIENT_NEVER_DISPLAY       = 'X'
         I_INCLNAME                   = V_REPID
      I_BYPASSING_BUFFER           =
      I_BUFFER_ACTIVE              =
        CHANGING
          CT_FIELDCAT                  = IT_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.
      LOOP AT IT_FIELDCAT INTO WA_FIELDCAT.
        CASE WA_FIELDCAT-FIELDNAME.
          WHEN 'KWMENG'.
           WA_FIELDCAT-COL_POS = '11'.
           WA_FIELDCAT-OUTPUTLEN = '22'.
           WA_FIELDCAT-SELTEXT_L = 'Net Value'.
            WA_FIELDCAT-DO_SUM    = 'X'.
        ENDCASE.
        MODIFY IT_FIELDCAT FROM WA_FIELDCAT INDEX SY-TABIX.
      ENDLOOP.
    ENDFORM.                    " FILL_FIELDCAT_HEADER
    *&      Form  GET_LAYOUT
          text
    -->  p1        text
    <--  p2        text
    FORM GET_LAYOUT .
      WA_LAYOUT-TOTALS_TEXT = 'TOTAL'.
    ENDFORM.                    " GET_LAYOUT
    *&      Form  GET_EVENT
          text
    -->  p1        text
    <--  p2        text
    FORM GET_EVENT .
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          I_LIST_TYPE     = 0
        IMPORTING
          ET_EVENTS       = IT_EVENTS
        EXCEPTIONS
          LIST_TYPE_WRONG = 1
          OTHERS          = 2.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      LOOP AT IT_EVENTS INTO WA_EVENTS.
        CASE WA_EVENTS-NAME.
          WHEN 'TOP_OF_PAGE'.
            WA_EVENTS-FORM = 'FILL_LIST_HEADER'.
          WHEN 'USER_COMMAND'.
            WA_EVENTS-FORM = 'PROCESS_BASIC_LIST'.
        ENDCASE.
        MODIFY IT_EVENTS FROM WA_EVENTS INDEX SY-TABIX.
      ENDLOOP.
    ENDFORM.                    " GET_EVENT
          FORM FILL_LIST_HEADER                                         *
    FORM FILL_LIST_HEADER.
      WRITE:2'Report :' ,   SY-REPID,
           : 85 '         Intelligroup Asia Pvt Ltd' CENTERED,
           : 159 'Date  :' ,SY-DATUM,
           :/2'User   :',   SY-UNAME,
           : 82 '               Hyderabad         ' CENTERED ,
           : 159 'Pg.No :' ,SY-PAGNO,
           :/86 '           Stock Report    ' CENTERED.
      SKIP 2.
    ENDFORM.                    "FILL_LIST_HEADER
    *&      Form  DISPLAY_LIST
          text
    -->  p1        text
    <--  p2        text
    FORM DISPLAY_LIST .
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK              = ' '
      I_BYPASSING_BUFFER             =
      I_BUFFER_ACTIVE                = ' '
         I_CALLBACK_PROGRAM             = V_REPID
      I_CALLBACK_PF_STATUS_SET       = ' '
      I_CALLBACK_USER_COMMAND        = ' '
      I_STRUCTURE_NAME               =
         IS_LAYOUT                      = WA_LAYOUT
         IT_FIELDCAT                    = IT_FIELDCAT
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
         IT_SORT                        = IT_SORT[]
      IT_FILTER                      =
      IS_SEL_HIDE                    =
      I_DEFAULT                      = 'X'
      I_SAVE                         = ' '
      IS_VARIANT                     =
         IT_EVENTS                      = IT_EVENTS
      IT_EVENT_EXIT                  =
      IS_PRINT                       =
      IS_REPREP_ID                   =
      I_SCREEN_START_COLUMN          = 0
      I_SCREEN_START_LINE            = 0
      I_SCREEN_END_COLUMN            = 0
      I_SCREEN_END_LINE              = 0
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER        =
      ES_EXIT_CAUSED_BY_USER         =
        TABLES
          T_OUTTAB                       = IT_FINAL
       EXCEPTIONS
         PROGRAM_ERROR                  = 1
         OTHERS                         = 2
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " DISPLAY_LIST
    *&      Form  do_sort
          text
    -->  p1        text
    <--  p2        text
    FORM DO_SORT .
    *-- Populating the sort table
      IT_SORT-FIELDNAME = 'MATNR'.
      IT_SORT-TABNAME = 'IT_FINAL'.
      IT_SORT-UP = 'X'.
    it_sort-subtot = 'X'.
      APPEND IT_SORT.
    ENDFORM.                    " do_sort
    Thanks & Regards
    Sreenivasulu P

  • Printing Page Numbers With A Sub Report

    Hi, I have a Crystal Report (XI) that includes a subreport which is identical to the main report because I am actually making the report print 2 copies of the same report with different critera in the detail section only. On the main report I have a Page Header section which I am using the special field "PAGE N of M", so on all pages of the report it is printing this page number. I  My issue is listed below:
    First page of report                    "Fred's Place"                 Page 1 of  2 (Correct)
    Second page of report              "Fred's Place"                 Page 2 of  2 (Correct)
    Third page of report                   "Fred's Place"                 Page 3 of  2 (Not Correct)
    Fourth  page of report                "Fred's Place"                 Page 4 of  2 (Not Correct)
    The first/second page are printing correctly with data being pulled from the main report, but the third/fourth pages are not printing correctly with data pulled from the sub report. My question is how to get the third/fourth pages to print as follows:
    Third page of report                   "Fred's Place"                 Page 1 of  2 (Correct)
    Fourth  page of report                "Fred's Place"                 Page 2 of  2 (Correct)
    Thanks for your help
    Jim Dyer

    Jim,
    Try passing the total page count from the main report to the subreport via a shared variable. Then set up a counter formula in the fake PH of the subreport and convert the counter and the shared variable so that it reads page 1(counter) of 2(shared variable)
    You should also be able to suppress the extra pagenofms in the main report when pagenumber > totalpagecount

  • Print or download ALV report with sort options

    Dear friends,
    How i can download into excel or print ALV report with sort options, like customer name column with similar values should not repeat in the print out or download file.
    Regards,
    Praveen Lobo

    Hi Praveen,
    Use this code, its working:-
    *FOR SORTING DATA
    DATA : it_sort TYPE slis_t_sortinfo_alv,
           wa_sort TYPE slis_sortinfo_alv.
    *          SORT W.R.T. CUSTOMER NAME
      wa_sort-spos = 1.
      wa_sort-fieldname = 'NAME1'. "field customer name
      wa_sort-tabname = 'IT_KNA1'. "internal table with records
      wa_sort-up = 'X'.
      APPEND wa_sort TO it_sort.
      CLEAR wa_sort.
    "this will sort the ALV o/p for customer with same name
    "now the name will not be repeated
    "records with same name will be grouped
    *          DISPLAY RECORDS IN ALV GRID
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        i_callback_program                = sy-repid "report id
        it_fieldcat                       = it_field "field catalog
        it_sort                           = it_sort "sort info
      TABLES
        t_outtab                          = it_kna1 "internal table
      EXCEPTIONS
        program_error                     = 1
        OTHERS                            = 2.
      IF sy-subrc <> 0.
      ENDIF.
    Hope this solves your problem.
    Thanks & Regards,
    Tarun Gambhir
    Edited by: Tarun Gambhir on Dec 31, 2008 1:13 PM

  • How to print page numbers in adobe form

    Hi,
    Can anybody tell me how to print page numbers in adobe form.
    Thanks in advance
    Chaitanya

    Hi,
    Yes the field page n of m is used normally for printing page numbers. But it won't display the current page of total pages by itself. You have to set the run time property to n (current page ) and m (Total number of pages). Carefully select the # (current page ) and ## (Total number of pages). Hope this works for you.
    My requirement is to have the user control on current page. For Example:
    Example for a Invoice with 5 PO items (stands on 2 pages) :
    1st  page is the letter : no page number
    2nd page is the 1st page of the 1st copy of the invoice : we should read u201C1 / 2u201D
    3rd page is the 2nd page of the 1st copy of the invoice : we should read u201C2 / 2u201D
    4th page is the 1st page of the 2nd copy of the invoice : we should read u201C1 / 2u201D
    5th page is the 2nd page of the 2nd copy of the invoice : we should read u201C2 / 2u201D
    Presently i cam getting the current page number for page 4th as 3 / 2 and for 5th page 4 / 2. I could able to control the total number of pages from print program. But when i am printing the second copy (4th and 5th pages), I couldn't able to control the current page number. I need to initialize the Current page count (4th page ) as 1.
    I have used the follwing java scripting:
    this.rawValue = wv_pages - xfa.layout.page(this)
    where wv_pages is total no of pages calculated from print program.
    Please help me in this regard with some formcal or java scripting conditions.
    Thank You,
    Regards,
    Naresh.

  • Create a Procedural ALV Report with editable fields and save the changes

    Hi,
    I am new to ABAP. I have created a Procedural ALV Report with 3 fields. I want to make 2 fields editable. When executed, if the fields are modified, I want to save the changes. All this I want to do without using OO concepts. Please help . Also, I checked out the forum and also the examples
    BCALV_TEST_GRID_EDIT_01
    BCALV_TEST_GRID_EDIT_02
    BCALV_TEST_GRID_EDIT_04_FORMS
    BCALV_TEST_GRID_EDITABLE
    BCALV_EDIT_01
    BCALV_EDIT_02
    BCALV_EDIT_03
    BCALV_EDIT_04
    BCALV_EDIT_05
    BCALV_EDIT_06
    BCALV_EDIT_07
    BCALV_EDIT_08
    BCALV_FULLSCREEN_GRID_EDIT
    But all these are using OO Concepts.
    Please help.
    Regards,
    Smruthi

    TABLES:     ekko.
    TYPE-POOLS: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
      line_color(4) TYPE c,     "Used to store row color attributes
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    *ALV data declarations
    DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
          gd_tab_group TYPE slis_t_sp_group_alv,
          gd_layout    TYPE slis_layout_alv,
          gd_repid     LIKE sy-repid.
    START-OF-SELECTION.
      PERFORM data_retrieval.
      PERFORM build_fieldcatalog.
      PERFORM build_layout.
      PERFORM display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
          Build Fieldcatalog for ALV Report
    FORM build_fieldcatalog.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
    fieldcatalog-do_sum      = 'X'.
    fieldcatalog-no_zero     = 'X'.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-seltext_m   = 'PO Item'.
      fieldcatalog-col_pos     = 1.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-seltext_m   = 'Status'.
      fieldcatalog-col_pos     = 2.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-seltext_m   = 'Item change date'.
      fieldcatalog-col_pos     = 3.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      fieldcatalog-col_pos     = 4.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-seltext_m   = 'PO quantity'.
    fieldcatalog-edit             = 'X'
      fieldcatalog-col_pos     = 5.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-seltext_m   = 'Order Unit'.
      fieldcatalog-col_pos     = 6.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-datatype     = 'CURR'.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-seltext_m   = 'Price Unit'.
      fieldcatalog-col_pos     = 8.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
    ENDFORM.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
          Build layout for ALV grid report
    FORM build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
      gd_layout-info_fieldname =      'LINE_COLOR'.
    ENDFORM.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
          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
                i_callback_pf_status_set = 'STATUS'
                i_callback_top_of_page   = 'TOP-OF-PAGE'
               i_callback_user_command = 'USER_COMMAND'
               i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
               it_special_groups       = gd_tabgroup
               IT_EVENTS                = GT_XEVENTS
                i_save                  = 'X'
               is_variant              = z_template
           TABLES
                t_outtab                = it_ekko
           EXCEPTIONS
                program_error           = 1
                OTHERS                  = 2.
    ENDFORM.                    " DISPLAY_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
          Retrieve data form EKPO table and populate itab it_ekko
    FORM data_retrieval.
      DATA: ld_color(1) TYPE c.
      SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
       UP TO 10 ROWS
        FROM ekpo
        INTO TABLE it_ekko.
      LOOP AT it_ekko INTO wa_ekko.
        ld_color = ld_color + 1.
        IF ld_color = 8.
          ld_color = 1.
        ENDIF.
        CONCATENATE 'C' ld_color '10' INTO wa_ekko-line_color.
        MODIFY it_ekko FROM wa_ekko.
      ENDLOOP.
    ENDFORM.                    " DATA_RETRIEVAL
          FORM top-of-page                                              *
    FORM top-of-page.
      WRITE:/ 'This is First Line of the Page'.
    ENDFORM.
          FORM status                                                   *
    FORM status USING rt_extab TYPE slis_t_extab.  .
      SET PF-STATUS 'ALV'.
    ENDFORM.
          FORM USER_COMMAND                                          *
    -->  RF_UCOMM                                                      *
    -->  RS                                                            *
    FORM user_command USING rf_ucomm LIKE sy-ucomm
                             rs TYPE slis_selfield.            
      DATA ref1 TYPE REF TO cl_gui_alv_grid.
      CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
        IMPORTING
          e_grid = ref1.
      CALL METHOD ref1->check_changed_data.
      CASE rf_ucomm.
    when 'SAVE'.
    get all the modified entries and store them in an internal table and udpate them in to the required transaction or your custom table.
    endcase.
    endform.
    ENDFORM.
    here u need to 2 performs for PF status and USER_COMMAND in the ALV parameters.
    create a custom PF status and create push buttons and assign your ok codes in your PF status.
    if the field has to be edited in the ALV then pass EDIT = 'X' for that field in the fieldcatlog preparation.
    Hope this will help you.
    Regards,
    phani.

  • How to print page no/total pges in report programing?

    how to print page no/total pges in report programing?

    Hi
    This is an example:
    In TOP-OF-PAGE you can write:
    WRITE: SY-PAGNO, '/', '-----'.
    When the program has finished to print all data, run a routine like this:
    Declare a variable
    DATA: L_PAGE_COUNT(5) TYPE C,
          V_LINE TYPE I. "The line where page number is written
    * In my example I suppose the page number is always
    * written in the first row of the page.
    V_LINE = 1.
    *  Copy this code to the end of program
    *  Page count will be printed on each page here
      WRITE sy-pagno TO l_page_count LEFT-JUSTIFIED.
      DO sy-pagno TIMES.
        READ LINE V_LINE OF PAGE sy-index.
        REPLACE '-----' WITH l_page_count INTO sy-lisel.
        MODIFY CURRENT LINE.
        ADD 1 TO sy-index.
      ENDDO.
    Max

  • Page Numbering for the aging report

    Hi,
    Does any one know how I can achieve the following:
    For the customer ageing report we need to print all customer statements at once. On our print layout we currently use the following CurrentPage()/TotalPages() formula fields to dispaly the page number. The result we get is 1/10, 2/10, 3/10....etc.
    We actually need the following, for total 10 pages statement would like to display the page number as follows:
    Customer A: 1/1
    Customer B: 1/3, 2/3, 3/3
    Customer C: 1/1
    Customer D: 1/5, 2/5, 3/5, 4/5, 5/5
    Does anyone know how to achieve the above for continuous print?
    Your assistance in this matter is highly appreciated.
    BR,
    Jimmy

    Hi,
    You are trying to print the detailed aging report. Right?
    It seems that there is no way of "splitting" the page numbers within a collection report.
    The system could not count the pages for EACH customer.The total number per pages will be per whole document, and cannot be per business partner within the same document when using the formula currentpage().
    Regards,
    Jitin

  • ALV Reporting with drill down capabillities

    I'm creating a abap custom report using the ALV.  I want to drill down to CJ03 which is projects.  I know how to do it in regular custom reporting, but I don't seem to be able to get it to work using the ALV.  Can anyone help?
    Thanks.
    Linda

    Hi Linda,
    Take a look at this sample program. The logic to handle any interaction with the user is in my "PORCESS_USER_COMMANDS" routine.
    This is defined in the "I_CALLBACK_USER_COMMAND" parameter in the ALV FM.
    Hope this helps.
    Cheers,
    Pat.
    [code]
    Modification History
    Date      | Author    | Chg Req #     | Description
    15.08.2001| Pat Yee   | $TMP          | Program Creation
    This program is an example of how the ALV Display works.
    It will display Customer Data.
    This report will also show how to display an ALV report with different
    colored lines and icons
    REPORT zpat.
    Include Programs
    INCLUDE <icon>.
    Database Tables
    TABLES: kna1.                  "Customer Master
    Types
    TYPE-POOLS: kkblo.
    Structures
    Structure to hold the Color Information
    DATA: BEGIN OF st_color,
            color(3) TYPE c,
          END OF st_color.
    Structure to hold the Icon Information
    DATA: BEGIN OF st_icon,
            icon(4) TYPE c,
          END OF st_icon.
    ALV Field Catalog Structure
    DATA: st_fieldcat   TYPE slis_fieldcat_alv.
    ALV Layout Structure
    DATA: st_layout     TYPE slis_layout_alv.
    Internal Tables
    Output Table
    DATA: BEGIN OF tbl_kna1 OCCURS 0.
            INCLUDE STRUCTURE st_icon.   "Icon Structure
            INCLUDE STRUCTURE kna1.      "Customer Master Structure
            INCLUDE STRUCTURE st_color.  "Color Structure
    DATA: END OF tbl_kna1.
    ALV Field Catalog Table
    DATA: tbl_fieldcat  TYPE slis_t_fieldcat_alv.
    Variables
    DATA: fieldname(30) TYPE c,
          g_repid       LIKE sy-repid.
    Start of Selection
    START-OF-SELECTION.
      g_repid = sy-repid.
      PERFORM get_data.
    End of Selection
    END-OF-SELECTION.
      PERFORM do_fancy_stuff.
      PERFORM get_layout.
      PERFORM get_fieldcat.
      PERFORM create_report.
    *&      Form  CREATE_REPORT
          Learn to read the subroutine name!
    FORM create_report.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
           EXPORTING
                i_interface_check       = ' '
                i_callback_program      = g_repid
                i_callback_user_command = 'PROCESS_USER_COMMANDS'
                it_fieldcat             = tbl_fieldcat
                i_default               = 'X'
                i_save                  = ' '
                is_layout               = st_layout
           TABLES
                t_outtab                = tbl_kna1
           EXCEPTIONS
                program_error           = 1
                OTHERS                  = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                               " CREATE_REPORT
    *&      Form  GET_FIELDCAT
          Build the Field Catalog
    FORM get_fieldcat.
    Here the field catalog is created. To display more fields simply
    'uncomment' the additional lines and add the field name. Also note
    that the field catalog is much more powerful than this. You can
    intensify fields, change the colour, assign reference fields, etc.
    Look at type slis_fieldcat_alv for more options.
      PERFORM write_fieldcat USING 'ICON'  'TBL_KNA1' '    ' 'X' 1 '2' 'X'
      PERFORM write_fieldcat USING 'KUNNR' 'TBL_KNA1' 'KNA1' 'X' 2 ' ' ' '
      PERFORM write_fieldcat USING 'NAME1' 'TBL_KNA1' 'KNA1' ' ' 3 '10' ' '
                                   'X'.
      PERFORM write_fieldcat USING 'STRAS' 'TBL_KNA1' 'KNA1' ' ' 4 ' ' ' '
      PERFORM write_fieldcat USING 'TELF1' 'TBL_KNA1' 'KNA1' ' ' 5 ' ' ' '
      PERFORM write_fieldcat USING 'ORT01' 'TBL_KNA1' 'KNA1' ' ' 6 ' ' ' '
      PERFORM write_fieldcat USING 'PSTLZ' 'TBL_KNA1' 'KNA1' ' ' 7 ' ' ' '
      PERFORM write_fieldcat USING 'SORTL' 'TBL_KNA1' 'KNA1' ' ' 8 ' ' ' '
      PERFORM write_fieldcat USING 'ERNAM' 'TBL_KNA1' 'KNA1' ' ' 9 ' ' ' '
      PERFORM write_fieldcat USING 'SPRAS' 'TBL_KNA1' 'KNA1' ' ' 10 ' ' ' '
    perform write_fieldcat using '     ' 'TBL_KNA1' 'KNA1' ' ' 10 ' '.
    perform write_fieldcat using '     ' 'TBL_KNA1' 'KNA1' ' ' 11 ' '.
    perform write_fieldcat using '     ' 'TBL_KNA1' 'KNA1' ' ' 12 ' '.
    ENDFORM.                               " GET_FIELDCAT
    *&      Form  WRITE_FIELDCAT
          Write the Field Catalog data to the Field Catalog Table
         -->name   Field name
         -->tab    Table name
         -->st     Structure Name
         -->key    Is this field a Key?
         -->pos    Position Number
         -->length Field Length
         -->icon   Display as Icon
         -->hot    Hotspot
    FORM write_fieldcat USING name tab st key pos length icon hot.
      st_fieldcat-fieldname   = name.
      st_fieldcat-tabname     = tab.
      st_fieldcat-ref_tabname = st.
      st_fieldcat-key         = key.
      st_fieldcat-col_pos     = pos.
      st_fieldcat-outputlen   = length.
      st_fieldcat-icon        = icon.
      st_fieldcat-hotspot     = hot.
      APPEND st_fieldcat TO tbl_fieldcat.
      CLEAR st_fieldcat.
    ENDFORM.                               " WRITE_FIELDCAT
    *&      Form  PROCESS_USER_COMMANDS
          Interactive Reporting Commands
    FORM process_user_commands USING syst-ucomm LIKE syst-ucomm
                                     selfield TYPE slis_selfield.
    This subroutine is called when there is user interaction in the output
    In this case if the user double clicks the Customer Number then the
    program will call transaction XD03 and display the Customer Master
    Data
      CASE syst-ucomm.
        WHEN '&IC1'.
    get cursor field fieldname.
          READ TABLE tbl_kna1 INDEX selfield-tabindex.
          SET PARAMETER ID 'KUN' FIELD tbl_kna1-kunnr.
          CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
      ENDCASE.
    ENDFORM.                               " PROCESS_USER_COMMANDS
    *&      Form  GET_LAYOUT
      set the layout of the ALV.
      add color to the row?
    FORM get_layout.
      st_layout-info_fieldname    = 'COLOR'.
      st_layout-colwidth_optimize = 'X'.
      st_layout-get_selinfos      = 'X'.
    ENDFORM.                    " GET_LAYOUT
    *&      Form  get_data
          Get some data to play with
    FORM get_data.
      SELECT * FROM kna1 INTO CORRESPONDING FIELDS OF TABLE tbl_kna1
             UP TO 30 ROWS.
    ENDFORM.                    " get_data
    *&      Form  do_fancy_stuff
          Do some fancy pants stuff for example changing the color of
          lines and adding icons
    FORM do_fancy_stuff.
    Here we will demonstrate changing the color of ALV Record lines as
    well as displaying Icons
      LOOP AT tbl_kna1.
    All records where NAME1 begins with 'M', will be displayed in Bluish
    Green
        IF tbl_kna1-name1(1) EQ 'M'.
          tbl_kna1-color = 'C41'.  "Bluish Green
          MODIFY tbl_kna1 TRANSPORTING color.
        ENDIF.
    All records with no TELF1 will be displayed in White and have a
    Warning Icon
        IF tbl_kna1-telf1 IS INITIAL.
          tbl_kna1-color = 'C00'.  "White
          tbl_kna1-icon  = '@AH@'. "Warning Icon
          MODIFY tbl_kna1 TRANSPORTING icon color.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " do_fancy_stuff[/code]

  • Printing page numbers in smartform

    Hello all,
    we need to print page numbers as Page 1 of 10 etc..
    But I can not use SFSY-FORMPAGES because I print multiple documents.
    I need to know how many pages will be printed in advance.
    Every time a new document comes we have to start the count again.
    Have anyone come across this and solved it. Pls help.
    Useful answers are rewarded.
    thanks.

    hi
    try this
    Page&SFSY-PAGE& of &SFSY-FORMPAGES(3ZC)&
    don't forgot to write 3zc otherwise it will show '*' ones the page no will exceed 10.
    regards
    vijay
    reward points if helpfull

  • Why won't my printer print page numbers? The page numbers show up when I preview the document by don't print on the page.

    Why won't my printer print page numbers in a document? The page numbers show in print preview, but will not print on document.

    Perhaps you have set the margins so tight to the edge of the paper that you have gotten into the non-printing area for your printer. Most printers have a dead zone.
    What are your margin settings?
    Jerry

  • How can I exchange my pc created documents on Excel, Word, and PowerPoint with my mac and my Pages, Numbers and Keynote created content with my pc?  I need to create and edit between both.

    How can I exchange my pc created documents on Excel, Word, and PowerPoint with my mac and my Pages, Numbers and Keynote created content with my pc?  I need to create and edit and exchange between both types of operating systems.

    Your Windows system will not open any Pages, Numbers or Keynote documents. No applications exist for Windows that can open those formats. You will need to export your documents in Word, Excel and PowerPoint formats, respectively, before you'll be able to view and edit the documents on your Windows system. The iWork documents can natively open Word, Excel and PP documents, though there are limitations on what can be imported (for instance, Numbers does not support all possible Excel functions). Consult the documentation for the relevant iWork application for details on importing and exporting.
    If you are asking how to get the documents from one system to the other, then there are several ways to do that, including file sharing, using an external drive (hard drive, USB flash drive), or emailing the documents to yourself. Which would be best for your situation I can't say without more details about your usage.
    Regarsd.

  • I have MacBook Pro Retina, but dint get pages, numbers and keynote for free with it, but others did. What to do?

    I have MacBook Pro Retina, but dint get pages, numbers and keynote for free with it, but others did. What to do?

    Solved the problem- I contacted apple on their support line found on this page... http://www.apple.com/uk/support/mac/ and they were really helpful and talked me through what to do on the phone, I now have all three productivity apps. Hope this helps

  • How to download iwork(pages,numbers,keynote) free of charge with your account id on the ipad air 2?

    If you get a used ipad air 2, how to download iwork(pages,numbers,keynote) free of charge with your account id on the ipad air 2?

    You don't. It's only free when you activate a NEW iOS device. The previous owner qualified for the free apps. You do not.
    You'll have to purchase them or activate a new iOS device to qualify for the free download.

Maybe you are looking for

  • File locked/Read-Only issue in OES2LINUX

    We have observed that when the novell connection is idle for some time, then it is creating a second connection upon wakeup. Whatever the opened files in the idle connection are getting read-only. How to activate the idle connection and prevent creat

  • How to pass a VO attribute value using Page Level button

    Hi Gurus, Consider the Sinple Page having a information header seaction (having name, ID (form value), and status) and one details section.this page has a page button bar having one button (say XYZbtn). Requirment : when the user clicks on the XYZbtn

  • Safari 6.0.5 share with Twitter

    Safari 6.0.5 share with Twitter does not automatically fill the message with the title of the web page you are sharing! please, bring the functionality back!!

  • Error installing dreamweaver in d disk

    When I try to install spanish dreamweaver in d disk, the system says that the cabinet file is damaged, the problem doesn´t occurs en c disk, I need change the drive but with this problem I cant do it

  • Computer name does not auto update in VMM console

    The computer name is not updating in VMM console after the following. - Create VM from scratch, install VM additions, name "VM1" - Shutdown VM - Clone "VM1" - Sysprep clone - Rename clone to "VM2" VMM does not recognize the new name even after a few