02-07-2007 8:31 AM
Hi,
I have one issue like selection should be like this.
Select the materials from the MARA which have the material types: ZXXX, ZXXY.
Select the materials from the MVER table and exclude the material which has the zero consumption in the past 36 months .
how do i nedd to do this??
Thanks in advance.
02-07-2007 8:34 AM
02-07-2007 8:43 AM
02-07-2007 9:06 AM
Hi Can you tell me solution for this.
Select the materials from the MVER table and exclude the material which has the zero consumption in the past 36 months .
02-07-2007 9:08 AM
Hi
U need to calculate the period to analyze:
YEAR_TO = SY-DATUM(4).
YEAR_FROM = SY-DATUM(4) - 3.
MONTH = SY-DATUM+4(2).
SELECT * FROM MVER INTO TABLE T_MVER
FOR ALL ENTRIES IN T_MARA WHERE MATNR = T_MARA-MATNR
AND ( GJAHR => YEAR_FROM AND
GJAHR <= YEAR_TO ).
SORT T_MVER BY MATNR GJAHR.
LOOP AT T_MVER.
IF T_MVER-GJAHR = YEAR_FROM.
* ---> U should consider only value of the fields from mothes => MONTH
ELSIF T_MVER-GJAHR = YEAR_TO.
* ---> U should consider only values of the fields from mothes <= MONTH
ELSE.
* ---> U should consider all values
ENDIF.
ENDLOOP.
Max
02-07-2007 9:27 AM
Hi Max,
I need to exclude the materials from mver which have zero consumption in past 36 months.
for this what do i need to do.
after the loop statement you menthoned is
IF T_MVER-GJAHR = YEAR_FROM.
after this what can i do.
02-07-2007 9:50 AM
02-07-2007 2:35 PM
Hi
Trying to combine the two replies . May be it will help.
SELECT * FROM MARA
into T_MARA
where mtart IN ( 'ZXXX', 'ZXXY' ).
*Selected all materials with material type ZXXX and ZYYY
YEAR_TO = SY-DATUM(4).
YEAR_FROM = SY-DATUM(4) - 3.
MONTH = SY-DATUM+4(2).
SELECT * FROM MVER INTO TABLE T_MVER
FOR ALL ENTRIES IN T_MARA WHERE MATNR = T_MARA-MATNR
AND ( GJAHR => YEAR_FROM AND
GJAHR <= YEAR_TO ).
*selected all material consumptions of type ZXXX and ZYYY in the last 3 years.
SORT T_MVER BY MATNR GJAHR.
I am not sure how will you get the month of consumption from MVER to implement max logic below.
But basically in the loop of T_MVER you need to check if all the consmption fields are ZERO
for a material over the last 3 years then put it in an internal table.
LOOP AT T_MVER.
IF T_MVER-GJAHR = YEAR_FROM.
---> U should consider only value of the fields from mothes => MONTH
ELSIF T_MVER-GJAHR = YEAR_TO.
---> U should consider only values of the fields from mothes <= MONTH
ELSE.
---> U should consider all values
ENDIF.
ENDLOOP.
*So my loop would look like
LOOP AT T_MVER INTO LS_MVER.
AT NEW MATNR.
CLEAR L_CONSUMPTION_ZERO.
END AT.
IF NOT LS_MVER-GSV01 is INTIAL AND
LS_MVER-GSV02 is INITIAL AND ..
......
LS_MVER-GSV13 in INTIAL.
L_CONSUMPTION_ZERO = 'X'.
ENDIF.
AT END OF MATNR.
IF L_CONSUMPTION_ZERO is INITIAL.
INSERT LS_MVER INTO TABLE T_ZERO_CONS.
END IF.
END AT.
ENDLOOP.