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 Error

Former Member
0 Likes
2,407

Dear All,

I am trying to change the Scheduling dates for a Sales Order using BAPI_SALESORDER_CHANGE.

After executing the BAPI, the retrn code is 0 but the return table has error as "Enter the document number"

Pasting the code for you ref.


              wa_orderx-updateflag = 'U'.
              wa_orderx-sales_org = 'X'.
              wa_orderx-distr_chan = 'X'.
              wa_orderx-division = 'X'.
              wa_order-sales_org = lv_vkorg.
              wa_order-distr_chan = lv_vtweg.
              wa_order-division = lv_spart.

              wa_bapisditm-itm_number  = wa_xvbep-posnr.
              APPEND wa_bapisditm TO it_bapisditm.

              wa_bapisditmx-itm_number = wa_xvbep-posnr.
              wa_bapisditmx-updateflag = 'U'.
              APPEND wa_bapisditmx TO it_bapisditmx.

              wa_bapischdl-itm_number = wa_xvbep-posnr.
              wa_bapischdl-sched_line = wa_xvbep-etenr.
              wa_bapischdl-ms_date    = wa_xvbep-mbdat.
              wa_bapischdl-load_date  = wa_xvbep-lddat.
              wa_bapischdl-gi_date    = wa_xvbep-wadat.
              wa_bapischdl-req_date   = wa_xvbep-edatu.
              APPEND wa_bapischdl TO it_bapischdl.

              wa_bapischdlx-itm_number = wa_xvbep-posnr.
              wa_bapischdlx-sched_line = wa_xvbep-etenr.
              wa_bapischdlx-ms_date    = 'X'.
              wa_bapischdlx-load_date  = 'X'.
              wa_bapischdlx-gi_date    = 'X'.
              wa_bapischdlx-req_date   = 'X'.
              wa_bapischdlx-updateflag = 'U'.
              APPEND wa_bapischdlx TO it_bapischdlx.

     CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
        EXPORTING
          salesdocument    = lv_vbeln
          order_header_in  = wa_order
          order_header_inx = wa_orderx
        TABLES
          return           = it_bapiret2
          order_item_in    = it_bapisditm
          order_item_inx   = it_bapisditmx
          schedule_lines   = it_bapischdl
          schedule_linesx  = it_bapischdlx.

All the work areas and variables have values.

Please help me find a solution.

regards,

Jinson

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,674

Hi,

Hope this will help

Cheers,

Pravin S

11 REPLIES 11
Read only

Former Member
0 Likes
1,673

Check while debugging lv_vbeln is not initial.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = lv_vbeln """" Check not initial

order_header_in = wa_order

order_header_inx = wa_orderx

TABLES

return = it_bapiret2

order_item_in = it_bapisditm

order_item_inx = it_bapisditmx

schedule_lines = it_bapischdl

schedule_linesx = it_bapischdlx.

Read only

0 Likes
1,673

Try populating the quantity field in the schedule line structure of the BAPISCHDL-REQ_QTY as well along with the date fields. That may remove the error.

Read only

0 Likes
1,673

>

> Try populating the quantity field in the schedule line structure of the BAPISCHDL-REQ_QTY as well along with the date fields. That may remove the error.

Dear Bhaskar,

Tried populating the BAPISCHDL-REQ_QTY field.But still the error is coming.

thanks,

Jinson

Read only

0 Likes
1,673

Hi

Fill the reference document number field REF_DOC in bapi importing structure BAPISDH1.

I think this will resolve your problem as the sales order change requires this field, if the order created with reference document number.

With Regards,

Dwarakanath.S

Read only

0 Likes
1,673

Dwarakanath,

I have checked the order again, it was not created with ref doc no.

thanks,

Jinson

Read only

Former Member
0 Likes
1,673

Pl. check whether the variable lv_vbeln contains the sales order no. or not. Also pl. post the message id and message no that u r getting in the return table.

Read only

0 Likes
1,673

Thanks for the quick response.

lv_vbeln is not initial.

and the msg details are as follows.

TYPE E

ID V1

NUMBER 045

MESSAGE Enter the document number

thanks,

Jinson

Read only

0 Likes
1,673

Hi,

I can only suspect one thing.

You are using this inside a loop endloop. and may be using a control break statement did you check if all values are well in debugging.

santhosh

Read only

0 Likes
1,673

>

> Hi,

> I can only suspect one thing.

>

> You are using this inside a loop endloop. and may be using a control break statement did you check if all values are well in debugging.

>

> santhosh

No Santosh, I am not using it in a Loop or using any control break statement with it.

thanks,

Jinson.

Read only

tarangini_katta
Active Contributor
0 Likes
1,673

Hi Jinso,

i think u need pass the order number to evry table then i hope it will not through an error for you.

Thanks,

Read only

Former Member
0 Likes
1,675

Hi,

Hope this will help

Cheers,

Pravin S