Skip to Content
0
Former Member
Jul 04, 2008 at 09:07 AM

BAPI_SALESORDER_CHANGE add new line and conditions with a condition value

143 Views

Hi,

I am using BAPI_SALESORDER_CHANGE to add new lines to a credit memo. All works fine except that I can not seem to put a condition value on the new lines. The condition is created but with a value of 0. I can popluate the condition amount field, KBETR but not KWERT. BAPICONDX seems to only have the COND_VALUE field in it and not CONDVALUE as in BAPICOND. Does anyone have any idea how to do this? In the code below I just want to change the material on the first line of the credit memo and not add the condition. Then add new lines with the the condition.

lw_order_header_inx-updateflag  = 'U'.

  LOOP AT i_accru INTO wa_accru.
    lv_count = lv_count + 1.
    lv_posnr = lv_count * 10.

* Order Items
    lw_order_item_inx-itm_number = lv_posnr.
    lw_order_item_inx-material   = 'X'.

    IF lv_count = 1.
      lw_order_item_inx-updateflag    = 'U'.
    ELSE.
      lw_order_item_inx-updateflag    = 'I'.
    ENDIF.

    APPEND lw_order_item_inx TO lt_order_item_inx.

    lw_order_item_in-itm_number = lv_posnr.
    lw_order_item_in-material   = wa_accru-vakey.

    APPEND lw_order_item_in TO lt_order_item_in.

* Conditions
    IF lv_count <> 1.

      lw_conditions_inx-itm_number = lv_posnr.
      lw_conditions_inx-cond_st_no = '905'.
      lw_conditions_inx-cond_count = '01'.
      lw_conditions_inx-cond_type  = 'ZHIE'.
      lw_conditions_inx-currency   = 'X'.
      lw_conditions_inx-updateflag = 'I'.

      APPEND lw_conditions_inx TO lt_conditions_inx.

      lw_conditions_in-itm_number = lv_posnr.
      lw_conditions_in-cond_st_no = '905' .
      lw_conditions_in-cond_count = '01'.
      lw_conditions_in-cond_type  = 'ZHIE'.
      lw_conditions_in-condvalue  = wa_accru-accru.
      lw_conditions_in-currency   = 'GBP'.

      APPEND lw_conditions_in TO lt_conditions_in.
    ENDIF.


  ENDLOOP.


* Change the credit memo
  CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
    EXPORTING
      salesdocument               = lv_vbeln
      order_header_in             = lw_order_header_in
      order_header_inx            = lw_order_header_inx
*   SIMULATION                  =
*   BEHAVE_WHEN_ERROR           = ' '
*   INT_NUMBER_ASSIGNMENT       = ' '
*   LOGIC_SWITCH                =
*   NO_STATUS_BUF_INIT          = ' '
    TABLES
      return                      = lt_return
      order_item_in               = lt_order_item_in
      order_item_inx              = lt_order_item_inx
*   PARTNERS                    =
*   PARTNERCHANGES              =
*   PARTNERADDRESSES            =
*   ORDER_CFGS_REF              =
*   ORDER_CFGS_INST             =
*   ORDER_CFGS_PART_OF          =
*   ORDER_CFGS_VALUE            =
*   ORDER_CFGS_BLOB             =
*   ORDER_CFGS_VK               =
*   ORDER_CFGS_REFINST          =
*   SCHEDULE_LINES              =
*   SCHEDULE_LINESX             =
*   ORDER_TEXT                  =
*   ORDER_KEYS                  =
     conditions_in               = lt_conditions_in
     conditions_inx              = lt_conditions_inx
*   EXTENSIONIN                 =
            .

  IF sy-subrc = 0.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
*   WAIT          =
* IMPORTING
*   RETURN        =
              .
  ENDIF.