Application Development and Automation 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: 

BAPI_PO_CHANGE

Former Member
0 Kudos
1,075

Hi Experts!

I have a little problem,

When I try to modify the conditions of a PO, using the BAPI BAPI_PO_CHANGE and I see it using transaction ME23N, some of the header conditions appear duplicated,

For example,

The header condition ZFLE appear twice, one with condition value and the other without condition value (value = 0).

Can U help me?

7 REPLIES 7

Former Member
0 Kudos
346

This is your ABAP code bug.

Former Member
0 Kudos
346

show your coding..?

Former Member
0 Kudos
346

Hi,

*first I get the PO Detail

CALL FUNCTION 'BAPI_PO_GETDETAIL1'

EXPORTING

purchaseorder = ekko-ebeln

  • ACCOUNT_ASSIGNMENT = ' '

  • ITEM_TEXT = ' '

  • HEADER_TEXT = ' '

  • DELIVERY_ADDRESS = ' '

  • VERSION = ' '

  • SERVICES = ' '

IMPORTING

poheader = poheader

poexpimpheader = poexpimpheader

TABLES

return = return

poitem = poitem

poaddrdelivery = poaddrdelivery

poschedule = poschedule

poaccount = poaccount

pocondheader = pocondheader

pocond = pocond

polimits = polimits

pocontractlimits = pocontractlimits

poservices = poservices

posrvaccessvalues = posrvaccessvalues

potextheader = potextheader

potextitem = potextitem

poexpimpitem = poexpimpitem

pocomponents = pocomponents

poshippingexp = poshippingexp

pohistory = pohistory

pohistory_totals = pohistory_totals

poconfirmation = poconfirmation

allversions = allversions

popartner = popartner

extensionout = extensionout.

*Then I delete the 'Z' Header Conditions

LOOP AT pocondheader.

IF pocondheader-cond_type(1) = 'Z'.

MOVE: pocondheader-condition_no TO pocondheaderx-condition_no,

pocondheader-itm_number TO pocondheaderx-itm_number,

pocondheader-cond_st_no TO pocondheaderx-cond_st_no.

MOVE 'D' TO pocondheader-change_id. "DELETE

MOVE 'X' TO pocondheaderx-change_id.

MODIFY pocondheader.

CLEAR pocondheader.

APPEND pocondheaderx.

CLEAR pocondheaderx.

ENDIF.

ENDLOOP.

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

purchaseorder = ekko-ebeln

  • POHEADER =

  • POHEADERX =

  • POADDRVENDOR =

testrun = ' '

  • MEMORY_UNCOMPLETE =

  • MEMORY_COMPLETE =

  • POEXPIMPHEADER =

  • POEXPIMPHEADERX =

  • VERSIONS =

  • NO_MESSAGING =

  • NO_MESSAGE_REQ =

  • NO_AUTHORITY =

  • NO_PRICE_FROM_PO =

IMPORTING

expheader = poheader

exppoexpimpheader = poexpimpheader

TABLES

return = return

  • POITEM =

  • POITEMX =

  • POADDRDELIVERY =

  • POSCHEDULE =

  • POSCHEDULEX =

  • POACCOUNT =

  • POACCOUNTPROFITSEGMENT =

  • POACCOUNTX =

pocondheader = pocondheader

pocondheaderx = pocondheaderx

  • pocond = pocond

  • pocondx = pocondx

  • POLIMITS =

  • POCONTRACTLIMITS =

  • POSERVICES =

  • POSRVACCESSVALUES =

  • POSERVICESTEXT =

  • EXTENSIONIN =

  • EXTENSIONOUT =

  • POEXPIMPITEM =

  • POEXPIMPITEMX =

  • POTEXTHEADER =

  • POTEXTITEM =

  • ALLVERSIONS =

  • POPARTNER =

  • POCOMPONENTS =

  • POCOMPONENTSX =

  • POSHIPPING =

  • POSHIPPINGX =

  • POSHIPPINGEXP =

  • POHISTORY =

  • POHISTORY_TOTALS =

  • POCONFIRMATION =

.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' .

CALL FUNCTION 'DEQUEUE_ALL'.

  • Using a Table Control I create the new Header Conditions

LOOP AT ti_cond WHERE kbert NE 0.

CLEAR t685a.

SELECT SINGLE * FROM t685a

WHERE kschl EQ ti_cond-kschl

AND kappl EQ 'M'.

CLEAR lfm1.

SELECT SINGLE * FROM lfm1

WHERE lifnr EQ ekko-lifnr

AND ekorg EQ ekko-ekorg.

CLEAR tmks.

SELECT SINGLE * FROM tmks

WHERE kalsk EQ lfm1-kalsk.

CLEAR t683s.

SELECT SINGLE * FROM t683s

WHERE kschl EQ ti_cond-kschl

AND kappl EQ 'M'

AND kalsm EQ tmks-kalsm.

  • BREAK-POINT.

pocondheader-condition_no = ekko-knumv.

pocondheader-itm_number = '000000'.

pocondheader-cond_st_no = t683s-stunr. " Número de nivel

pocondheader-cond_count = t683s-zaehk."contador

pocondheader-cond_type = ti_cond-kschl."Clase de cond

IF ti_cond-koein EQ '%'.

pocondheader-cond_value = ti_cond-kbert * 100. "valor

ELSE.

pocondheader-cond_value = ti_cond-kbert. "valor

ENDIF.

pocondheader-cond_value = ti_cond-kbert. "valor

pocondheader-currency = ti_cond-koein.

pocondheader-currency_iso = ti_cond-koein.

pocondheader-applicatio = 'M'.

APPEND pocondheader.

CLEAR pocondheader.

pocondheaderx-condition_no = ekko-knumv.

pocondheaderx-itm_number = '000000'.

pocondheaderx-cond_st_no = t683s-stunr. " Número de nivel

pocondheaderx-cond_count = 'X'."contador

pocondheaderx-cond_type = 'X'."Clase de cond

pocondheaderx-cond_value = 'X'. "valor

pocondheaderx-currency = 'X'. "ti_cond-KOEIN

pocondheaderx-currency_iso = 'X'. "ti_cond-KOEIN

pocondheaderx-applicatio = 'X'.

APPEND pocondheaderx.

CLEAR pocondheaderx.

ENDLOOP.

  • and Modify the PO

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

purchaseorder = ekko-ebeln

  • POHEADER =

  • POHEADERX =

  • POADDRVENDOR =

testrun = ' '

  • MEMORY_UNCOMPLETE =

  • MEMORY_COMPLETE =

  • POEXPIMPHEADER =

  • POEXPIMPHEADERX =

  • VERSIONS =

  • NO_MESSAGING =

  • NO_MESSAGE_REQ =

  • NO_AUTHORITY =

  • NO_PRICE_FROM_PO =

IMPORTING

expheader = poheader

exppoexpimpheader = poexpimpheader

TABLES

return = return

  • POITEM =

  • POITEMX =

  • POADDRDELIVERY =

  • POSCHEDULE =

  • POSCHEDULEX =

  • POACCOUNT =

  • POACCOUNTPROFITSEGMENT =

  • POACCOUNTX =

pocondheader = pocondheader

pocondheaderx = pocondheaderx

  • pocond = pocond

  • pocondx = pocondx

  • POLIMITS =

  • POCONTRACTLIMITS =

  • POSERVICES =

  • POSRVACCESSVALUES =

  • POSERVICESTEXT =

  • EXTENSIONIN =

  • EXTENSIONOUT =

  • POEXPIMPITEM =

  • POEXPIMPITEMX =

  • POTEXTHEADER =

  • POTEXTITEM =

  • ALLVERSIONS =

  • POPARTNER =

  • POCOMPONENTS =

  • POCOMPONENTSX =

  • POSHIPPING =

  • POSHIPPINGX =

  • POSHIPPINGEXP =

  • POHISTORY =

  • POHISTORY_TOTALS =

  • POCONFIRMATION =

.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' .

CALL FUNCTION 'DEQUEUE_ALL'.

*

When I see the PO using ME23N

Some of these header conditions appear duplicated

Thaks for your help

Former Member
0 Kudos
346

Any suggest?

Thanks.

0 Kudos
346

Hi,

There is a option called CHANGE ID- I ,U, D in BAPI_PO_CHANGE

in every condition types add this option

I- means Insert, if previously condition type is not thr,

U- means update, if previously condition type is thr

D- means delete, if previously condition type u want to delete

Former Member

Former Member
0 Kudos
346

Hey Francisco,

Could you solve the problem?

If you resolved this, can you tell me how you did it, because I have the same problem please.

Thanks!!!!