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

BAPI_SALESORDER_CHANGE doesn't change quantity

Former Member
7,041

Hi Forum,

I need to change the selected quantity of sales order by using BAPI_SALESORDER_CHANGE, I can change the quantity values by using transaction code va02, but when I use BAPI_SALESORDER_CHANGE is gives the message order changed succesfully but nothing changed. I use BAPI_TRANSACTION_COMMIT. Anyone used this BAPI before?

Regards,

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,459

Hi,

Try changing the quantity using the schedule lines. Because sometimes if an item number has assosiated schedule lines then the only way of changing the item quantity is by changing the induvidual entries in schedule lines.

Hope this works.

Sharath.

Hi Forum,

I need to change the selected quantity of sales order by using BAPI_SALESORDER_CHANGE, I can change the quantity values by using transaction code va02, but when I use BAPI_SALESORDER_CHANGE is gives the message order changed succesfully but nothing changed. I use BAPI_TRANSACTION_COMMIT. Anyone used this BAPI before?

Regards,

12 REPLIES 12
Read only

Former Member
0 Likes
3,459

Hi Abdulvahap Yeroglu,

can u tell me how the sales order is getting creted,it's thru bapi or any other service/fuction?

In that bapi or any other service/fuction whidh is creating the sales u call a function module(u can search for this FM in SE37 or SE80) and pass the parameters and carry outt he necessary changes.

If I get that FM, i'll let u know.

check whether u've updkz(update parameter) field in ur BAPI_SALESORDER_CHANGE, if yes then pass 'i' to it.

all the best.

regards

Message was edited by: henry

Message was edited by: henry

Message was edited by: henry

Read only

0 Likes
3,459

Hi Henry,

thanks for your care,

I have no updkz field in the BAPI, my code is below, I used neccessary update flag and other values, still I have problem.

header_inx-updateflag = 'U'.

item_in-itm_number = itab-posnr.

item_in-target_qty = itab-dmiktar.

item_in-target_qu = itab-vrkme.

APPEND item_in.

item_inx-itm_number = itab-posnr.

item_inx-updateflag = 'U'.

item_inx-target_qty = 'X'.

item_inx-target_qu = 'X'.

APPEND item_inx.

break hgenc.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = itab-vbeln

order_header_inx = header_inx

TABLES

return = message

order_item_in = item_in

order_item_inx = item_inx.

READ TABLE message WITH KEY type = 'E'.

IF sy-subrc NE 0.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

ENDIF.

CLEAR ret. APPEND ret.

Read only

nishanthbhandar
Contributor
0 Likes
3,459

Please check whether you have put an 'U' for the update flag and an 'X' for the quantity field that you are trying to update.The BAPI works fine and the sequence of execution is

BAPI_SALESORDER_CHANGE

BAPI_TRANSACTION_COMMIT

If this solves your problem please close the thread and give the reward points.

Cheers

Nishanth

Read only

0 Likes
3,459

Hi,

I did those things but nothing changed, I used BAPI_TRANSACTION_COMMIT.

Thanks,

Read only

Former Member
0 Likes
3,460

Hi,

Try changing the quantity using the schedule lines. Because sometimes if an item number has assosiated schedule lines then the only way of changing the item quantity is by changing the induvidual entries in schedule lines.

Hope this works.

Sharath.

Read only

0 Likes
3,459

I understand that you are trying to change the order quantity at the item level.If it's some other quantity then please let me know.The idea is to make all the required entries.If you are updating the item then i am sure you have entered an 'U' and 'X' in ORDER_ITEM_INX and the corresponding quantity in ORDER_ITEM.If not please let me know.

Cheers

Nishanth

Read only

0 Likes
3,459

I try it by using schedule lines but the result is same.

thanks for your relevance

Read only

0 Likes
3,459

Hi,

previoulsy i had same problem when i am creating the sales orders using BAPI. Use schedule lines structure

<b>(BAPISCHDL)</b> field <b>req_qty</b> and corresponding structure Mark the <b>BAPISCHDLX-REQ_QTY = 'X'.</b> still if you are facing problem please put the code here we will try to sort it out.

Good Luck

Suresh Babu Karanam

Read only

0 Likes
3,459

> Hi,

>

> previoulsy i had same problem when i am creating the

> sales orders using BAPI. Use schedule lines structure

>

> <b>(BAPISCHDL)</b> field <b>req_qty</b> and

> corresponding structure Mark the

> <b>BAPISCHDLX-REQ_QTY = 'X'.</b> still if you are

> facing problem please put the code here we will try

> to sort it out.

>

> Good Luck

> Suresh Babu Karanam

Hello

Please see the following code which is posted by some users previously.

<b>Code:</b>

parameters: p_vbeln type bapivbeln-vbeln default '7226'.

      • Header Structure

data: ls_order_header_in type bapisdh1.

data: ls_order_header_inx type bapisdh1x.

      • Line Item Table

data: lt_order_item_in type table of bapisditm.

data: lt_order_item_inx type table of bapisditmx.

      • Schedule Lines Table

data: lt_schedule_lines type table of bapischdl.

data: lt_schedule_lines_x type table of bapischdlx.

      • Schedule Lines Structure

data: ls_schedule_lines type bapischdl.

data: ls_schedule_lines_x type bapischdlx.

      • Return Tabledata: lt_return type table of bapiret2.

data: ls_return type bapiret2.

      • Header Information

ls_order_header_in-sales_org = '1000'.

ls_order_header_in-distr_chan = '10'.

ls_order_header_in-division = '00'.

*ls_order_header_in-sales_grp = '110'.

*ls_order_header_in-sales_off = '1010'.

***To updatels_order_header_inx-updateflag = 'U'.

      • Schedule Line Information

ls_schedule_lines-itm_number = '000010'.

ls_schedule_lines-sched_line = '0003'.

*ls_schedule_lines-req_date = '20050401'.

ls_schedule_lines-date_type = '1'.

ls_schedule_lines-req_qty = '105.000'.

append ls_schedule_lines to lt_schedule_lines.

*ls_schedule_lines-itm_number = '000010'.

ls_schedule_lines-sched_line = '0003'.

*ls_schedule_lines-req_date = '20050401'.

ls_schedule_lines-date_type = '1'.

ls_schedule_lines-req_qty = '130.000'.

append ls_schedule_lines to lt_schedule_lines.

ls_schedule_lines_x-itm_number = '000010'.

ls_schedule_lines_x-sched_line = '0003'.

ls_schedule_lines_x-updateflag = 'U'.

ls_schedule_lines_x-req_date = 'X'.

ls_schedule_lines_x-date_type = 'X'.

ls_schedule_lines_x-req_qty = 'X'.

append ls_schedule_lines_x to lt_schedule_lines_x.

*ls_schedule_lines-itm_number = '000010'.

*ls_schedule_lines-sched_line = '0039'.

*ls_schedule_lines-req_date = '20050401'.

*ls_schedule_lines-date_type = '1'.

*ls_schedule_lines-req_qty = '80.000'.

*append ls_schedule_lines to lt_schedule_lines.

**ls_schedule_lines_x-itm_number = '000010'.

*ls_schedule_lines_x-sched_line = '0039'.

*ls_schedule_lines_x-updateflag = 'I'.

*ls_schedule_lines_x-req_date = 'X'.

*ls_schedule_lines_x-date_type = 'X'.

*ls_schedule_lines_x-req_qty = 'X'.

*append ls_schedule_lines_x to lt_schedule_lines_x.

call function 'BAPI_SALESORDER_CHANGE'

exporting

salesdocument = p_vbeln order_header_in = ls_order_header_in order_header_inx = ls_order_header_inx* SIMULATION =* BEHAVE_WHEN_ERROR = ' '* INT_NUMBER_ASSIGNMENT = ' '* LOGIC_SWITCH = tables return = lt_return order_item_in = lt_order_item_in order_item_inx = lt_order_item_inx* PARTNERS =* PARTNERCHANGES =* PARTNERADDRESSES =* ORDER_CFGS_REF =* ORDER_CFGS_INST =* ORDER_CFGS_PART_OF =* ORDER_CFGS_VALUE =* ORDER_CFGS_BLOB =* ORDER_CFGS_VK =* ORDER_CFGS_REFINST = schedule_lines = lt_schedule_lines schedule_linesx = lt_schedule_lines_x* ORDER_TEXT =* ORDER_KEYS =* CONDITIONS_IN =* CONDITIONS_INX =* EXTENSIONIN = .

call function 'BAPI_TRANSACTION_COMMIT'

exporting

wait = 'X'

  • IMPORTING* RETURN =

//Suresh Babu Karanam

Read only

0 Likes
3,459

Hi Sures Babu,

Here is my code, I check the itab, it includes the correct values, but cannot change the quantity with BAPI_SALESORDER_CHANGE. Thanks for your relevance.

LOOP AT itab WHERE chk = 'X'.

CLEAR header_inx.

REFRESH : item_in, item_inx, message.

header_inx-updateflag = 'U'.

item_in-itm_number = itab-posnr.

item_in-target_qty = itab-dmiktar.

item_in-target_qu = itab-vrkme.

APPEND item_in.

item_inx-itm_number = itab-posnr.

item_inx-updateflag = 'U'.

item_inx-target_qty = 'X'.

item_inx-target_qu = 'X'.

APPEND item_inx.

I_SCHED-ITM_NUMBER = ITAB-POSNR.

I_SCHED-SCHED_LINE = ITAB-ETENR.

I_SCHED-REQ_QTY = 0 .

I_SCHEDX-UPDATEFLAG = 'U'.

I_SCHEDX-ITM_NUMBER = ITAB-POSNR.

I_SCHEDX-SCHED_LINE = ITAB-ETENR.

I_SCHEDX-REQ_QTY = 'X'.

APPEND I_SCHED.

APPEND I_SCHEDX.

break hgenc.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = itab-vbeln

order_header_inx = header_inx

TABLES

return = message

order_item_in = item_in

order_item_inx = item_inx.

SCHEDULE_LINES = I_SCHED

SCHEDULE_LINESX = I_SCHEDX.

break hgenc.

READ TABLE message WITH KEY type = 'E'.

IF sy-subrc NE 0.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

ENDIF.

CLEAR ret. APPEND ret.

LOOP AT message.

MOVE-CORRESPONDING message TO ret.

APPEND ret.

ENDLOOP.

ENDLOOP.

Read only

0 Likes
3,459

Hello,

I am little busy with my work. I have seen some errors in your program. Please correct those it should work. Just now i have tested it is working fine.

1)Remove item_in-target_qty = itab-dmiktar.

item_in-target_qu = itab-vrkme from <b>item_in </b>

but still you can add Material number. Now in item_in should have only item number and material.

2)Do correspondingly <b>item_inx</b> and delete target qty, unit but add mateiral number. Now in <b>item_inx</b> should have only item number,Update flag (U) and material.

3) You are not specify the partner details at all, i am not sure, but for safety please fill that structure also.

4) I think schedule lines were looks fine.

and see the <b>bapi return</b> structure once FM is executed.

Regards

Suresh Babu Karanam

Read only

0 Likes
3,459

Same problem.. But u gave excellent solution Sir... Hats off. Trying from 4days..

Really happy..

Thanq very much Suresh babu..

Mithuunn,