Skip to Content
0
Oct 06, 2019 at 10:09 AM

BAPI_SALESORDER_CREATEFROMDAT2 Updating condition value

1153 Views

Hi gurus,

I am working on an upload program which will mass create Sales Order.

A brief introduction as below:

1. Prices are all manually entered during upload.

2. Condition type (ZEAP) is configured to allow manual entries.

3. Manual creation via VA01 is working without any issue.

4. I am attempting to upload and create a sales order with multiple line items.

5. All line items have the same condition type (ZEAP) in upload file and before passing to bapi BAPI_SALESORDER_CREATEFROMDAT2.

My issue:

1. When upload a sales order with 3 line items, in the created sales order, the first two line items have their prices updated. The third line is not updated.

2. Issue only occurs when there are multiple line items and only occurs to the last line item.

Kindly advise on what are the possible cause of errors and let me know the information is suffficient.

Code snippet:

"Begin of line item condition details
    ls_cond-itm_number = lv_posnr.
    ls_cond-cond_type  = <fs_upload>-kschl.
    ls_cond-cond_value = <fs_upload>-kbetr.
    ls_cond-condvalue  = <fs_upload>-kbetr.
    ls_cond-cond_p_unt = <fs_upload>-kpein.
    ls_cond-currency   = <fs_upload>-waers.
    ls_cond-curr_iso   = <fs_upload>-waers.
    ls_cond-cond_unit  = <fs_upload>-kmein.
    ls_cond-cd_unt_iso = <fs_upload>-kmein.
    ls_cond-cond_st_no = '020'.
    ls_cond-cond_count = '01'.
    ls_cond-cond_updat = abap_true.

    ls_condx-itm_number = lv_posnr.
    ls_condx-cond_st_no = '020'.
    ls_condx-cond_count = '01'.
    ls_condx-cond_type  = <fs_upload>-kschl.
    ls_condx-cond_value = abap_true.
    ls_condx-cond_p_unt = abap_true.
    ls_condx-currency   = abap_true.
    ls_condx-cond_unit  = abap_true.
    ls_condx-updateflag = 'U'.

    APPEND ls_items     TO lt_items.
    APPEND ls_itemx     TO lt_itemx.
    APPEND ls_schedule  TO lt_schedule.
    APPEND ls_schedulex TO lt_schedulex.
    APPEND ls_cond      TO lt_cond.
    APPEND ls_condx     TO lt_condx.
  ENDLOOP.

  CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
    EXPORTING
      order_header_in      = ls_header
      order_header_inx     = ls_headerx
    IMPORTING
      salesdocument        = lv_vbeln
    TABLES
      return               = lt_return
      order_items_in       = lt_items
      order_items_inx      = lt_itemx
      order_partners       = lt_partner
      order_schedules_in   = lt_schedule
      order_schedules_inx  = lt_schedulex
      order_conditions_in  = lt_cond
      order_conditions_inx = lt_condx.