Skip to Content

How to add scales with BAPI_CONTRACT_CHANGE?

Hi community,

I try to add scales to an outline agreement with BAPI_CONTRACT_CHANGE (=ME32K). The contract condition line already exists. The Bapi returns that the contract has been changed successfully. However, when I look into the condition line (ME33K) no scales were created at all.

*&---------------------------------------------------------------------*
*& Report ZMTEST_BAPI_SCALES
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zmtest_bapi_scales.

DATA:
  lt_conds   TYPE bapimeout_t_cond,
  lt_conds_u TYPE bapimeout_t_cond,    lt_condsux   TYPE bapimeout_t_condx,
  ls_cond    TYPE bapimeoutcondition,   ls_condsx    TYPE bapimeoutconditionx,
  lt_scales  TYPE bapimeout_t_scalequant,
  ls_scale   TYPE bapimeoutitemscalequan,
  lt_return  TYPE bapiret2_tbl, "Meldungen
  ls_return  TYPE bapiret2.

PARAMETERS:
  p_ebeln TYPE ekpo-ebeln DEFAULT 6291000532,
  p_item  LIKE ls_cond-item_no DEFAULT 1,
  p_test  TYPE abap_bool DEFAULT abap_true as CHECKBOX.

START-OF-SELECTION.

  CALL FUNCTION 'BAPI_CONTRACT_GETDETAIL'
    EXPORTING
      purchasingdocument = p_ebeln
      condition_data     = 'X'
    TABLES
      item_condition     = lt_conds.

  " Konditionszeile aktualisieren
  READ TABLE lt_conds INTO ls_cond WITH KEY item_no = p_item cond_count = 1
       TRANSPORTING item_no serial_id cond_count.
  ls_cond-scale_base_ty = 'C'. "Mengenstaffel
  ls_cond-scale_type = 'A'. "ab Staffel
  ls_cond-scale_unit = 'PC'.
  ls_cond-scale_unit_iso = 'PCE'.
  ls_cond-change_id = 'U'.
  APPEND ls_cond TO lt_conds_u.

  ls_condsx-item_no = ls_cond-item_no.
  ls_condsx-serial_id = ls_cond-serial_id.
  ls_condsx-cond_count = ls_cond-cond_count.
  ls_condsx-item_nox = 'X'.
  ls_condsx-serial_idx = 'X'.
  ls_condsx-cond_countx = 'X'.
  ls_condsx-scale_type = 'X'.
  ls_condsx-scale_base_ty = 'X'.
  ls_condsx-scale_unit = 'X'.
  ls_condsx-scale_unit_iso = 'X'.
  APPEND ls_condsx TO lt_condsux.

  " Staffelzeilen erstellen
  ls_scale-item_no = ls_cond-item_no.
  ls_scale-serial_no = ls_cond-serial_id.
  ls_scale-cond_count = ls_cond-cond_count.

  ls_scale-line_no = 1.
  ls_scale-scale_base_qty = 1.
  ls_scale-cond_value = 20.
  APPEND ls_scale TO lt_scales.

  ls_scale-line_no = 2.
  ls_scale-scale_base_qty = 10.
  ls_scale-cond_value = 18.
  APPEND ls_scale TO lt_scales.

  ls_scale-line_no = 3.
  ls_scale-scale_base_qty = 50.
  ls_scale-cond_value = 15.
  APPEND ls_scale TO lt_scales.

  IF p_test = abap_false.
    CALL FUNCTION 'BAPI_CONTRACT_CHANGE'
      EXPORTING
        purchasingdocument   = p_ebeln
      TABLES
        item_condition       = lt_conds_u
        item_conditionx      = lt_condsux
        item_cond_scale_quan = lt_scales
        return               = lt_return.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      IMPORTING
        return = ls_return.
    APPEND ls_return TO lt_return.
  ENDIF.

  BREAK-POINT.

lt_conds_u

ITEM_NO SERIAL_ID COND_COUNT SCALE_TYPE SCALE_BASE_TY SCALE_UNIT SCALE_UNIT_ISO CHANGE_ID
00001 0000211591 01 A C PC PCE U

lt_condsux

ITEM_NO SERIAL_ID COND_COUNT ITEM_NOX SERIAL_IDX COND_COUNTX COND_TYPE SCALE_TYPE SCALE_BASE_TY SCALE_UNIT SCALE_UNIT_ISO 
00001 0000211591 01 X X X X X X X

lt_scales

ITEM_NO SERIAL_NO COND_COUNT LINE_NO SCALE_BASE_QTY COND_VALUE
00001   0000211591 01 0001  1.000 20.000000000
00001   0000211591 01 0002 10.000 18.000000000
00001   0000211591 01 0003 50.000 15.000000000

After execution the BAPI returns:

Instance 6291000532 of object type PurchasingContract has been changed.
central value contr. 6291000532 changed

Unfortunately, the condition were not updated.

What am I doing wrong?

Regards,

José

me33k-1.jpg (197.1 kB)
Add comment
10|10000 characters needed characters exceeded

  • You must check there are no 'E' error message in RETURN before COMMIT, also the BAPI_TRANSACTION_COMMIT wont return a RETURN parameter without parameter WAIT set.

  • "You must check there are no 'E' error message in RETURN before COMMIT, also the BAPI_TRANSACTION_COMMIT wont return a RETURN parameter without parameter WAIT set."

    As you can see in my original posting, there are no E messages in the return parameter. Using parameter WAIT in BAPI_COMMIT does not provide any additional information.

    PS: Please do not use the comment function to provide any solution suggestions as that does not allow to reply properly.

  • Follow
  • Get RSS Feed

1 Answer

  • Feb 12 at 07:11 AM

    Did you remove the code where you checked RETURN for error (or information) messages?

    Add comment
    10|10000 characters needed characters exceeded