Skip to Content
0
Former Member
Nov 07, 2006 at 04:06 AM

Find total quantity from vbrk and vbrp

326 Views

Hi frinds doing a report to display sales in 3 month 6 month snd past 12 months but didnt get logic to find out

here is my code

SELECT vbrk~vbeln

vbrk~fkdat

vbrp~fkimg

vbrp~matnr

vbrp~werks

INTO CORRESPONDING FIELDS OF TABLE iquan

FROM vbrk INNER JOIN

vbrp ON vbrkvbeln = vbrpvbeln

WHERE vbrk~fkdat >= w_date " w_date =past 12month

AND vbrp~matnr IN s_matnr " = imatr-matnr

AND vbrp~werks IN s_werks. " = imatr-werks

**now how to find the total sales quantity

i tried in this way its not working "iquan is same as iquan1 with added added sales field.

LOOP AT iquan.

READ TABLE iquan1 WITH KEY matnr = iquan-matnr

werks = iquan-werks.

IF sy-subrc = 0.

IF w_date3 LE iquan-fkdat.

w_tot3 = w_tot3 + iquan-fkimg.

ELSEIF

w_date2 LE iquan-fkdat.

w_tot2 = w_tot2 + iquan-fkimg.

ELSEIF

w_date1 LE iquan-fkdat.

w_tot1 = w_tot1 + iquan-fkimg.

ENDIF.

iquan-sale12 = w_tot1.

iquan-sale6 = w_tot2.

iquan-sale3 = w_tot3.

ENDIF.

MODIFY iquan.

ENDLOOP.

*PLs pls pls pls help me with code or suggestion

0ut put shpuld be

material plant sales 3months 6months 12 months

01 0040 130 00.00 120

regards