08-25-2022 5:46 AM
On PO screen at Item level, I want Delivery complete indicator checkbox to be tick for all open PO as i want to close all the PO's. Through ABAP Program?
In the screenshot elikz.png as I highlighted, I want all the PO to be released i.e. 'del. cmpl.' field to be marked as X automatically through ABAP program
Table Name : EKBE
Filed Name-ELIKZ
08-25-2022 7:09 AM
Hiakjayaa
Please refer to the sample program here. you can modify it as per your requirement.
LOOP AT it_po INTO wa_po.
k_tabix = sy-tabix.
PERFORM bapi_po_change.
ENDLOOP.
FORM bapi_po_change .
DATA: l_ponumber LIKE bapimepoheader-po_number,
i_po_items TYPE TABLE OF bapimepoitem WITH HEADER LINE,
i_po_itemsx TYPE TABLE OF bapimepoitemx WITH HEADER LINE,
i_return TYPE TABLE OF bapiret2 WITH HEADER LINE.
CLEAR: i_po_items, i_po_items[],
i_po_itemsx, i_po_itemsx[],
i_return, i_return[].
l_ponumber = wa_po-ebeln.
i_po_items-po_item = wa_po-ebelp.
i_po_items-deliv_compl = 'X'.
i_po_items-no_more_gr = 'X'.
i_po_itemsx-po_item = i_po_items-po_item.
i_po_itemsx-po_itemx = 'X'. "Item holds changes
i_po_itemsx-no_more_gr = 'X'.
i_po_items-conf_ctrl = '0001'.
i_po_itemsx-conf_ctrl = 'X'.
i_po_itemsx-deliv_compl = 'X'. "Deletion field is changed
APPEND: i_po_items, i_po_itemsx.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = l_ponumber
testrun = space
TABLES
poitem = i_po_items
poitemx = i_po_itemsx
return = i_return.
READ TABLE i_return WITH KEY type = 'E'.
IF sy-subrc NE 0.
wa_output-message = 'Error in Update data'.. "i_return-message.
ELSE.
wa_output-message = 'Updated..' .
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.
ENDFORM.
Regards,
Venkat
08-25-2022 7:09 AM
Hiakjayaa
Please refer to the sample program here. you can modify it as per your requirement.
LOOP AT it_po INTO wa_po.
k_tabix = sy-tabix.
PERFORM bapi_po_change.
ENDLOOP.
FORM bapi_po_change .
DATA: l_ponumber LIKE bapimepoheader-po_number,
i_po_items TYPE TABLE OF bapimepoitem WITH HEADER LINE,
i_po_itemsx TYPE TABLE OF bapimepoitemx WITH HEADER LINE,
i_return TYPE TABLE OF bapiret2 WITH HEADER LINE.
CLEAR: i_po_items, i_po_items[],
i_po_itemsx, i_po_itemsx[],
i_return, i_return[].
l_ponumber = wa_po-ebeln.
i_po_items-po_item = wa_po-ebelp.
i_po_items-deliv_compl = 'X'.
i_po_items-no_more_gr = 'X'.
i_po_itemsx-po_item = i_po_items-po_item.
i_po_itemsx-po_itemx = 'X'. "Item holds changes
i_po_itemsx-no_more_gr = 'X'.
i_po_items-conf_ctrl = '0001'.
i_po_itemsx-conf_ctrl = 'X'.
i_po_itemsx-deliv_compl = 'X'. "Deletion field is changed
APPEND: i_po_items, i_po_itemsx.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = l_ponumber
testrun = space
TABLES
poitem = i_po_items
poitemx = i_po_itemsx
return = i_return.
READ TABLE i_return WITH KEY type = 'E'.
IF sy-subrc NE 0.
wa_output-message = 'Error in Update data'.. "i_return-message.
ELSE.
wa_output-message = 'Updated..' .
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.
ENDFORM.
Regards,
Venkat
08-26-2022 6:53 AM
Dear Sir,
I have done as you mentioned in the above program. Now I am getting message as "Instance 3000000004 of object type Purchase Order could not be changed".
I have attached the screenshot of debugger with all the values and with return message.
08-28-2022 5:53 AM
Try the same PO with ME22N and try to update the delivery indicator. See what is the actual message and why it is not allowing.
based on that we can modify the BAPI.
09-02-2022 10:17 AM
Hi Sir Good After Noon,
After adding wait = 'X' it is working fine....
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
Thank you so much sir..
Regards
Jayaprakash AK
08-25-2022 7:18 AM
You can use the BAPI 'BAPI_PO_CHANGE' to update the delivery complete indicator.
Pass 'X' to no_more_gr field of the poitem structure of the BAPI.
I think the below sample code will help you get started with the development.
DATA: lt_return TYPE bapirettab,
ls_poitem TYPE bapimepoitem,
lt_poitem TYPE bapimepoitem_tp,
ls_poitemx TYPE bapimepoitemx,
lt_poitemx TYPE bapimepoitemx_tp.
ls_poitem-po_item = p_ebelp. "Set Item Number
ls_poitem-no_more_gr = 'X'.
APPEND ls_poitem TO lt_poitem.
ls_poitemx-po_item = p_ebelp. "Set Item Number
ls_poitemx-no_more_gr = 'X'.
APPEND ls_poitemx TO lt_poitemx.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = p_ebeln "Set Purchase Order number here.
TABLES
return = lt_return[]
poitem = lt_poitem[]
poitemx = lt_poitemx[].
IF sy-subrc = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
09-02-2022 10:21 AM
Hi Nitish Good Afternoon,
I have modified this program based on my requirement now its working fine.
Thank you so much Nitish............
Regards
Jayaprakash AK
08-25-2022 7:38 AM
Hello akjayaa
You can of course write a custom report to close POs as indicated in the other answers. However as much simpler way is to use MEMASSPO transaction. It is a purchase order mass maintenance transaction. You can import data from external file or from the clipboard to the transaction - see SAP Help Importing Table Data
Best regards
Dominik Tylczynski
08-26-2022 6:03 AM
Through MEMASSPO transaction, it is not allowing to close some PO's, so I want to close PO forcefully.
So, is there any code we can write to close PO.