Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Cancel PO Rejection using BADI ME_PROCESS_PO_CUST not working

Hello ABAPER's.

I need your help please.

The client wants that in ME29N when SAVING the PO, the program to make the same as the "CANCEL REJECTION" button.

I managed to create a code to make the CANCEL REJECTION part (in a Ztest program) and it works very well with this code:

REPORT  zteste_rjm.

DATA: lc_po       TYPE REF TO cl_po_header_handle_mm,
      ls_document TYPE mepo_document,
      lv_ponumber LIKE ekko-ebeln,
      lv_ebeln LIKE ekko-ebeln.

PARAMETERS im_ebeln LIKE ekko-ebeln.

*  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.

*  object creation and initialization
lv_ponumber = im_ebeln.
lv_ebeln = lv_ponumber.
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
    im_tcode     = 'ME29N' "lv_tcode
    im_trtyp     = ls_document-trtyp
    im_aktyp     = ls_document-trtyp
    im_po_number = lv_ebeln
    im_document  = ls_document.

  CALL METHOD lc_po->if_releasable_mm~reject
      im_reset = 'X'
      failed   = 1
      OTHERS   = 2.

CALL METHOD lc_po->po_post
    failure = 1
    OTHERS  = 2.

This works fine as a standalone program, but as I said they want it when saving in the ME29N, so I found a BADI ME_PROCESS_PO_CUST and made an implementation of it and in the POST method i put my code, but what happens is that the program enters in a loop and never comes out. so one thing I changed was taking out of my code the last call method. The programs doesn't enter in loop but doesn't executes the CANCEL REJECTION.

Can anyone help me please ?

Best regards,

Ricardo Monteiro

Not what you were looking for? View more on this topic or Ask a question