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
595

Hello ABAPers,

I'm trying to update the PO using BAPI_PO_CHANGE. the code is as below.

FORM run_bapi .

CLEAR : ipoheader, ipoheader[], ipoheaderx, ipoheaderx[],ipoitem,ipoitem[].

CLEAR : ipoitemx,ipoitemx[],ipocond, ipocond[],ipocondx, ipocondx[],ireturn.

LOOP AT itab.

DATA : vebelp LIKE ekpo-ebelp.

DATA : vkposn TYPE kposn.

CLEAR : vebelp, vkposn .

CLEAR : ipoheader,ipoheaderx, ipoitem,ipoitemx,ipocond,ipocondx.

ipoheader-po_number = itab-ebeln.

ipoheader-our_ref = '1'.

ipoheader-ref_1 = '1'.

APPEND ipoheader.

ipoheaderx-po_number = 'X'.

ipoheaderx-our_ref = 'X'.

ipoheaderx-ref_1 = 'X'.

APPEND ipoheaderx.

WHILE vebelp < itab-ebelp.

vebelp = vebelp + 10.

vkposn = vkposn + 10.

READ TABLE itab2 WITH KEY ebeln = itab-ebeln ebelp = vebelp.

IF sy-subrc = 0.

ipoitem-po_item = itab2-ebelp.

  • ipoitem-conf_ctrl = '0001'.

ipoitem-val_type = itab2-bwtar.

IF itab2-bwtar = 'BOUGHT OUT'.

ipoitem-calctype = 'B'.

ELSE.

ipoitem-calctype = 'A'.

ENDIF.

APPEND ipoitem.

ipoitemx-po_item = itab2-ebelp.

ipoitemx-po_itemx = 'X'.

  • ipoitemx-conf_ctrl = 'X'.

ipoitemx-val_type = 'X'.

ipoitemx-calctype = 'X'.

APPEND ipoitemx.

IF itab2-bwtar = 'BOUGHT OUT'.

ipocond-itm_number = itab2-ebelp.

ipocond-cond_type = 'ZEXP'.

ipocond-cond_value = 0.

ipocond-calctypcon = 'B'.

  • ipocond-change_id = 'U'.

APPEND ipocond.

ipocondx-itm_number = itab2-ebelp.

ipocondx-itm_numberx = 'X'.

ipocondx-cond_type = 'X'.

ipocondx-cond_value = 'X'.

ipocondx-calctypcon = 'X'.

  • ipocondx-change_id = 'X'.

APPEND ipocondx.

ELSE.

ipocond-itm_number = itab2-ebelp.

ipocond-calctypcon = 'A'.

APPEND ipocond.

ipocondx-itm_number = itab2-ebelp.

ipocondx-itm_numberx = 'X'.

ipocondx-calctypcon = 'X'.

APPEND ipocondx.

ENDIF.

CLEAR: ipoitem,ipoitemx.

CLEAR: ipocond,ipocondx.

ENDIF.

CLEAR : itab2.

ENDWHILE.

CLEAR: itab, itab2.

ENDLOOP.

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

purchaseorder = ipoheader-po_number

poheader = ipoheader

poheaderx = ipoheaderx

TABLES

return = ireturn

poitem = ipoitem

poitemx = ipoitemx

pocond = ipocond

pocondx = ipocondx

.

  • SORT ireturn BY type.

  • READ TABLE ireturn WITH KEY type = 'E' BINARY SEARCH TRANSPORTING no field.

  • IF sy-subrc = 0.

  • itab-flag = 'E'.

  • itab-err_msg = 'Valuation Type not updated.'.

  • ELSE.

  • CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

  • itab-flag = 'S'.

  • itab-err_msg = 'Valuation Type updated successfully.'.

  • ENDIF.

  • MODIFY itab TRANSPORTING flag err_msg.

  • CLEAR: itab, itab2.

  • ENDLOOP.

*BREAK-POINT.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

ENDFORM. " RUN_BAPI

when I execute the above code, system put the Lock entry for PO and it got hanged. it show successfull of po change but not changes happens in PO Data.

Pl help.

regards,

rrsuthar

Hello ABAPers,

I'm trying to update the PO using BAPI_PO_CHANGE. the code is as below.

FORM run_bapi .

CLEAR : ipoheader, ipoheader[], ipoheaderx, ipoheaderx[],ipoitem,ipoitem[].

CLEAR : ipoitemx,ipoitemx[],ipocond, ipocond[],ipocondx, ipocondx[],ireturn.

LOOP AT itab.

DATA : vebelp LIKE ekpo-ebelp.

DATA : vkposn TYPE kposn.

CLEAR : vebelp, vkposn .

CLEAR : ipoheader,ipoheaderx, ipoitem,ipoitemx,ipocond,ipocondx.

ipoheader-po_number = itab-ebeln.

ipoheader-our_ref = '1'.

ipoheader-ref_1 = '1'.

APPEND ipoheader.

ipoheaderx-po_number = 'X'.

ipoheaderx-our_ref = 'X'.

ipoheaderx-ref_1 = 'X'.

APPEND ipoheaderx.

WHILE vebelp < itab-ebelp.

vebelp = vebelp + 10.

vkposn = vkposn + 10.

READ TABLE itab2 WITH KEY ebeln = itab-ebeln ebelp = vebelp.

IF sy-subrc = 0.

ipoitem-po_item = itab2-ebelp.

  • ipoitem-conf_ctrl = '0001'.

ipoitem-val_type = itab2-bwtar.

IF itab2-bwtar = 'BOUGHT OUT'.

ipoitem-calctype = 'B'.

ELSE.

ipoitem-calctype = 'A'.

ENDIF.

APPEND ipoitem.

ipoitemx-po_item = itab2-ebelp.

ipoitemx-po_itemx = 'X'.

  • ipoitemx-conf_ctrl = 'X'.

ipoitemx-val_type = 'X'.

ipoitemx-calctype = 'X'.

APPEND ipoitemx.

IF itab2-bwtar = 'BOUGHT OUT'.

ipocond-itm_number = itab2-ebelp.

ipocond-cond_type = 'ZEXP'.

ipocond-cond_value = 0.

ipocond-calctypcon = 'B'.

  • ipocond-change_id = 'U'.

APPEND ipocond.

ipocondx-itm_number = itab2-ebelp.

ipocondx-itm_numberx = 'X'.

ipocondx-cond_type = 'X'.

ipocondx-cond_value = 'X'.

ipocondx-calctypcon = 'X'.

  • ipocondx-change_id = 'X'.

APPEND ipocondx.

ELSE.

ipocond-itm_number = itab2-ebelp.

ipocond-calctypcon = 'A'.

APPEND ipocond.

ipocondx-itm_number = itab2-ebelp.

ipocondx-itm_numberx = 'X'.

ipocondx-calctypcon = 'X'.

APPEND ipocondx.

ENDIF.

CLEAR: ipoitem,ipoitemx.

CLEAR: ipocond,ipocondx.

ENDIF.

CLEAR : itab2.

ENDWHILE.

CLEAR: itab, itab2.

ENDLOOP.

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

purchaseorder = ipoheader-po_number

poheader = ipoheader

poheaderx = ipoheaderx

TABLES

return = ireturn

poitem = ipoitem

poitemx = ipoitemx

pocond = ipocond

pocondx = ipocondx

.

  • SORT ireturn BY type.

  • READ TABLE ireturn WITH KEY type = 'E' BINARY SEARCH TRANSPORTING no field.

  • IF sy-subrc = 0.

  • itab-flag = 'E'.

  • itab-err_msg = 'Valuation Type not updated.'.

  • ELSE.

  • CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

  • itab-flag = 'S'.

  • itab-err_msg = 'Valuation Type updated successfully.'.

  • ENDIF.

  • MODIFY itab TRANSPORTING flag err_msg.

  • CLEAR: itab, itab2.

  • ENDLOOP.

*BREAK-POINT.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

ENDFORM. " RUN_BAPI

when I execute the above code, system put the Lock entry for PO and it got hanged. it show successfull of po change but not changes happens in PO Data.

Pl help.

regards,

rrsuthar

1 REPLY 1
Read only

Former Member
0 Likes
448

Hello,

Begin by test BAPI_PO_CHANGE with a header and one item.

If it is correct, you test with other parameters.