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: 

SO change

Former Member
0 Kudos

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

govind_seenivasan
Participant
0 Kudos

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

govind_seenivasan
Participant
0 Kudos

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.

0 Kudos

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

0 Kudos

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.

0 Kudos

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

0 Kudos

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....

0 Kudos

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...

0 Kudos

Hi Kiran,

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

Thanks

0 Kudos

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

0 Kudos

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...

0 Kudos

thanks a lot guys.