Dear All,
I want to get field "mbwbest" and "wbwbest" from table S032 but with period and the problem is no period on S032,
because i want to extract data from S032 per period. I know the period is on table S031 (SPMON), but i have some problems on joining that 2 tables
for example : if i extract data from period Jan 2014 the total of "mbwbest" and "wbwbest" is different with tcode MC.9 or MCBE
Please help me how to extract data from table S032 with period by join it to table S031
REPORT YPPTEST.
TABLES : mara, s031, s032.
TYPES: BEGIN OF ty_s032,
matnr LIKE mara-matnr,
lgort LIKE s032-lgort,
mbwbest LIKE s032-mbwbest,
wbwbest LIKE s032-wbwbest,
spmon LIKE s031-spmon,
werks LIKE s031-werks,
END OF ty_s032.
DATA : xs032 TYPE STANDARD TABLE OF ty_s032 WITH HEADER LINE.
data : ts032 LIKE STANDARD TABLE OF s032 WITH HEADER LINE.
SELECT a~matnr a~lgort a~spmon INTO CORRESPONDING FIELDS OF TABLE xs032
FROM s031 AS a
INNER JOIN mara AS b ON a~matnr = b~matnr
WHERE b~mtart = 'ZFG2'
AND a~matnr IN s_matnr
AND a~werks = s_plant
and a~spmon = s_period.
IF xs032[] is not initial.
select matnr lgort werks mbwbest wbwbest INTO CORRESPONDING FIELDS OF TABLE ts032
from s032
WHERE matnr IN s_matnr
AND werks = s_plant
AND bklas = '1020'.
ENDIF.
LOOP AT xs032.
LOOP AT TS032 WHERE matnr = xs032-matnr and lgort = xs032-lgort
xs032-mbwbest = xs032-mbwbest + ts032-mbwbest.
xs032-wbwbest = xs032-wbwbest + ts032-wbwbest.
ENDLOOP.
MODIFY xs032.
ENDLOOP.
ENDIF.
Please Help Me,
Thanks
Ferry