Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Price changing in BAPI_SALESORDER_CHANGE


Hello Friends,

I am changing requested date in sales order but the prices is also changing. Please help to solve.

My code is :

START-OF-SELECTION.

PERFORM f_update_crd USING '0052714759'    "wa_vbakvbap-vbeln
                           '000010'         "wa_vbakvbap-posnr
                           '15122016'     "wa_output-crd  "Update CRD
                           '08122015'.   "wa_vbakvbap-edatu. "Schedule date

END-OF-SELECTION.

FORM f_update_crd  USING    p_sales_order TYPE vbeln
                            p_order_item  TYPE posnr
                            p_output_crd  TYPE char10
                            p_edatu       TYPE edatu.

  DATA : lt_schedule_lines TYPE TABLE OF bapischdl,
         ls_schedule_lines TYPE bapischdl,
         lt_schedule_linesx TYPE TABLE OF bapischdlx,
         ls_schedule_linesx TYPE bapischdlx,
         lt_return TYPE TABLE OF bapiret2,
         ls_return TYPE bapiret2,
         ls_order_header_inx TYPE bapisdh1x,
         ls_logic_switch TYPE bapisdls.

  CLEAR : ls_schedule_lines, ls_schedule_linesx,
          ls_order_header_inx, ls_return, ls_logic_switch, gv_vbeln.
  REFRESH : lt_schedule_lines, lt_schedule_linesx, lt_return.

  PERFORM convert_date_in_sap USING p_output_crd
                           CHANGING p_output_crd.

  PERFORM convert_date_in_sap USING p_edatu
                           CHANGING p_edatu.

  ls_schedule_lines-itm_number = p_order_item.
  ls_schedule_lines-sched_line = '0001'.
  ls_schedule_lines-req_date   = p_output_crd.
  APPEND ls_schedule_lines TO lt_schedule_lines.

  ls_schedule_linesx-itm_number = p_order_item.
  ls_schedule_linesx-sched_line = '0001'.

  ls_schedule_linesx-updateflag = 'U'.
  ls_schedule_linesx-req_date   = 'X'.
  APPEND ls_schedule_linesx TO lt_schedule_linesx.

  ls_order_header_inx-updateflag = 'U'.

  ls_logic_switch-pricing = 'X'.      "Copy pricing elements unchanged and redetermine taxes
  ls_logic_switch-cond_handl = 'X'.   "Implementation of new procedure for condition lines handling


  CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
    EXPORTING
      salesdocument    = p_sales_order
      order_header_inx = ls_order_header_inx
      logic_switch     = ls_logic_switch
    TABLES
      return           = lt_return
      schedule_lines   = lt_schedule_lines
      schedule_linesx  = lt_schedule_linesx.

  READ TABLE lt_return INTO ls_return WITH KEY type = 'E'.
  IF sy-subrc = 0.
    SKIP 1.
    WRITE :/ p_sales_order, '-', p_order_item, ls_return-message(70).
  ELSE.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        wait = 'X'.
    IF p_output_crd < p_edatu.
      WRITE:/ 'LSD Improved'.
    ELSEIF p_output_crd > p_edatu.
      WRITE:/ 'LSD Pushed Out'.
    ENDIF.
    gv_vbeln = p_sales_order.
  ENDIF.
ENDFORM.

Not what you were looking for? View more on this topic or Ask a question