09-29-2008 7:34 PM
Hi all,
I need to reject a PO with abap code.
Since i didn't found any function module for that, i tried to create a BDC with ME29N but it doesn't seem to work.
Any other ideas?
Thanks,
Luis Cruz
09-29-2008 7:41 PM
09-29-2008 7:41 PM
09-29-2008 7:57 PM
Hi senthil,
I don't have those BADI's. I searched in SE37 and SE19.
SAP_BASIS = SAPKB70015
Thanks,
Luis Cruz
09-29-2008 10:26 PM
09-30-2008 5:47 PM
Hi Gabriel,
I can't find any field on that function to set PO document as rejected.
Can you help me on what field should i change?
Thanks
09-30-2008 6:10 PM
Hello,
On structure BAPIMEPOHEADER there is a field named REASON_CANCEL....I think that one will work.
Anyways ask your functional team which fields are required to reject a PO, take the data element from tcode me29n and look for it on the structures attached to the bapi.
cheers,
Gabriel P.-
09-30-2008 6:23 PM
Looks like it didn't worked.
I always receive the following message:
Change Reas. for Canc. could not be effected
The PO is not locked.
I'm doing the following code:
call function 'BAPI_PO_GETDETAIL1'
exporting
purchaseorder = lv_PURCHASEORDER
IMPORTING
POHEADER = ls_poheader
TABLES
RETURN = lt_RETURN
POITEM = lt_pOITEM.
ls_poheader-REASON_CANCEL = '1'.
ls_poheaderx-REASON_CANCEL = 'X'.
append INITIAL LINE TO lt_pOITEMX.
call function 'BAPI_PO_CHANGE'
exporting
purchaseorder = lv_PURCHASEORDER
POHEADER = ls_poheader
POHEADERX = ls_poheaderx
TABLES
RETURN = lt_RETURN
POITEM = lt_pOITEM
POITEMX = lt_pOITEMX.
COMMIT WORK AND WAIT.
CALL FUNCTION 'DEQUEUE_ALL'.
09-30-2008 7:05 PM
Hello,
Sorry It didnt work. Ask your functional team how to fill that field, or how is the procedure to reject...and look on bapi structures the corresponding fields; as I said before.
So far, that is the only help I could give you.
Let me know if you need something else.
Bye,
Gabriel P-.
10-01-2008 5:12 PM
After some debugs on ME29N, i manage to reject PO documents, here's the code, if anyone needs it:
* prepare creation of PO instance
ls_document-doc_type = 'F'.
ls_document-process = mmpur_po_process.
ls_document-trtyp = 'V'.
ls_document-doc_key(10) = lv_ponumber.
ls_document-initiator-initiator = mmpur_initiator_rel.
* object creation and initialization
lv_ponumber = im_ebeln.
lv_ebeln = lv_ponumber.
create object lc_po.
lc_po->for_bapi = mmpur_yes.
call method lc_po->po_initialize( im_document = ls_document ).
call method lc_po->set_po_number( im_po_number = lv_ebeln ).
call method lc_po->set_state( cl_po_header_handle_mm=>c_available ).
* read purchase order from database
call method lc_po->po_read
exporting
im_tcode = lv_tcode
im_trtyp = ls_document-trtyp
im_aktyp = ls_document-trtyp
im_po_number = lv_ebeln
im_document = ls_document.
if lc_po->if_releasable_mm~is_rejection_allowed( ) = 'X'.
call method lc_po->if_releasable_mm~reject
exporting
im_reset = space
exceptions
failed = 1
others = 2.
endif.
call method lc_po->po_post
exceptions
failure = 1
others = 2.
12-03-2009 5:20 PM
Hi Cruz,
Could you please provide me the entire code to reject the Purchase Order
08-23-2010 1:33 AM
Luiz, I just wanted to thank you! It works perfectly and saved me hours of painful debug...
Thank's again!
Regards,
Flavio Rasseli
08-23-2010 1:35 AM
By the way, the types used there are:
DATA: lc_po TYPE REF TO cl_po_header_handle_mm,
ls_document TYPE mepo_document.
Regards,
Flavio Rasseli
11-10-2010 4:44 AM
04-22-2011 12:28 PM
Hi,
i need also to reject a purchase order, thanks for object code but it don't work, the system tell me 'Purchasing document 1200000031 cannot be released'.
When i debug the problem comes from the method get_transaction_state(), it return type A.
04-22-2011 1:24 PM
05-29-2014 7:47 AM