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: 

BAPI_PO_Change

Former Member
0 Kudos

Hello everyone,

I am trying to use BAPI_PO_Change in an enhancement of tcode MB01, the field in the po line item is changed and logged and could be found in the Tcode ME22n->MENU->Environment-> ITEM CHANGES. But the PO is not changed, hence the field change is not seen when viewed in ME22n because the database is not commited or updated.

The BAPI return message is also success and says PO is changed, but PO is not changed.

How can i change and update the PO.....

Thanks,

Uma.

5 REPLIES 5

Former Member
0 Kudos

Hi Uma,

Normally this should not happen. Just make sure while calling the BAPI, TESTRUN is empty.

And also try to use COMMIT WORK after calling BAPI.

Regards,

Amit Mittal.

0 Kudos

Hello Amit,

I introduced enhancement ZMB01_MARK_ELIKZ in the include MM07MFS0_SEGMENTDATEN_EK_SETZE

I executed in foreground MB01, ELIKZ flag is set and PO changed successfully...When i tried to update the PO by idoc processing using WE19, against tcode MB01, the PO log has ELIKZ changed but the PO not changed and hence ELIKZ flag is not updated in PO.

Please refer to the below code ...Is there any other factors to consider when processing BAPI.....

form segmentdaten_ek_setzen.

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$SE:(1 ) Form SEGMENTDATEN_EK_SETZEN, Start D

$$-Start: (1 )----

-


$$

ENHANCEMENT 372 ZMB01_MARK_ELIKZ. "active version

data l_ebeln type ekko-ebeln.

data :

i_return TYPE bapiret2 OCCURS 0 WITH HEADER LINE,

s_bapimepoheader TYPE bapimepoheader,

s_bapimepoheaderx TYPE bapimepoheaderx,

s_bapimepoitem TYPE bapimepoitem occurs 0 with header line,

s_bapimepoitemX TYPE bapimepoitemX occurs 0 with header line.

if sy-dynnr = '0200' or sy-tcode = 'WE19' or sy-tcode = 'MB01' .

select single ebeln from ekko into l_ebeln where ebeln = xebefu-ebeln and bsart = 'ZNB'.

if sy-subrc = 0.

if xebefu-elikz <> 'X'.

xebefu-elikz = 'X'.

*Mark DCI flag for every line item

s_bapimepoheaderx-po_number = XEBEFU-EBELN.

s_bapimepoheader-po_number = XEBEFU-EBELN.

s_bapimepoitemx-po_item = XEBEFU-EBELP.

s_bapimepoitem-po_item = XEBEFU-EBELP.

s_bapimepoitemx-NO_MORE_GR = 'X'.

s_bapimepoitem-NO_MORE_GR = 'X'.

append s_bapimepoitem.

clear s_bapimepoitem.

append s_bapimepoitemx.

clear s_bapimepoitemx.

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

PURCHASEORDER = XEBEFU-EBELN

TABLES

return = i_return

poitem = s_bapimepoitem

poitemx = s_bapimepoitemx.

*Message types: S Success, E Error, W Warning, I Info, A Abort

*Supress all Warning Messages

DELETE i_return WHERE ( TYPE EQ 'W' ).

read table i_return with key type = 'E'.

if sy-subrc eq 0.

Message E900(M7) with XEBEFU-EBELN XEBEFU-EBELP.

endif.

refresh : s_bapimepoitem,s_bapimepoitemx.

endif.

endif.

endif.

ENDENHANCEMENT.

$$-End: (1 )----

-


$$

data: l_k_mseg type mseg. " 979280

if xebefu-bsmng is initial and not xebefu-netwr is initial.

message e187.

  • Die Bestellung enthält einen Wert ohne Menge

endif.

Thanks for your time....

0 Kudos

Hi Uma,

Check the execution by passing the below parameter aswell

s_bapimepoitemx-PO_ITEMX = 'X'.

As i see you are not pasing the same.

Regards,

Deepak.

Former Member
0 Kudos

Hi Uma,

Fisrt try to get the details of PO that you want to change by using BAPI BAPI_PO_GETDETAIL1 , there you will get POSCHEDULE table . Then update this table with the data that you need to update and build the table POSCHEDULEX with PO_ITEMX and the field that you need to udate with 'X' an use in BAPI BAPI_PO_CHANGE . Then use BAPI_TRANSACTION_COMMIT.

We used same solution to update the scheduled delivery line items in PO

Please let me know if you need any further information

Regards,

Snehal Patil

0 Kudos

Hi Snehal,

Thanks for your reply...As the issue is mainly of handling the PO & GR through MB01 via IDOC, i decided to fix the same in the Inbound FM of idoc...So wrote enhancement as below : and is working fine.

ENHANCEMENT 5 ZWE19_MARK_ELIKZ. "active version

data l_ebeln type ekko-ebeln.

data l_ebelp type ekpo-ebelp.

data wa_hdr type E1MBXYH.

data wa_itm type E1MBXYI.

clear : wa_hdr, wa_itm, l_ebeln, l_ebelp.

if sy-tcode = 'WE19' .

loop at idoc_data.

CASE idoc_data-segnam.

WHEN 'E1MBXYH'.

wa_hdr = idoc_data-sdata.

WHEN 'E1MBXYI'.

wa_itm = idoc_data-sdata.

if wa_hdr-XBLNR is not initial and wa_hdr-tcode = 'MB01' and wa_itm-ebeln is not initial .

select single ebeln from ekko into l_ebeln where ebeln = wa_itm-ebeln and bsart = 'ZNB'.

if sy-subrc = 0.

wa_itm-elikz = 'X'.

idoc_data-sdata = wa_itm.

modify idoc_data .

endif.

endif.

ENDCASE.

endloop.

endif.

ENDENHANCEMENT.