Application Development and Automation 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: 
Read only

SO change

Former Member
0 Likes
1,119

Hi All,

I have got a small problem. im creating a sales order using a bapi and doing some process with the return orders thats already created. if the order created consists of duplicate line items i have to add the quantity of the duplicate material numbers and make it look in a single line. im using BAPI_SALESORDER_CHANGE for doing that. how can i do that. any suggestions plz.

Thanks & Regards,

Kiran.

1 ACCEPTED SOLUTION
Read only

govind_seenivasan
Participant
0 Likes
1,087

Hi Kiran,

Before calling the BAPI check the Item table for the existance of the line item. If it exists, then pick that Qty and line item number and add the new Quantity now you got the line item with the new qty. Now call the BAPI with your new values.

Thanks

Govin.

10 REPLIES 10
Read only

govind_seenivasan
Participant
0 Likes
1,088

Hi Kiran,

Before calling the BAPI check the Item table for the existance of the line item. If it exists, then pick that Qty and line item number and add the new Quantity now you got the line item with the new qty. Now call the BAPI with your new values.

Thanks

Govin.

Read only

0 Likes
1,087

could me plz let me know how i can do that. any logic or syntax for example ...

Read only

0 Likes
1,087

Hi,

Select * from VBAP where vbeln eq s_vbeln and

MATNR eq s_matnr.

if sy-subrc eq 0.

Then update your item data internal table Qty with the above qty and POSNR with the above posnr.

Now you got the POSNR and New qty of the line Item.

Continue with the existing process.

Read only

0 Likes
1,087

Hi,

One more addition to sreeni answer....along with line item vbap table data and you should pass the header data also from the vbak table...

Thanks,

Sony

Read only

0 Likes
1,087

ive got 3 lines in the lines internal table. im getting 3 line where in

1st line item is matl m1 quantity 1

2nd line item is matl m2 quantity 2

3rd line item is matl m1 quantity 1

how can i do the processing then....

Read only

0 Likes
1,087

Hi Kiran,

Now you have to replace new qty with the old qty then pass that internal table to the bapi structure....

then call the bapi_*_change FM...

Read only

0 Likes
1,087

Hi Kiran,

Use the "COLLECT" statement to count the Qty and delete the duplicate records in Internal table.

Thanks

Read only

0 Likes
1,087

HI Kiran.

YOu have to use the following logic.

First sort your internal table based on the material number.

sort itab by matnr.

loop at itab.

at new matnr.

collect itab into itab_new.

endat.

endloop.

Regards,

Ravi

Read only

0 Likes
1,087

if you want to make it single record with the duplicate records...

what you have to do is loop that internal table with the distinct command and add all the qty values with the temporary parameter...

Read only

0 Likes
1,087

thanks a lot guys.