cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI_PO_CHANGE - Change conditions price TBA1

daniel_pietrosz
Explorer
0 Kudos

Hey, I need to change the TBA1 condition for PO type LB. I want to change the KWERT prize in KONV. The condition is deleted first and then new. I change CONBASEVAL, but KWERT is still the same. What should I do? Thank you for your advice.

DATA : lt_return TYPE TABLE OF bapiret2,
         lt_cond TYPE TABLE OF bapimepocond,
         ls_cond TYPE bapimepocond,
         lt_condx TYPE TABLE OF bapimepocondx,
         ls_condx TYPE bapimepocondx,
         l_testrun TYPE flag VALUE ''.
		 
*--Delete old conditions TBA1------------------------------------------------------------------*
         ls_cond-itm_number   = l_ebelp.
         ls_cond-condition_no = l_knumv.
         ls_cond-cond_st_no   = ls_konv-stunr.
         ls_cond-cond_count   = ls_konv-zaehk.
         ls_cond-cond_type    = ls_konv-kschl.
         ls_cond-change_id    = 'D'.
         APPEND ls_cond TO lt_cond.
   
         ls_condx-itm_number   = l_ebelp.
         ls_condx-condition_no = l_knumv.
         ls_condx-cond_st_no    = ls_konv-stunr.
         ls_condx-cond_count    = 'X'.
         ls_condx-cond_type     = 'X'.
         ls_condx-change_id    = 'X'.
         APPEND ls_condx TO lt_condx.
*--Insert new conditions TBA1------------------------------------------------------------------*
         CLEAR: ls_cond, ls_condx.
 
         ls_cond-itm_number   = l_ebelp.
         ls_cond-condition_no = l_knumv.
         ls_cond-cond_st_no   = '100'.
         ls_cond-cond_count   = '01'.
 
         IF ls_mbew-vprsv EQ 'S'.
           ls_cond-conbaseval = ls_mbew-stprs.
           ls_cond-scalbasval = ls_mbew-stprs.
         ELSEIF ls_mbew-vprsv EQ 'V'.
           ls_cond-conbaseval   = ls_mbew-verpr.
           ls_cond-scalbasval   = ls_mbew-verpr.
         ENDIF.
         ls_cond-cond_value = '2'.
 
         ls_cond-calctypcon   = 'A'.
         ls_cond-cond_type    = ls_konv-kschl.
         ls_cond-stat_con     = 'X'.
         ls_cond-change_id    = 'I'.
         APPEND ls_cond TO lt_cond.
 
         ls_condx-itm_number   = l_ebelp.
         ls_condx-condition_no = l_knumv.
         ls_condx-cond_st_no   = '100'.
         ls_condx-cond_count   = 'X'.
         ls_condx-conbaseval   = 'X'.
         ls_condx-calctypcon   = 'X'.
         ls_condx-cond_value   = 'X'.
         ls_condx-cond_type    = 'X'.
         ls_condx-change_id    = 'X'.
         ls_condx-stat_con     = 'X'.
         APPEND ls_condx TO lt_condx.
*--------------------------------------------------------------------*
    CALL FUNCTION 'BAPI_PO_CHANGE'
      EXPORTING
        PURCHASEORDER = i_mseg-ebeln
        TESTRUN       = l_testrun
      TABLES
        RETURN        = lt_return
        POITEM        = lt_poitem
        POITEMX       = lt_poitemx
*       POSCHEDULE    =
*       POSCHEDULEX   =
        POCOND        = lt_cond
        POCONDX       = lt_condx
     .
	 
	 COMMIT WORK AND WAIT.

Thank for any answer.

Accepted Solutions (0)

Answers (1)

Answers (1)

JL23
Active Contributor
0 Kudos

Where shall we the MM and purchasing consultants, who have no hands on your system, start?

If you have trouble in the ABAP then the tag for ABAP development would have been more relevance than MM and purchasing.

Have you tried your desire already manually in ME22N? Is it possible there or not?

We have no insight in your variables, we cannot know whether standard price and moving average price in your material master are equal by chance and you can't see an effect because of this circumstance.

Your code does not at all show how the variables get filled.

A screenshot from the conditions screen of your PO from before and after could eventually help.

A screenshot from a debugger session showing the values of the variables.

A screenshot from definition of condition TBA1 since it is not standard.

An explanation why another field KWERT in the same condition should change automatically based on the value in CONBASEVAL