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: 

Sales order change 'BAPI_SALESORDER_CHANGE'

Former Member
0 Kudos
1,377

Hi,

I had a peculiar issue in BAPI_SALESORDER_CHANGE. I am changing the quanity of an item and I am getting succsss mesage in RETUN as "Demand Entry has been saved " .

But when I check the order in VA03, the quanity remains unchanged. Can any body sugget. My code is below.

lv_order_header_inx-updateflag = 'U'.

SELECT * FROM vbap INTO table it_vbap

WHERE vbeln = zdemmast-slno.

LOOP AT it_zdem_item INTO wa_zdem_item.

  • Order Items

lt_order_item_inx-itm_number = wa_zdem_item-posnr.

lt_order_item_inx-material = 'X'.

lt_order_item_inx-target_qty = 'X'.

READ TABLE it_vbap INTO wa_vbap WITH KEY posnr = wa_zdem_item-posnr.

IF sy-subrc = 0.

lt_order_item_inx-updateflag = 'U'.

ELSE.

lt_order_item_inx-updateflag = 'I'.

ENDIF.

APPEND lt_order_item_inx. " TO lt_order_item_inx.

lt_order_item_in-itm_number = wa_zdem_item-posnr.

lt_order_item_in-material = wa_zdem_item-matnr.

lt_order_item_in-target_qty = wa_zdem_item-cret.

APPEND lt_order_item_in . "TO lt_order_item_in.

ENDLOOP.

  • Change the order

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = zdemmast-slno

order_header_in = lv_order_header_in

order_header_inx = lv_order_header_inx

TABLES

return = lt_return

order_item_in = lt_order_item_in

order_item_inx = lt_order_item_inx.

IF sy-subrc = 0.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • WAIT =

  • IMPORTING

  • RETURN =

.

ENDIF.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
136

You have to pass the values into SCHEDULE_LINES & SCHEDULE_LINESX structures also. Passing value to REQ_QTY in these structures will update Item level target quantity.

8 REPLIES 8

Former Member
0 Kudos
137

You have to pass the values into SCHEDULE_LINES & SCHEDULE_LINESX structures also. Passing value to REQ_QTY in these structures will update Item level target quantity.

0 Kudos
136

Hi ,

I have passed both as mentioned above and included in BAPI too. Still no change. What would be the reason?

lt_schedule_linesx-itm_number = wa_zdem_item-posnr.

lt_schedule_linesx-req_qty = 'X'.

APPEND lt_schedule_linesx.

lt_schedule_lines-itm_number = wa_zdem_item-posnr.

lt_schedule_lines-req_qty = wa_zdem_item-cret.

APPEND lt_schedule_lines.

0 Kudos
136

Hi,

Set lt_schedule_linesx-updateflag = 'I'.

If already existing, lt_schedule_linesx-updateflag = 'U'.

Hope it helps.

Sujay

Edited by: Sujay Venkateswaran Krishnakumar on Oct 7, 2010 11:36 AM Added if already existing condition

0 Kudos
136

In addition to the reply by Sujay, Add following lines while populating SCHEDULE LINE data. Check the Schedule line number, given 0001 as example.

lt_schedule_linesx-sched_line = '0001'.
lt_schedule_lines-sched_line = '0001'

0 Kudos
136

Thanks Vinod, Sujay,

It works.

One more clarification I need. What ever target quantity I give, it is getting added up with the existing quantity.

My Requirement is to reduce the quantity, can you suggest any option?

0 Kudos
136

Hope you are passing 'U' in the structure field UPDATEFLAG. Check the entries in VBEP (Schedule Lines) Table for the order. Total Quantity of VBEP (for a specific Line item) will be updated in VBAP. If you want to delete the entry in schedule line (VBEP) pass the value 'D' to structure field SCHEDULE_LINESX-UPDATEFLAG.

0 Kudos
136

Hi Vinod,

I am not trying to delete the item.

Everything is fine except the quantity updation. I changed the schedule line part as below. Now I am getting an error "Missing item number when you changed the schedule line " . But item number is available on "wa_vbap-posnr" debug. This error comes only when I update the updateflag for schedule ilne, otherwise it is going fine.

lt_schedule_linesx-itm_number = wa_vbap-posnr.

IF NOT wa_vbap IS INITIAL.

lt_schedule_linesx-updateflag = 'U'.

ELSE.

lt_schedule_linesx-updateflag = 'I'.

ENDIF.

lt_schedule_linesx-req_qty = 'X'.

APPEND lt_schedule_linesx.

lt_schedule_lines-itm_number = wa_vbap-posnr.

lt_schedule_lines-req_qty = '2'.

APPEND lt_schedule_lines.

Can you suggest?

0 Kudos
136

Hi,

When you update, you have to provide the SCHED_LINE in the structure as Vinod had earlier pointed out, Get the value from VBEP-ETENR for the corresponding schedule line.

Sujay