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: 

BAPI_SALESORDER_CHANGE

Former Member
0 Kudos

Hello Experts,

My requirement is to create a new line item in the existing sales order through ABAP program. I am using BAPI_SALESORDER_CHANGE for it. But it does not produce any item..?

Please let me know if anyone has created line item using this BAPI.

Thanks,

Nazneen.

8 REPLIES 8

Former Member
0 Kudos

Hi,

Use BAPI_TRANSACTION_COMMIT after the BAPI call to commit the changes.

Also set the corresponding fields in the next internal table like LINEITEMX or POITEMX to 'X'.

Regards,

Subramanian

vinod_vemuru2
Active Contributor
0 Kudos

Hi Nazneen,

What r the messages u r getting in return table? Any errors?

R u getting any message sales order xxx changed?

Next R U calling BAPI_TRANSACTION_COMMIT if every thing is fine?

Thanks,

Vinod.

0 Kudos

Hi Subramanian and Vinod,

Thanks for your quick responses.

My requirement is to create line item in Sales order by copying the data of the Main Item.

I am using BAPI_TRANSACTION_COMMIT after checking if there are no error messages in it_return.

At the moment, I am just passing the below parameters to check whether it creates line item in sales order.

w_salesdocument = evnt-docnr.

wa_order_header_inx-updateflag = 'U'.

wa_order_item_in-itm_number = '002020'.

wa_order_item_in-item_categ = 'YEMJ'.

APPEND wa_order_item_in TO it_order_item_in.

wa_order_item_inx-itm_number = '002020'.

wa_order_item_in-item_categ = 'X'.

wa_order_item_inx-updateflag = 'I'.

APPEND wa_order_item_inx TO it_order_item_inx.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = w_salesdocument

order_header_inx = wa_order_header_inx

TABLES

return = it_return

order_item_in = it_order_item_in

order_item_inx = it_order_item_inx.

READ TABLE it_return WITH KEY type = 'E'

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

ENDIF.

Apart from some warning messages, I am getting the below errors in it_return.

Error - No item category available (Table T184 YSCB TEXT )

Error - Error in ITEM_IN 002020

Error - Sales document 0300015936 was not changed

I think some parameters are missing. Is there any configuration required to be done on our system for calling this BAPI?

Please let me know.

Thanks,

Nazneen.

0 Kudos

Look at your code:

wa_order_item_in-item_categ = 'X'.

it should be:

wa_order_item_inx-item_categ = 'X'.

This is the reason of the error you get because there's no item categoery 'X' defined in your system.

Edited by: Maciej Domaga³a on Jun 20, 2008 11:05 AM

0 Kudos

Hi,

Thanks but it does not solve the problem.

It still gives me error "No item category available (Table T184 YSCB BANC YEMR)". Here YSCB indicates the sales order header type. I have been trying to check whether it executes through SE37. But I get the same error for any other order as well (the order type is different in each message).

Any customizing required for the BAPI.?

Please help me.

0 Kudos

Hi,

in the table ORDER_ITEM_INX there is one field UPDATEFLAG pass value 'I' to that field and the item data u want to add.

I thinks this will solve the purpose.

Regards,

Bhanu.

0 Kudos

No customizing special for BAPI is required here. First check if you can change an order manually in VA02 using the order type and order item category you're trying with BAPI. If you can in VA02 you should be able with BAPI too.

Besides, you may also provide schedule lines (params: SCHEDULE_LINES, SCHEDULE_LINESX) and conditions for your new item if required (CONDITIONS_IN, CONDITIONS_INX)

good luck

Former Member
0 Kudos

Nazneen,

After procees the FM "BAPI_SALESORDER_CHANGE", need to use the following code.

DATA: COMMIT_RETURN TYPE STANDARD TABLE OF

BAPIRET2 WITH HEADER LINE.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

IMPORTING

RETURN = COMMIT_RETURN.

Regards,

Suresh Kumar.