05-09-2006 4:24 PM
Hi,
I wrote this report to count orders, if they were edi or manual orders based on creation date. Now the req is based on creation date only I have to count the orders month wise. For ex: if the input is 03/15/2006 to 5/05/2006, it has to display month wise order totals for march from march 15 to march 31, april total april 1 to 30, may total may 1 to may 5, based on the input.
Please give me idea, how to change this report.
Thanks
Veni.
REPORT ZSDORDCNT LINE-SIZE 250
NO STANDARD PAGE HEADING MESSAGE-ID ZV.
TABLES: VBAK, "Sales Document: Header Data
VBAP, "Sales Document: Item Data
KNA1. "General Data in Customer Master
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 ',
41(10) 'Edi' RIGHT-JUSTIFIED,
52(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,
41(10) ITAB_OUTPUT-NO_ORDER1,
52(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.
LOOP AT ITAB_VBAK.
READ TABLE ITAB_KNA1
WITH KEY KUNNR = ITAB_VBAK-KUNNR.
IF SY-SUBRC EQ 0.
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.
ENDFORM. "GET_DATA
************************************************************
05-10-2006 9:56 AM
hi,
define a int. table:
data: begin of mtab occurs 0,
period(6), "YYYYMM
cnt type sy-dbcnt,
end of mtab.
...
LOOP AT ITAB_VBAK.
move itab_vbak-erdat(6) to mtab-period.
move 1 to mtab-cnt.
collect mtab.
Andreas
05-10-2006 10:09 AM
use offset condition to collect the date and use BKK_GL_BKKC12_GET_LAST_DATE to get last date of the month
get this data into an internal table... now u have the next month by adding 1 to the month field in BKK_GL_BKKC12_GET_LAST_DATE
u must have already collected the second date in the select option, so use it collect the rest of the months accordingly
now get the months data details accordingly into seperate internal table, if u are doing it using ALV' then u can use hierarchy list displays
Message was edited by: Rahul Kavuri
Message was edited by: Rahul Kavuri