‎2007 Jan 30 2:44 PM
Hi friends
I have two questions
1)
I have my final internal table as below
CORPID MATNR QTY ADDRID
123 10 1 101
123 20 2 101
123 10 5 101
123 10 5 102
123 20 5 102
123 30 8 102
123 20 5 102
so now i want to add the QTY when the CORPID, ADDRID AND MATNR are same so from the above table i need to have
CORPID MATNR QTY ADDRID
123 10 6 101
123 20 2 101
123 10 5 102
123 20 10 102
123 30 8 102
2)
Based on this modified internal table i need to create sales orders
Based on the CORPID and ADDRID i have to create one sales order so from the modified table i have to create two sales.
can any one help me out in this logic
‎2007 Jan 30 2:49 PM
Hi satya,
try to collect into the internal table.
regards, Dieter
‎2007 Jan 30 2:51 PM
‎2007 Jan 30 2:51 PM
1. change ur internal table order of fields to
CORPID
ADDRID
MATNR
QTY
sort itab by CORPID ADDRID MATNR QTY
delete adjacent duplicates from itab comparing CORPID ADDRID MATNR.
loop at itab.
at end of matnr.
SUM.
endat.
endloop.
2. loop at itab.
at end of ADDRID.
*create one sales order
endat.
endat.Message was edited by:
Chandrasekhar Jagarlamudi
‎2007 Jan 30 2:53 PM
u need to use collect statement...here CORPID / MATNR / ADDRID should be char fields & QTY needs to be quantity field.
loop at itab.
collect itab.
endloop.
so, itab will have....
123 10 6 101
123 20 2 101
123 10 5 102
123 20 10 102
123 30 8 102
now write a BDC to create sales order using VA01 with condition as
sort itab by CORPID ADDRID.
loop at itab.
at new ADDRID.
fill header details.
endat.
fill item details.
at end of ADDRID.
save the order.
endat.
clear header data.
endloop.
‎2007 Jan 30 2:54 PM
Hi Satya,
you can use COLLECT statement inside the LOOP to get the output.
For ex:
Loop at itab.
itab1-CORPID = itab-CORPID.
itab1-MATNR = itab-MATNR.
itab1-QTY = itab-QTY
itab1-ADDRID = itab-ADDRID.
Collect itab1.
Endloop.
regards,
Madhumitha
‎2007 Jan 30 3:02 PM
‎2007 Jan 30 3:21 PM
Hi,
If QTY is of type N, P or F, you can definitely use the Collect statement.
Otherwise rearrange the itab internal table strucutre to have QTY field as the last one...
then loop at itab and use
keep adding itab-qty to a temp variable.
at new fld1 fld2 fld3.
move-corresponding itab to itab1.
wa_qty = wa_qty+itab-qty.
on change of itab-qty.
itab1-qty = wa_qty.
append itab1.
clear: itab1,wa_qty.
endon.
Regards
Subramanian