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 custom field does not updated

Former Member
0 Kudos

Hi Experts,

I have to populate the custom fields via BAPI 'BAPI_PO_CHANGE' but the custom fields did not update.

I refered below thread..

I have included custom fields in both custom structures CI_EKPODB and CI_EKPODBX after that I followed the sample code from above thread. Please advise me, what Iu2019m missed?

Thanks.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Since you extended the stucture CI_EKPODB, hope you want to update the item table(EKPO).

DATA: WA_BAPI_POITEM like BAPI_TE_MEPOITEM,

WA_BAPI_POITEMX like BAPI_TE_MEPOITEMX,

IT_EXTENSIONIN type standard table of BAPIPAREX,

WA_EXTENSIONIN type BAPIPAREX.

WA_BAPI_POITEM-PO_ITEM = V_EBELP. " item no

WA_BAPI_POITEM-ZZ_Field1= '0001'.

WA_BAPI_POITEM-ZZ_Field2= 'ABCD'.

WA_BAPI_POITEMX-PO_ITEM = V_EBELP. " same item no

WA_BAPI_POITEMX-ZZ_Field1= 'X'.

WA_BAPI_POITEMX-ZZ_Field1= 'X'.

*Appending to extensionin table

WA_EXTENSIONIN-STRUCTURE = 'BAPI_TE_MEPOITEM'.

WA_EXTENSIONIN-VALUEPART1 = WA_BAPI_POITEM.

append WA_EXTENSIONIN to IT_EXTENSIONIN.

clear: WA_EXTENSIONIN.

WA_EXTENSIONIN-STRUCTURE = 'BAPI_TE_MEPOITEMX'.

WA_EXTENSIONIN-VALUEPART1 = WA_BAPI_POITEMX.

append WA_EXTENSIONIN to IT_EXTENSIONIN.

finally call the bapi

call function 'BAPI_PO_CHANGE'

exporting

PURCHASEORDER = PURCHASEORDER

tables

RETURN = RETURN

POITEM = IT_POITEM

POITEMX = IT_POITEMX

EXTENSIONIN = IT_EXTENSIONIN

exceptions

others = 1.

Please use the above code. Let me know if you have any concerns.

Regards,

Sajith

10 REPLIES 10

Former Member
0 Kudos

Hi,

Since you extended the stucture CI_EKPODB, hope you want to update the item table(EKPO).

DATA: WA_BAPI_POITEM like BAPI_TE_MEPOITEM,

WA_BAPI_POITEMX like BAPI_TE_MEPOITEMX,

IT_EXTENSIONIN type standard table of BAPIPAREX,

WA_EXTENSIONIN type BAPIPAREX.

WA_BAPI_POITEM-PO_ITEM = V_EBELP. " item no

WA_BAPI_POITEM-ZZ_Field1= '0001'.

WA_BAPI_POITEM-ZZ_Field2= 'ABCD'.

WA_BAPI_POITEMX-PO_ITEM = V_EBELP. " same item no

WA_BAPI_POITEMX-ZZ_Field1= 'X'.

WA_BAPI_POITEMX-ZZ_Field1= 'X'.

*Appending to extensionin table

WA_EXTENSIONIN-STRUCTURE = 'BAPI_TE_MEPOITEM'.

WA_EXTENSIONIN-VALUEPART1 = WA_BAPI_POITEM.

append WA_EXTENSIONIN to IT_EXTENSIONIN.

clear: WA_EXTENSIONIN.

WA_EXTENSIONIN-STRUCTURE = 'BAPI_TE_MEPOITEMX'.

WA_EXTENSIONIN-VALUEPART1 = WA_BAPI_POITEMX.

append WA_EXTENSIONIN to IT_EXTENSIONIN.

finally call the bapi

call function 'BAPI_PO_CHANGE'

exporting

PURCHASEORDER = PURCHASEORDER

tables

RETURN = RETURN

POITEM = IT_POITEM

POITEMX = IT_POITEMX

EXTENSIONIN = IT_EXTENSIONIN

exceptions

others = 1.

Please use the above code. Let me know if you have any concerns.

Regards,

Sajith

0 Kudos

Hi Sajith,

The below code am using in report, please check if anything wrong.

DATA: bapi_te_mepoitem LIKE bapi_te_mepoitem,

bapi_te_mepoitemx LIKE bapi_te_mepoitemx,

l_extensionin TYPE TABLE OF bapiparex WITH HEADER LINE,

l_extensionout TYPE TABLE OF bapiparex .

bapi_te_mepoitem-po_item = '10'.

bapi_te_mepoitem-zzebeln = '0000001234'.

MOVE 'BAPI_TE_MEPOITEM' TO l_extensionin-structure.

MOVE bapi_te_mepoitem TO l_extensionin-valuepart1.

APPEND l_extensionin.

bapi_te_mepoitemx-po_item = '10'.

bapi_te_mepoitemx-zzebeln = 'X'.

MOVE 'BAPI_TE_MEPOITEMX' TO l_extensionin-structure.

MOVE bapi_te_mepoitemx TO l_extensionin-valuepart1.

APPEND l_extensionin.

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

purchaseorder = '0000023456'

TABLES

return = t_bapireturn

poitem = t_bapi_poitem

poitemx = t_bapi_poitemx

extensionin = l_extensionin

extensionout = l_extensionout.

READ TABLE t_bapireturn WITH KEY type = 'E' TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

ENDIF.

Thanks.

blent_evli
Explorer
0 Kudos

Dear Stars ;

Some BAPI needs at the end "commit work".

Check your code.

clear return_t[].

call function 'BAPI_PO_CHANGE'

exporting

purchaseorder = ebeln

tables

return = return_t

  • poitem = lt_item

  • poitemx = lt_itemx

extensionin = lt_extensionin.

commit work and wait.

Former Member
0 Kudos

Hi Stars,

The code looks fine. Is it working? let me know if you have any concerns.

Regards,

Sajith

0 Kudos

Hi Sajith,

When I change the PO with ZZEBELN value it didnu2019t update the value in EKPO, also it cleared the old value.

Thanks.

Former Member
0 Kudos

Hi Stars,

In BAPI_TE_MEPOHEADERX, How are you declaring the fields? The fields should be of same name, but of length 1(component type BAPIUPDATE). Please verify that once.

In debugging mode, come to PERFORM move_extensionin, there check whether the values are populating correctly in the internal tables cht_poitem, cht_poitemx.

Regards,

Sajith

0 Kudos

Yes Sajith.It is getting populated correctly... Any sugesstions Thanks.

0 Kudos

Hi..,

Just pass the values at zzebeln once again,

e.g.,

bapi_te_mepoitemx-po_item = '10'.

bapi_te_mepoitemx-zzebeln = ' '0000001234'.

Regards.

Former Member
0 Kudos

Hi Stars,

I don't find any reason for not updating the ekpo table.For me, the same code worked. try for some other PO number or even for different line item.

Regards,

Sajith

0 Kudos

Thanks Sajith. Solved myself but about code working correctly.