Skip to Content
Nov 22, 2018 at 02:26 PM

BAPI_SALESORDER_CHANGE extension update issue

2417 Views Last edit Nov 22, 2018 at 02:35 PM 4 rev

I am trying to update two value though BAPI


update of ORD_REASON field through header structure order_header_in and order_header_inx .


I have added new custom field in VBAK and updated same field in the BAPI structure bape_vbak and bape_vbakx.

Now the problem is when i am trying to update both first and second value , i am getting error order reason 000 is not defined in table bapi table ct_return.

But you can see below the sample code , i am passing Order reason value as Z23 .

So here i doubt this error is because of the extension value is not properly integrated with the BAPi because when i do not pass the extension table it does not give me any such error.

I have attached the code below . Please let me know if i am doing anything wrong.

Thanks in advance.



 lc_status        TYPE augru          VALUE 'Z23'.

* Fill order readson to update in BAPI

  ls_order_header_in-ord_reason  = lc_status.

  ls_order_header_inx-updateflag = 'U'.

  ls_order_header_inx-ord_reason = 'X'.

* Fill BAPI extension to update reason reject code

  ls_bape_vbak-vbeln            = uv_vbelv.

  lv_reject_reason              = uv_augru. " this value is fetcched previously

  ls_bape_vbak-value1-zz_reject_reason = lv_reject_reason.

   ASSIGN ls_bape_vbak TO <fs_x_vbak> CASTING.

   ASSIGN <fs_x_vbak> TO <fs_c_vbak> CASTING.

  ls_extension-structure        = lc_ext_vbak.

  ls_extension-valuepart1       = <fs_c_vbak>(240).

  ls_extension-valuepart2       = <fs_c_vbak>+240(208).

  APPEND ls_extension TO lt_extension.

  CLEAR ls_extension.
  ls_bape_vbakx-value1x-zz_reject_reason = 'X'.

  ASSIGN ls_bape_vbakx TO <fs_x_vbakx> CASTING.

  ASSIGN <fs_x_vbakx> TO <fs_c_vbakx> CASTING.

  ls_extension-structure         = lc_ext_vbakx.

  ls_extension-valuepart1        = <fs_c_vbakx>.

  APPEND ls_extension TO lt_extension.

  CLEAR: <fs_c_vbak>, <fs_x_vbak>.



      salesdocument    = uv_vbelv   " this the offer which should be upadted

      order_header_in  = ls_order_header_in

      order_header_inx = ls_order_header_inx


      return           = ct_return

      order_text       = lt_order_text

      extensionin      = lt_extension.