Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Change condition amount on BAPI_CONTRACT_CHANGE

marcelom_bovo
Participant
0 Kudos

Hi people,

I am trying to update the amount value of an item condition for a contract on ME32K.

For that I'm using BAPI_CONTRACT_CHANGE.

I created a program to test the BAPI, but it is not working.

After execute it, return table have no error message, but when I go to ME33K, the amount is not changed.

I have search the entire forum, but found no answer.

tks

1 ACCEPTED SOLUTION

marcelom_bovo
Participant

Here is the program I've made to test the BAPI:


DATA: v_po TYPE bapimeoutheader-number VALUE '4600000001'.
DATA: t_item  TYPE TABLE OF bapimeoutitem WITH HEADER LINE,
      t_itemx TYPE TABLE OF bapimeoutitemx WITH HEADER LINE,
      t_item_condition  TYPE TABLE OF bapimeoutcondition WITH HEADER LINE,
      t_item_condition_s  TYPE TABLE OF bapimeoutcondition WITH HEADER LINE,
      t_item_conditionx TYPE TABLE OF bapimeoutconditionx WITH HEADER LINE,
      t_item_cond_validity TYPE TABLE OF bapimeoutvalidity WITH HEADER LINE,
      t_item_cond_validityx TYPE TABLE OF bapimeoutvalidityx WITH HEADER LINE,
      t_return  TYPE TABLE OF bapiret2 WITH HEADER LINE.



CALL FUNCTION 'BAPI_CONTRACT_GETDETAIL'
  EXPORTING
    purchasingdocument = v_po
    item_data          = 'X'
    condition_data     = 'X'
  TABLES
    item               = t_item
    item_cond_validity = t_item_cond_validity
    item_condition     = t_item_condition_s
    return             = t_return.


READ TABLE t_item_condition_s INDEX 1.
READ TABLE t_item_cond_validity INDEX 1.

t_item_cond_validityx-serial_id = t_item_condition_s-serial_id.
t_item_cond_validityx-item_no = 10.

APPEND t_item_cond_validityx.

t_item_condition-item_no = 10.
t_item_condition-cond_value = 51.
t_item_condition-serial_id = t_item_condition_s-serial_id.
t_item_condition-cond_count = t_item_condition_s-cond_count.
*T_ITEM_CONDITION-COND_TYPE = 'PB00'.
t_item_condition-change_id = 'U'.
APPEND t_item_condition.

t_item_conditionx-item_no = 10.
t_item_conditionx-serial_id = t_item_condition_s-serial_id.
t_item_conditionx-cond_count = t_item_condition_s-cond_count.
t_item_conditionx-cond_value = 'X'.
APPEND t_item_conditionx.


CALL FUNCTION ' BAPI_CONTRACT_CHANGE'
  EXPORTING
    purchasingdocument = v_po
  TABLES
    item_condition     = t_item_condition
    item_conditionx    = t_item_conditionx
    return             = t_return.


CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
  EXPORTING
    wait = 'X'.

I am trying to change condition value to '51' of contract '4600000001'.

8 REPLIES 8

marcelom_bovo
Participant

Here is the program I've made to test the BAPI:


DATA: v_po TYPE bapimeoutheader-number VALUE '4600000001'.
DATA: t_item  TYPE TABLE OF bapimeoutitem WITH HEADER LINE,
      t_itemx TYPE TABLE OF bapimeoutitemx WITH HEADER LINE,
      t_item_condition  TYPE TABLE OF bapimeoutcondition WITH HEADER LINE,
      t_item_condition_s  TYPE TABLE OF bapimeoutcondition WITH HEADER LINE,
      t_item_conditionx TYPE TABLE OF bapimeoutconditionx WITH HEADER LINE,
      t_item_cond_validity TYPE TABLE OF bapimeoutvalidity WITH HEADER LINE,
      t_item_cond_validityx TYPE TABLE OF bapimeoutvalidityx WITH HEADER LINE,
      t_return  TYPE TABLE OF bapiret2 WITH HEADER LINE.



CALL FUNCTION 'BAPI_CONTRACT_GETDETAIL'
  EXPORTING
    purchasingdocument = v_po
    item_data          = 'X'
    condition_data     = 'X'
  TABLES
    item               = t_item
    item_cond_validity = t_item_cond_validity
    item_condition     = t_item_condition_s
    return             = t_return.


READ TABLE t_item_condition_s INDEX 1.
READ TABLE t_item_cond_validity INDEX 1.

t_item_cond_validityx-serial_id = t_item_condition_s-serial_id.
t_item_cond_validityx-item_no = 10.

APPEND t_item_cond_validityx.

t_item_condition-item_no = 10.
t_item_condition-cond_value = 51.
t_item_condition-serial_id = t_item_condition_s-serial_id.
t_item_condition-cond_count = t_item_condition_s-cond_count.
*T_ITEM_CONDITION-COND_TYPE = 'PB00'.
t_item_condition-change_id = 'U'.
APPEND t_item_condition.

t_item_conditionx-item_no = 10.
t_item_conditionx-serial_id = t_item_condition_s-serial_id.
t_item_conditionx-cond_count = t_item_condition_s-cond_count.
t_item_conditionx-cond_value = 'X'.
APPEND t_item_conditionx.


CALL FUNCTION ' BAPI_CONTRACT_CHANGE'
  EXPORTING
    purchasingdocument = v_po
  TABLES
    item_condition     = t_item_condition
    item_conditionx    = t_item_conditionx
    return             = t_return.


CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
  EXPORTING
    wait = 'X'.

I am trying to change condition value to '51' of contract '4600000001'.

0 Kudos

You have to pass the value X to which you want to change the value.

read the BAPI documentation.

CALL FUNCTION 'BAPI_CONTRACT_GETDETAIL'
  EXPORTING
    purchasingdocument = v_po
    item_data          = 'X'
    condition_data     = 'X'
  TABLES
    item               = t_item
     itemx                       = i_itemx
    item_cond_validity = t_item_cond_validity
    item_condition     = t_item_condition_s
    item_conditionx             = i_item_conditionx
    return             = t_return.

0 Kudos

Hi Naresh,

thanks for reply,

I am using X table, you have seen the wrong BAPI(wich I use to get contract data).


CALL FUNCTION 'BAPI_CONTRACT_CHANGE'
  EXPORTING
    purchasingdocument = v_po
  TABLES
    item_condition     = t_item_condition
    item_conditionx    = t_item_conditionx
    return             = t_return.

See the program above again.

tks

0 Kudos

Pass the validity internal table values also

CALL FUNCTION 'BAPI_CONTRACT_CHANGE'
  EXPORTING
    purchasingdocument = v_po
  TABLES
    ITEM_COND_VALIDITY = t_item_cond_validity
    ITEM_COND_VALIDITYX = t_item_cond_validityx
    item_condition     = t_item_condition
    item_conditionx    = t_item_conditionx
    return             = t_return.

0 Kudos

Hi Naresh,

Thank you.

Now it's ok.

I'm passing ITEM_COND_VALIDITY(don't need X, but give a W message) and I also have to pass the entire ITEM_CONDITION data, not just the ones I wanna change(In this case is COND_VALUE).

Thanks for your help

Louis-Arnaud
Participant
0 Kudos

Hello,

I know this is an old post, but I'm facing the same problem and it seems that you managed to resolved it.

I want to change a condition value. I understand that I need to send condtion validity (which is the same). I understand that I need to send all item condition data (and X structure completely filled ?).

But I got a short dump (duplicate key...). It seems that whatever I tried, the BAPI try to insert a new record instead of update it. If someone can help me with this...

0 Kudos

Hello Louis,

Unfortunately I don't remember very well what I did, but reading the thread I came to the conclusion the table item_conditionX is not needed, just the other one with the data. you should try that

0 Kudos

Thank you for having taking the time to answer me.

I came to the conclusion that the BAPI is not able to change the value for the exact same validity period. I managed to do it by adding an enhancement to force the update flag at the end of the process... Dirty.