on 01-21-2015 4:25 AM
Hi Abapers ,
I have a requirement of opening stock and closing .
I have records in my internal table like this ,
material doc.no openingqty closing qty
------------------------------------------------------------------------------------
100-100 101 50 70
100-100 102 60 80
100-101 | 201 | 60 | 90 |
100-101 202 40 20
My requirement is the output should appear as follows that the closing qty should be the opening qty of next doc no .
material doc no openingqty closingqty
------------------------------------------------------------------------------------------------------
100-100 101 50 70
100-100 102 70 80
100-101 201 60 90
100-101 202 90 20
Regards ,
Rocky
<thread locked by moderator, spoonfeeding is bad for health>
Message was edited by: Manish Kumar
Hi,
Pass the contents of internal table to another internal table.
it_temp[] = itab[].
Sort it_temp by matnr doc.
Delete adjacent duplicates comparing matnr.
loop at itab into wa.
read table it_temp into wa_temp with key matnr = wa-matnr.
if sy-subrc = 0.
wa-openingstock = wa_temp-closingstock.
endif.
modify itab from wa.
endloop.
Hope it helpful.
Regards,
Venkat.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi raj,
Please find below the logic to arrange the information as per your requirement.
sort internal_table by Material mov._type.
data: mat type matnr,
closing_val type related_data_type.
Loop at Internal_table in wa.
if mat is initial.
mat = wa-matrn.
closing_val = wa-closingqty.
elseif mat eq wa-matner.
wa-openingQty = closing_val.
modify internal_table from wa index sy-tabix.
closing_val = wa-closingqty. |
elseif mat ne wa-matnr.
mat = wa-matrn.
closing_val = wa-closingqty.
endif.
endloop.
Regards.
Praveer.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Praveen ,
i have to do the calcultaions also based on debit and crdit quantity .
how can i do the calculations for the values .
material doc no openingqty shkzg qty closingqty
------------------------------------------------------------------------------------------------------
100-100 101 50 S 20 70
100-100 102 70 S 10 80
100-101 201 60 S 30 90
100-101 202 90 H 70 20
kindly give me sme code for the output with calculation based on debit and credit .
final output should look like above.
Thanks & Regards ,
Rocky
Hi Raj,
In the sme logic you can do the Calculation.
Loop at Internal_table in wa.
if mat is initial.
mat = wa-matrn.
if H.
closing_val = wa-closingqty - qty.
elseif S
closing_val = wa-closingqty + qty.
endif.
wa-closingqty = closing_val.
modify internal_table from wa index sy-tabix.
elseif mat eq wa-matner.
wa-openingQty = closing_val.
if H. closing_val = wa-closingqty - qty. elseif S closing_val = wa-closingqty + qty. endif. |
wa-closingqty = closing_val.
|
elseif mat ne wa-matnr.
mat = wa-matrn.
if H.
closing_val = wa-closingqty - qty.
elseif S
closing_val = wa-closingqty + qty.
endif.
wa-closingqty = closing_val. |
modify internal_table from wa index sy-tabix.
endif.
endloop.
Regards.
Praveer
Hi Rocky,
For every record you need to check whether previous document number for the same material is exist or not. (Check Doc.No = (Doc.No - 1)). If you find the record, change the opening stock with closing stock of record found.
Regards,
Vijay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rocky,
I am sorry, I made it so complex. Please change it.
SORT ITAB BY MATNR DOC.
LOOP AT ITAB INTO WA.
LV_DOC = WA_DOC - 1. " LV_DOC TYPE C (as doc type).
READ ITAB INTO WA1 WITH KEY MATNR = WA-MATNR DOC = LV_DOC
BINARY SEARCH.
IF SY-SUBRC = 0.
WA-OPEN = WA1-CLOSE.
ENDIF.
ENDLOOP.
Regards,
Vijay
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.