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: 
Read only

BAPI_PO_CHANGE

Former Member
0 Likes
3,152

HI,

I am using this bapi to set the delivery completed and final invoice indicator for a single PO.

But iam unable to change it, is there any thing wrong in the program code, i meant in passing the parameters.

Please help me out.

REPORT ZCLOSEPO .

data: ls_POITEM like BAPIMEPOITEM occurs 0 with header line,

ls_POITEMX like BAPIMEPOITEMX occurs 0 with header line,

ls_t_return like BAPIRET2 occurs 0 with header line,

ls_purchaseorder like BAPIMEPOHEADER,

ls_poheader like BAPIMEPOHEADER,

ls_poheaderx like BAPIMEPOHEADERX.

DATA : l_msgty TYPE c,

l_msgid(2) TYPE c,

l_msgno(3) TYPE c,

l_msgtx(100) TYPE c,

l_errflag TYPE c.

clear: ls_t_return,

ls_poitem,

ls_poitemx.

ls_purchaseorder-PO_NUMBER = '0000404026'.

ls_poheader-PO_NUMBER = '0000404026'.

ls_poheaderx-PO_NUMBER = '0000404026'.

ls_poitem-PO_ITEM = '00010'.

ls_poitem-NO_MORE_GR = 'X'.

ls_poitem-final_inv = 'X'.

ls_poitem-MATERIAL = '989888'.

APPEND ls_poitem.

ls_poitemx-po_item = '00010'.

ls_poitemx-po_itemx = 'U'.

ls_poitemx-no_more_gr = 'X'.

ls_poitemx-final_inv = 'X'. "Final invoice

ls_poitem-MATERIAL = 'X'.

APPEND ls_poitemx.

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

purchaseorder = '0000404026'

poheader = '0000404026'

poheaderx = '0000404026'

TABLES

RETURN = ls_t_return

POITEM = ls_poitem

POITEMX = ls_poitemx.

LOOP AT ls_t_return.

CLEAR: l_msgty, l_msgid, l_msgno, l_msgtx.

l_msgty = ls_t_return-type.

l_msgid = ls_t_return-id.

l_msgno = ls_t_return-number.

l_msgtx = ls_t_return-message.

WRITE: / l_msgty, l_msgid, l_msgno, l_msgtx.

Endloop.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

1 ACCEPTED SOLUTION
Read only

Former Member
2,688

Hi,

Are you changing a PO or an RFQ??

The sample code I provided worked fine for PO..

Thanks,

Naren

HI,

I am using this bapi to set the delivery completed and final invoice indicator for a single PO.

But iam unable to change it, is there any thing wrong in the program code, i meant in passing the parameters.

Please help me out.

REPORT ZCLOSEPO .

data: ls_POITEM like BAPIMEPOITEM occurs 0 with header line,

ls_POITEMX like BAPIMEPOITEMX occurs 0 with header line,

ls_t_return like BAPIRET2 occurs 0 with header line,

ls_purchaseorder like BAPIMEPOHEADER,

ls_poheader like BAPIMEPOHEADER,

ls_poheaderx like BAPIMEPOHEADERX.

DATA : l_msgty TYPE c,

l_msgid(2) TYPE c,

l_msgno(3) TYPE c,

l_msgtx(100) TYPE c,

l_errflag TYPE c.

clear: ls_t_return,

ls_poitem,

ls_poitemx.

ls_purchaseorder-PO_NUMBER = '0000404026'.

ls_poheader-PO_NUMBER = '0000404026'.

ls_poheaderx-PO_NUMBER = '0000404026'.

ls_poitem-PO_ITEM = '00010'.

ls_poitem-NO_MORE_GR = 'X'.

ls_poitem-final_inv = 'X'.

ls_poitem-MATERIAL = '989888'.

APPEND ls_poitem.

ls_poitemx-po_item = '00010'.

ls_poitemx-po_itemx = 'U'.

ls_poitemx-no_more_gr = 'X'.

ls_poitemx-final_inv = 'X'. "Final invoice

ls_poitem-MATERIAL = 'X'.

APPEND ls_poitemx.

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

purchaseorder = '0000404026'

poheader = '0000404026'

poheaderx = '0000404026'

TABLES

RETURN = ls_t_return

POITEM = ls_poitem

POITEMX = ls_poitemx.

LOOP AT ls_t_return.

CLEAR: l_msgty, l_msgid, l_msgno, l_msgtx.

l_msgty = ls_t_return-type.

l_msgid = ls_t_return-id.

l_msgno = ls_t_return-number.

l_msgtx = ls_t_return-message.

WRITE: / l_msgty, l_msgid, l_msgno, l_msgtx.

Endloop.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

8 REPLIES 8
Read only

Former Member
0 Likes
2,688

Hi,

The changes are marked in bold..

REPORT ZCLOSEPO .

data: ls_POITEM like BAPIMEPOITEM occurs 0 with header line,

ls_POITEMX like BAPIMEPOITEMX occurs 0 with header line,

ls_t_return like BAPIRET2 occurs 0 with header line,

ls_purchaseorder like BAPIMEPOHEADER,

ls_poheader like BAPIMEPOHEADER,

ls_poheaderx like BAPIMEPOHEADERX.

DATA : l_msgty TYPE c,

l_msgid(2) TYPE c,

l_msgno(3) TYPE c,

l_msgtx(100) TYPE c,

l_errflag TYPE c.

clear: ls_t_return,

ls_poitem,

ls_poitemx.

<b>*ls_purchaseorder-PO_NUMBER = '0000404026'.

*ls_poheader-PO_NUMBER = '0000404026'.

*ls_poheaderx-PO_NUMBER = '0000404026'.</b>

ls_poitem-PO_ITEM = '00010'.

ls_poitem-NO_MORE_GR = 'X'.

ls_poitem-final_inv = 'X'.

<b>*ls_poitem-MATERIAL = '989888'</b>.

APPEND ls_poitem.

ls_poitemx-po_item = '00010'.

ls_poitemx-po_itemx = '<b>X</b>'.

ls_poitemx-no_more_gr = 'X'.

ls_poitemx-final_inv = 'X'. "Final invoice

<b>*ls_poitem-MATERIAL = 'X'.</b>

APPEND ls_poitemx.

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

purchaseorder = '0000404026'

<b>*poheader = '0000404026'

*poheaderx = '0000404026'</b>

TABLES

RETURN = ls_t_return

POITEM = ls_poitem

POITEMX = ls_poitemx.

LOOP AT ls_t_return.

CLEAR: l_msgty, l_msgid, l_msgno, l_msgtx.

l_msgty = ls_t_return-type.

l_msgid = ls_t_return-id.

l_msgno = ls_t_return-number.

l_msgtx = ls_t_return-message.

WRITE: / l_msgty, l_msgid, l_msgno, l_msgtx.

Endloop.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

Thanks,

Naren

Read only

Former Member
0 Likes
2,688

Hi,

Also check this sample code..

PARAMETERS: p_ebeln LIKE ekko-ebeln OBLIGATORY.

PARAMETERS: p_ebelp LIKE ekpo-ebelp OBLIGATORY.

DATA: t_item LIKE bapimepoitem OCCURS 0 WITH HEADER LINE.

DATA: t_itemx LIKE bapimepoitemx OCCURS 0 WITH HEADER LINE.

DATA: t_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

t_item-po_item = p_ebelp.

t_item-no_more_gr = 'X'.

t_item-final_inv = 'X'.

APPEND t_item.

t_itemx-po_item = p_ebelp.

t_itemx-po_itemx = 'X'.

t_itemx-no_more_gr = 'X'.

t_itemx-final_inv = 'X'.

APPEND t_itemx.

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

purchaseorder = p_ebeln

TABLES

return = t_return

poitem = t_item

poitemx = t_itemx.

LOOP AT t_return WHERE type = 'A' OR type = 'E'.

EXIT.

ENDLOOP.

IF sy-subrc = 0.

WRITE: / 'FAILED'.

ELSE.

WRITE: / 'SUCCESS'.

COMMIT WORK.

ENDIF.

Thanks,

Naren

Read only

2,688

Hi I got this erroe mesaage when executed the program with the changes!

E ME 616 Not possible to process an RFQ using this function

Read only

Former Member
0 Likes
2,688

Hi,

Please reward points for helpful answers and close the thread if the problem is solved..

Thanks,

Naren

Read only

0 Likes
2,688

Hi Naren,

Error - E ME 616 Not possible to process an RFQ using this function while using BAPI_PO_CHANGE.

I would like to update the custom fields in ME43,ME42,ME41, i have added the custom fields at header(ekko) and item(ekpo) and at screen level using customer exit.

My requirement is to update the custom fields through bapi which i have added.

Please if you know can you share your solution

Thanks,

Gayathri.

Read only

OwenLiu
Product and Topic Expert
Product and Topic Expert
0 Likes
2,688

Thanks for coming to SAP Community for answers. Please post your question as a new question here:
https://answers.sap.com/questions/ask.html Since you're new in asking questions here, check out our tutorial about asking and answering questions (if you haven't already), as it provides tips for preparing questions more effectively, that draw responses from our members. Please note, that your post here won't be answered.

Best Regards,
Owen Liu
Read only

Former Member
2,689

Hi,

Are you changing a PO or an RFQ??

The sample code I provided worked fine for PO..

Thanks,

Naren

Read only

0 Likes
2,688

Dear Narendran,

I am using the BAPI_PO_CHANGE for closing the PO's, it is working fine but if the PO is set to Invoice Receipt = 'X', then it is throiwng the error indicator for invoice receipt used not allowed.Please help me on this. It is affecting the Productivity as they have close multiple PO's byt month end.