2008 Nov 04 10:38 AM
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
2008 Nov 04 12:55 PM
Hello,
Begin by test BAPI_PO_CHANGE with a header and one item.
If it is correct, you test with other parameters.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |