Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

page no problem

Hi experts,

Iam trying to display report with Page with total page numbers(1 of 10). If page is filled completely and it continues to next page then iam getting problem like page 8 of 7. Can any one tell me how can i count all the pages before displaying the report.

Please check the bold one.

REPORT  Z_ISSUE_SLIP_WH
        MESSAGE-ID  ZM
        LINE-SIZE 76
        LINE-COUNT 65(14)
        NO STANDARD PAGE HEADING.


TABLES: MKPF,
        MSEG,
        MARA,
        AFIH,
        AFPO,
        AUFK,
        ILOA,
        KNVV,
        AFKO,
        IHPA,
        AUFM,
        ZCSPICKLISTGROUP.



DATA: BEGIN OF T_HDR OCCURS 0,
         AUFNR LIKE ZCSPICKLISTGROUP-AUFNR,
      END OF T_HDR.


DATA: BEGIN OF T_AUFM OCCURS 0,
       MBLNR LIKE MKPF-MBLNR,
       ZEILE LIKE MSEG-ZEILE,
*       MATNR LIKE MSEG-MATNR,
       MENGE LIKE MSEG-MENGE,
       AUFNR LIKE MSEG-AUFNR,
       BUDAT LIKE AUFM-BUDAT,
       MEINS LIKE AUFM-MEINS,
      END OF T_AUFM.


DATA: BEGIN OF T_DET OCCURS 0,
        REVNR LIKE AFIH-REVNR,
        AUFNR LIKE AUFK-AUFNR,
        TPLNR LIKE ILOA-TPLNR,
        VKBUR LIKE KNVV-VKBUR,
        BUDAT LIKE MKPF-BUDAT,
        ERNAM LIKE AUFK-ERNAM,
        MENGE TYPE I,
        MATNR LIKE MARA-MATNR,
        MEINS LIKE MARA-MEINS,
        MBLNR LIKE MKPF-MBLNR,
        G_QTY  TYPE I,
      END OF T_DET.


DATA: BEGIN OF T_TEMP OCCURS 0,
       REVNR LIKE AFIH-REVNR,
       AUFNR LIKE MSEG-AUFNR,
       TPLNR LIKE ILOA-TPLNR,
       VKBUR LIKE KNVV-VKBUR,
       ERNAM LIKE AUFK-ERNAM,
       BUDAT LIKE MKPF-BUDAT,
       G_QTY TYPE I,
       MEINS LIKE MARA-MEINS,
     END OF T_TEMP.


DATA: I_DET LIKE T_DET OCCURS 0 WITH HEADER LINE.


DATA: G_ORDR(3).
DATA: G_CNT TYPE I.
DATA: G_REVNR LIKE AFIH-REVNR.
DATA: GLOBAL(3).
DATA: LCOUNT TYPE I VALUE 65.
DATA: G_GRPNO(14).


SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.
PARAMETERS: P_GRPNO LIKE ZCSPICKLISTGROUP-GRPNO.

SELECTION-SCREEN END OF BLOCK A1.


START-OF-SELECTION.

  SELECT AUFNR FROM ZCSPICKLISTGROUP INTO TABLE
  T_HDR WHERE GRPNO = P_GRPNO.

  SORT T_HDR BY AUFNR.

  IF NOT T_HDR[] IS INITIAL.



   SELECT MBLNR ZEILE MENGE AUFNR BUDAT MEINS
         INTO CORRESPONDING FIELDS OF TABLE T_AUFM
           FROM AUFM
           FOR ALL ENTRIES IN T_HDR
             WHERE AUFNR = T_HDR-AUFNR AND
                   BWART = '981'.


    IF T_AUFM[] IS INITIAL.
      MESSAGE S000(ZM) WITH 'No data found !'.
      EXIT.
    ENDIF.
  ELSE.
    MESSAGE S000(ZM) WITH 'No data found for this selection !'.
    EXIT.
  ENDIF.


  LOOP AT T_AUFM.
    MOVE-CORRESPONDING T_AUFM TO T_DET.
    COLLECT T_DET.
    CLEAR T_DET.
  ENDLOOP.



  LOOP AT T_DET.

    SELECT SINGLE * FROM AFIH WHERE AUFNR = T_DET-AUFNR.
    IF SY-SUBRC = 0.
      T_DET-REVNR = AFIH-REVNR.
      MODIFY T_DET.
    ENDIF.

    SELECT SINGLE * FROM ILOA WHERE ILOAN = AFIH-ILOAN.
    IF SY-SUBRC = 0.
      T_DET-TPLNR = ILOA-TPLNR.
      MODIFY T_DET.
    ENDIF.

    SELECT SINGLE * FROM AUFK WHERE AUFNR = T_DET-AUFNR.
    IF SY-SUBRC = 0.
      T_DET-ERNAM = AUFK-ERNAM.
      MODIFY T_DET.
    ENDIF.

    SELECT SINGLE * FROM IHPA WHERE OBJNR = AUFK-OBJNR.
    SELECT SINGLE * FROM KNVV WHERE KUNNR = IHPA-PARNR.

    IF SY-SUBRC = 0.
      T_DET-VKBUR = KNVV-VKBUR.
      MODIFY T_DET.
    ENDIF.

    T_DET-G_QTY =  T_DET-MENGE.
    MODIFY T_DET.

    I_DET-REVNR = T_DET-REVNR.
    APPEND I_DET.
    CLEAR I_DET.

  ENDLOOP.


  SORT I_DET.
  DELETE ADJACENT DUPLICATES FROM I_DET.

<b>  LOOP AT I_DET.
    GLOBAL = GLOBAL + 1.  " todisplay total pages
  ENDLOOP.</b>              


  LOOP AT T_DET.
    MOVE-CORRESPONDING T_DET TO T_TEMP.
    APPEND T_TEMP.
    CLEAR T_TEMP.
  ENDLOOP.

  SORT T_TEMP.
  DELETE ADJACENT DUPLICATES FROM T_TEMP.

  REFRESH T_DET.

  LOOP AT T_TEMP.
    MOVE-CORRESPONDING T_TEMP TO T_DET.
    APPEND T_DET.
    CLEAR T_DET.
  ENDLOOP.



  LOOP AT T_DET.

    AT NEW REVNR.

      RESERVE LCOUNT LINES.
      NEW-PAGE.
      WRITE :/1(10) 'Srvc.Order',
              14(20) 'Site/Block/Lift',
              32(4) 'Dept',
              39(12) 'Superv',
              50(10) 'GI Date',
              63(5) 'Qty',
              70(3) 'Uom'.
      WRITE :/1(80) SY-ULINE.
      CLEAR: G_ORDR.
    ENDAT.

    WRITE:/1(10) T_DET-AUFNR,
           14(20) T_DET-TPLNR,
           32(4) T_DET-VKBUR,
           39(12) T_DET-ERNAM,
           50(10) T_DET-BUDAT,
           61(5) T_DET-G_QTY,
           70(3) T_DET-MEINS.
    G_ORDR = G_ORDR + 1.

    AT END OF REVNR.
      SUM.
      WRITE :/1(7) SY-ULINE,
                      61(5) SY-ULINE.
      WRITE:/1(10) G_ORDR,
             61(5) T_DET-G_QTY.
      WRITE :/1(7) SY-ULINE,
              61(5) SY-ULINE.
    ENDAT.
  ENDLOOP.

  G_CNT = SY-LINCT - SY-LINNO - 14.
  IF G_CNT > 0.
    SKIP G_CNT.
  ENDIF.



TOP-OF-PAGE.
  DATA: G_PAGNO(3). " LIKE SY-PAGNO.
<b>  ADD 1 TO G_PAGNO.    "to dispay currect page no </b>

  SHIFT G_PAGNO LEFT DELETING LEADING SPACE.
  SHIFT P_GRPNO LEFT DELETING LEADING '0'.
  CONCATENATE 'Group no' P_GRPNO INTO G_GRPNO SEPARATED BY SPACE.


  WRITE:/1(66) TEXT-010 CENTERED, 56 SY-UZEIT, 67 SY-DATUM DD/MM/YY,
  /1(66) <b>TEXT-015 CENTERED, 57 'Page no', G_PAGNO,'of',GLOBAL
RIGHT-JUSTIFIED,</b>  /65 G_GRPNO.

  SKIP 2.

  WRITE:/ 'Revision', 20 ':',SPACE, T_DET-REVNR.
  SKIP 2.


END-OF-PAGE.

  WRITE :/1(80) SY-ULINE.
  WRITE:/40 SY-VLINE.
  WRITE:/2 'Approved By : ',
        40 SY-VLINE,
        42 'Issued By : '.
  WRITE:/16(20) SY-ULINE,
         40 SY-VLINE,
         54(22) SY-ULINE.
  ULINE.
  WRITE:/ TEXT-016.
  ULINE.
  WRITE:/ 'Recvd By :          ',
          'EF No. :            ',
          'Initial :           ',
          'Date :'.

Reward guaranteed.

thanks

kaki

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question