‎2006 Jul 13 1:29 PM
hi experts,
i have to calculate the total material consumed with respect to goods issued and goods receipt. I am unable to find the logic for 20 movement types assigned to me to calculate goods consumed.
can any one help me to find a logic...
i used the tables: MSEG, MKPF.
or can anyone send me a sample code to calculate the goods consumed to my id sabteam@rediffmail.com
thanx in advance
Afsar
‎2006 Jul 13 4:19 PM
Hello,
Some of the movement types may not record consumption since they are configured like that. The table for cosumption data is MVER.
Thanks,
Venu
‎2006 Jul 13 4:25 PM
Hi Venu,
Actually i collect the material numbers from estmj table and for those i calculate the material consumption.
and those materials r not in MVER table in my server.
do u have any sample code how to use the logic for material consumption with movement types.
Thanx
Syed
‎2006 Jul 13 4:31 PM
Hi,
Have you looked FM CONSUMPTION_READ_FOR_MM?
Here are the parameters.
- Material Number MATNR
- Plant WERKS
- Period Indicator PERKZ (M= Monthly, W=Weekly, T=Daily, P = Fiscal Year)
- Fiscal year variant PERIV (if PERKZ = P)
<b>FYI
Hope thisll give you idea!!
<b>Pl... award the points.</b>
Good luck
Thanks
Saquib Khan
"Some are wise and some are otherwise"
‎2006 Jul 13 5:02 PM
hi saquib do u have any sample code for material consumption, can u send it to me?
i am confused how to use the FM..
i have around 20 movement types for all plants in client..
so plant is paprameters.. if the enduser selct the plant then it looks for material and movement types and calculate the consumed material.
if enduser didn't select any plant then it search for all plants for the selected material numbers and shud show the final consumtion.
my problem is how to calculate the consumption for morethan 20 movement types from different plants..
i need logic...
my present logic is..
LOOP AT m_mseg.
count = m_mseg-bwart MOD 2.
IF count = 0.
consume = consume - m_mseg-menge.
ELSE.
consume = consume + m_mseg-menge.
ENDIF.
ENDLOOP.
m_mseg table contains movement types for selected material number from all plants..
is that logic good?
thanx
‎2006 Jul 13 5:08 PM
You must know the list of movement which tells you which are consumption movement type and which are reversal for consumption. Well I posted one time a table name which contain all the movement type telling its consumption etc .. You can search on SDN threads and find it . I also write a small logic there...
Pl..reward the points
Thx
Saquib
‎2006 Jul 19 1:57 PM
Hi Experts,
i have a doubt on movement types, for example:
103 - GR into blocked stock
104 - GR to blocked rev.
715 - GI InvDiff: Returns
for above movement types what is total consumption?
consumption = 715 - 103 - (-104) = 715-103 + 104
is it right?
and 653 - GD Returns unrestr.
654 - GD Returns unrestr. rev.
what these movement type means? issue or receipt?
Thanx
‎2006 Jul 19 2:20 PM
103/104 and 653/654 are pairs...so in that case consumption would be 103 - 104 and 653 - 654.
Regards
Anurag
‎2006 Jul 19 2:34 PM
So, consumtion = (103 -104) + (653-654)
when we r calculating consumption can we also consider the movement type with MSEG-XAUTO = 'X' ?
541 - GI whse to subc. stck.
what it means?
when i run mb5b tcode for a particular material it was taken as 541 as for consumption.. i am confused?
‎2006 Jul 19 4:17 PM
I think its getting a bit confusing ...the best solution is when you loop through the material documents database(MSEG), read the table T156 with Movement type(MSEG-BWART) field. If the Consumption posting field in the table T156 is not empty you need to include that in your consumption total.
Consumption Posting - T156-KZVBU
Values - Space - No consumption
G - Planned withdrawal
R - Planned, (ref to reservation)
U - Unplanned withdrawal.
Please try the above..I feel it should help.
Regards
Anurag
‎2006 Jul 19 4:57 PM
Hi,
the problem is i got arund 50 movement types for all plants for my comapny.
when i give material name then it total material consumed for all plants.... if plant is also given then material consumed for respective plant.
and i am confused how to know which movement type is for goods issue, goods issue rev, goods receipt , goods recipt rev..
and i am bit new to abap...
and confusing how to code all movement types for material consumption... which is + or - ?
send a sample code if u have so i can get better idea
thanx in advance
‎2006 Jul 20 10:49 AM
Syed,
Try and use the below logic.
SELECT {required fields - MATNR,WERKS,SHKZG,BWART,MENGE}
FROM MSEG
INTO IT_CONS
WHERE MATNR in SelectOpt-Matnr and
WERKS in SelectOpt-WERKS and
KZVBR = 'V' and
BWART in SelectOpt-Bwart.
SORT IT_CONS.
LOOP AT IT_CONS.
AT NEW WERKS.
CLEAR : W_TOTCONS.
ENDAT.
write IT_CONS. {If you wish to print the list}
If it_cons-SHKZG = 'S'.
w_totcons = w_totcons + it_cons-menge.
elseif it_cons-shkzg = 'H'.
w_totcons = w_totcons - it_cons-menge.
endif.
AT END OF WERKS.
write : W_TOTCONS.
endat.
ENDLOOP.
The above code would help you to calculate the total consumption for the given material and plant.
Regards
Anurag
‎2006 Jul 26 8:46 PM
Hi syed,
check for shkzg field in mseg if it is s then + if it is - then h
finally consumption is s - h
hope this helps
‎2006 Jul 26 8:53 PM
hi srinu and anurag,
is the consumption takes place only if the storage location is assigned... i mean for some movement type the storage location is ' ' (SPACE).
shall we have to consider those movement types also?
thanx
Syed
‎2006 Jul 27 8:50 AM