Skip to Content

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

No output comming

Hi,

I have the following report, when I debug values are comming to NAME1,NO_ORDER1,NO_ORDER2 the fields. But when I execute nothing is comming. Please help me slove the problem.

Thanks

Veni

REPORT ZSDORDCNT LINE-SIZE 250
                       NO STANDARD PAGE HEADING MESSAGE-ID ZV.


*----------------------------------------------------------------------*
*-------------------------- TABLES ------------------------------------*
*----------------------------------------------------------------------*
TABLES: VBAK,      "Sales Document: Header Data
        VBAP,      "Sales Document: Item Data
        KNA1.      "General Data in Customer Master
*----------------------------------------------------------------------*
*----------------------- INTERN TABLES --------------------------------*
*----------------------------------------------------------------------*

DATA: BEGIN OF ITAB_VBAK OCCURS 0,
      VBELN LIKE VBAK-VBELN,          "Sales Document
      KUNNR LIKE VBAK-KUNNR,          "Customer Number
      ERDAT LIKE VBAK-ERDAT,          "Order Date
      ERNAM LIKE VBAK-ERNAM,          "Name
      AUART LIKE VBAK-AUART,          "Order Type
      END OF ITAB_VBAK.

DATA: BEGIN OF ITAB_KNA1 OCCURS 0,
      KUNNR LIKE KNA1-KUNNR,          "Customer Number
      NAME1 LIKE KNA1-NAME1,          "Name
      END OF ITAB_KNA1.

DATA: BEGIN OF ITAB_OUTPUT OCCURS 0,
      NAME1 LIKE KNA1-NAME1,          "Name
      NO_ORDER1 TYPE I,               "Number of EDI orders
      NO_ORDER2 TYPE I,               "Number of Manual orders
*      MONTH
      END OF ITAB_OUTPUT.
*----------------------------------------------------------------------*
* ---------------------- DATA DECLARATIONS ----------------------------*
*----------------------------------------------------------------------*
DATA: NO_ORDER1 TYPE I VALUE 0,               "Number of EDI orders
      NO_ORDER2 TYPE I VALUE 0.               "Number of EDI orders
*----------------------------------------------------------------------*
*------------------------- SELECTION SCREEN ---------------------------*
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
SELECT-OPTIONS: SERDAT FOR VBAK-ERDAT.
SELECTION-SCREEN END OF BLOCK B1.
*----------------------------------------------------------------------*
**********************
INITIALIZATION.
**********************

**********************
AT SELECTION-SCREEN.
**********************
  IF SERDAT IS INITIAL.
    MESSAGE E013 WITH TEXT-ER1.
  ENDIF.

**********************
START-OF-SELECTION.
**********************
  PERFORM GET_DATA.
  PERFORM OUTPUT.
**********************
TOP-OF-PAGE.
**********************
  ULINE.
  FORMAT INTENSIFIED OFF.
  FORMAT COLOR COL_HEADING.
  WRITE : / 'Report ID :' , SY-REPID, 60 '',
           120 'Page :', SY-PAGNO.
  WRITE : / 'User......:', SY-UNAME,
           120 'Date :', SY-DATUM.
  ULINE.
  PERFORM HEADINGS.
  ULINE.
********************
FORM HEADINGS.
********************
*  FORMAT COLOR 4.
*  WRITE: /45(10) 'MONTH' RIGHT-JUSTIFIED.
*  FORMAT COLOR OFF.

  FORMAT COLOR 4.
  WRITE: /01(40) 'Account Name ',
          40(10) 'Edi' RIGHT-JUSTIFIED,
          50(10) 'Manual' RIGHT-JUSTIFIED.
  FORMAT COLOR OFF.
ENDFORM.                               " HEADINGS
********************
FORM OUTPUT.
********************
  SORT ITAB_OUTPUT BY NAME1.
  LOOP AT ITAB_OUTPUT.
    AT NEW NAME1.
      WRITE: /01(40) ITAB_OUTPUT-NAME1,
              40(50) ITAB_OUTPUT-NO_ORDER1,
              50(10) ITAB_OUTPUT-NO_ORDER2.
    ENDAT.
  ENDLOOP.
  ULINE.

ENDFORM.                                "OUTPUT
*********************
FORM GET_DATA.
*********************
  SELECT VBELN KUNNR ERDAT ERNAM AUART FROM VBAK
         INTO TABLE ITAB_VBAK
         WHERE ERDAT IN SERDAT
               AND ( AUART = 'OR'
                OR  AUART = 'ZLAT'
                OR  AUART = 'ZCLO'
                OR  AUART = 'ZREN' )
         ORDER BY VBELN.
  IF SYST-DBCNT > 0.
    SELECT KUNNR NAME1 FROM KNA1
           INTO TABLE ITAB_KNA1
           FOR ALL ENTRIES IN ITAB_VBAK
           WHERE KUNNR = ITAB_VBAK-KUNNR.
  ENDIF.

*  CLEAR: ITAB_VBAK, KNA1-NAME1.
*  REFRESH ITAB_OUTPUT.

    LOOP AT ITAB_VBAK.
     IF SY-SUBRC EQ 0.
      READ TABLE ITAB_KNA1
           WITH KEY KUNNR = ITAB_VBAK-KUNNR BINARY SEARCH.

      IF VBAK-ERNAM = 'BATCHUSER'
         OR   VBAK-ERNAM = 'REDDYV'.
        NO_ORDER1 = NO_ORDER1 + 1.
      ELSE.
        NO_ORDER2 = NO_ORDER2 + 1.
      ENDIF.

      MOVE:   KNA1-NAME1      TO ITAB_OUTPUT-NAME1,
              NO_ORDER1       TO ITAB_OUTPUT-NO_ORDER1,
              NO_ORDER2       TO ITAB_OUTPUT-NO_ORDER2.
      APPEND ITAB_OUTPUT.
      CLEAR ITAB_OUTPUT.
       ENDIF.
    ENDLOOP.

ENDFORM.                                        "GET_DATA
************************************************************

Tags:
replied

The problem is because you read table itab_kna1, but assign kna1-name1 to itab_output-name1, not itab_kna1-name1. So, try:

  LOOP AT itab_vbak.
    IF sy-subrc EQ 0.
      READ TABLE itab_kna1
           WITH KEY kunnr = itab_vbak-kunnr BINARY SEARCH.

      IF vbak-ernam = 'BATCHUSER'
         OR   vbak-ernam = 'REDDYV'.
        no_order1 = no_order1 + 1.
      ELSE.
        no_order2 = no_order2 + 1.
      ENDIF.

      MOVE:   itab_kna1-name1 TO itab_output-name1,
              no_order1       TO itab_output-no_order1,
              no_order2       TO itab_output-no_order2.
      APPEND itab_output.
      CLEAR itab_output.
    ENDIF.
  ENDLOOP.

itab_output-no_order1 and itab_output-no_order2 should both be OK though.

Rob

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question