cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to update record using BAPI_SALESORDER_CHANGE?

vinayad
Participant
0 Likes
1,272

Hello all,

I am trying update VBEP table record using BAPI_SALESORDER_CHANGE but it is duplicating the record instead of updating to the old record.

What would be the issue ?

Any help would be appreciated!

      w_order_sch_in-itm_number = i_item.
      w_order_sch_in-ms_date = i_matl_avail_date.
      append w_order_sch_in to i_order_sch_in.
      CLEAR: w_order_sch_in.

      w_order_sch_inx-itm_number = i_item.
      w_order_sch_inx-ms_date = 'X'.
      w_order_sch_inx-updateflag = 'U'. 
      append w_order_sch_inx to i_order_sch_inx.
      CLEAR: w_order_sch_inx.

     CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
        EXPORTING
          SALESDOCUMENT               = I_SALES_DOCUMENT     
          ORDER_HEADER_INX            = order_headerx
        TABLES
          RETURN                      = t_return
          SCHEDULE_LINES              = i_order_sch_in
          SCHEDULE_LINESX             = i_order_sch_inx.

      CLEAR w_return.
      READ TABLE t_return INTO w_return WITH KEY type = 'E'.

      IF w_return IS NOT INITIAL.   " error found
        MESSAGE w_return-message TYPE 'I'.
        RETURN.
      ENDIF.

      CLEAR w_return.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
       EXPORTING
         WAIT          = 'X'
       IMPORTING
         RETURN        = w_return .

      IF w_return-type = 'E'.   " error found
        MESSAGE w_return-message TYPE 'I'.
        RETURN.
      Endif.

Accepted Solutions (1)

Accepted Solutions (1)

RobertVit
Active Contributor
0 Likes

Hi,

you need to enter an existing etenr to complete the key

KR

vinayad
Participant
robert.forster3 Thank you for response !I have added it, still no changes.
w_order_sch_in-sched_line = wa_vbep-etenr.
Sandra_Rossi
Active Contributor

vinayad don't forget that other line:

w_order_sch_inx-sched_line = wa_vbep-etenr.
vinayad
Participant
0 Likes
Sandra Rossi

Thank you for your response!

Instead of moving the value, I made mistake here.

w_order_sch_inx-sched_line = 'X'.

It's working now thanks.

vinayad
Participant
0 Likes

robert.forster3 and Sandra Rossi

It is working for present and future date but user also requires for past date.

How to achieve it ? It is showing information message on screen

Answers (0)