Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

MARA table

Former Member
0 Kudos

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.

7 REPLIES 7

Former Member
0 Kudos
SELECT * FROM MARA
               into itab
               where mtart IN ( 'ZXXX', 'ZXXY' ).

0 Kudos

Hi,

what about second select statement.can any one tell me.

0 Kudos

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 .

0 Kudos

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

0 Kudos

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.

0 Kudos

Hi Max,

can you tell the same for above query.

0 Kudos

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.