Skip to Content
0
Former Member
Dec 02, 2011 at 04:46 AM

Report is not displaying 'previous day maximum sale' correctly

32 Views

There is a issue in the report

Based on material and date and displays the previous day maximum sale

The issue is whenever i run the report in give a single Document Date on selection screen it works fine but whenever i run the report in a range it shows the previous date of the range like when i run the report with

Document date - 05.07.2007, its working fine but and showing 04.07.2007 as previous day

when run the report

Document date - 01.07.2007 to 31.07.2007, its displaying 30.07.2007 for all records and not displaying different results based on doc date,

like it should show for 31.07.2007 --- 30.07.2007 and

30.07.2007 --- 29.07.2007

29.07.2007 --- 28.07.2007

CODE :-

**************************************************************************

FORM data_retrieval.

SELECT MSEGMATNR MSEGMBLNR MSEGMENGE MSEGMEINS MSEGCHARG MSEGLGORT MSEGBWART MSEGWERKS MSEGLIFNR MSEGEBELN MSEGBPRME MSEGDMBTR MSEGEXBWR MSEGVKWRT MSEG~SHKZG

MKPFBLDAT MKPFBUDAT MKPFMBLNR MKPFBKTXT MKPFXABLN MKPFCPUDT MKPFXBLNR MKPFMJAHR

INTO CORRESPONDING FIELDS OF TABLE itab FROM MSEG

JOIN MKPF

ON MSEGMBLNR = MKPFMBLNR

where MSEG~MATNR IN S_MATNR

AND MSEG~WERKS IN S_WERKS

AND MSEG~LGORT IN S_LGORT

AND MSEG~CHARG IN S_CHARG

AND MSEG~LIFNR IN S_LIFNR

AND MSEG~KUNNR IN S_KUNNR

AND MSEG~BWART IN S_BWART

AND MSEG~SOBKZ IN S_SOBKZ

AND MKPF~BUDAT IN S_BUDAT

AND MKPF~BLDAT IN S_BLDAT .

IF ITAB[] IS NOT INITIAL.

select matnr vbeln netwr UMKZWI1_01 fkdat ummenge VKORG VGBEL from s961

into corresponding fields of table IT_S961 FOR ALL ENTRIES IN itab

where matnr = itab-matnr and fkdat < itab-bldat.

ENDIF.

SORT IT_S961 descending BY matnr fkdat ummenge .

**

LOOP AT itab INTO wa_itab.

READ TABLE IT_S961 WITH KEY MATNR = WA_ITAB-MATNR BINARY SEARCH.

IF sy-subrc = 0.

wa_itab-VBELN = IT_S961-VBELN.

wa_itab-NETWR = IT_S961-NETWR.

wa_itab-UMKZWI1_01 = IT_S961-UMKZWI1_01.

wa_itab-UMMENGE = IT_S961-UMMENGE.

wa_itab-VKORG = IT_S961-VKORG.

wa_itab-VGBEL = IT_S961-VGBEL.

wa_itab-FKDAT = IT_S961-FKDAT.

ENDIF.

MODIFY itab FROM wa_itab TRANSPORTING VBELN NETWR UMKZWI1_01 FKDAT UMMENGE VKORG VGBEL.

CLEAR : wa_itab.

ENDLOOP.