2007 Aug 02 6:53 PM
Hi, how can we know in the method post of the BADI ME_PROCESS_PO_CUST if we are in creation mode (me21n) or change mode (me22n), I need to do some coding only at the creation of the PO but this method is call anytime we click save!
thanks!
2007 Aug 02 7:23 PM
Hello Alexandre
It would be possible to check the transaction. However, if the BAPI BAPI_PO_CREATE is used the BAdI is also processed yet the transaction is most likely wrong.
An <u>unambigous </u>approach is to check IMPORTING parameter IM_TRTYP in method IF_EX_ME_PROCESS_PO_CUST~OPEN:
METHOD if_ex_me_process_po_cust~open.
* define local data
DATA:
lo_po TYPE REF TO cl_po_header_handle_mm,
ls_header TYPE mepoheader.
me->md_trtyp = im_trtyp. " save transaction type
IF ( im_trtyp = 'H' ). " add new purchase order
...I would add an instance attribute MD_TRTYP to the BAdI implementing class and save the transaction type in method IF_EX_ME_PROCESS_PO_CUST~OPEN (see above).
Now you can simply add the following IF condition to your POST method:
METHOD if_ex_me_process_po_cust~open.
CASE me->md_trtyp.
WHEN 'H'. " add new purchase order
... " do required action for CREATE
WHEN ... .
WHEN others.
...
ENDCASE.
...The possible transaction types can be found at: im_trtyp -> data element -> <b>domain </b>(fixed values).
Regards
Uwe
Hi, how can we know in the method post of the BADI ME_PROCESS_PO_CUST if we are in creation mode (me21n) or change mode (me22n), I need to do some coding only at the creation of the PO but this method is call anytime we click save!
thanks!
2007 Aug 02 7:18 PM
2007 Aug 02 7:23 PM
Hello Alexandre
It would be possible to check the transaction. However, if the BAPI BAPI_PO_CREATE is used the BAdI is also processed yet the transaction is most likely wrong.
An <u>unambigous </u>approach is to check IMPORTING parameter IM_TRTYP in method IF_EX_ME_PROCESS_PO_CUST~OPEN:
METHOD if_ex_me_process_po_cust~open.
* define local data
DATA:
lo_po TYPE REF TO cl_po_header_handle_mm,
ls_header TYPE mepoheader.
me->md_trtyp = im_trtyp. " save transaction type
IF ( im_trtyp = 'H' ). " add new purchase order
...I would add an instance attribute MD_TRTYP to the BAdI implementing class and save the transaction type in method IF_EX_ME_PROCESS_PO_CUST~OPEN (see above).
Now you can simply add the following IF condition to your POST method:
METHOD if_ex_me_process_po_cust~open.
CASE me->md_trtyp.
WHEN 'H'. " add new purchase order
... " do required action for CREATE
WHEN ... .
WHEN others.
...
ENDCASE.
...The possible transaction types can be found at: im_trtyp -> data element -> <b>domain </b>(fixed values).
Regards
Uwe
2007 Aug 02 7:40 PM
Thanks Uwe, this is what I was searching for, I never thought to look in the open method.
I give you 10
Regards,
Alex
2007 Aug 02 8:02 PM
Hello Alexandre
You are welcome!
Since BAdI interface usually do not have that many methods I usually "browse" through all methods and their parameters to get an idea about the function of the methods (because, sadly enough, they are poorly documented).
Regards
Uwe
2007 Sep 14 5:41 AM
I face the same problem as I need to have some logic implemented in the close method if it is a create PO action.
When I try your coding in METHOD if_ex_me_process_po_cust~open.
me->md_trtyp = im_trtyp.
I get 'Field "MD_TRTYP" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement.
Besides, I would like to ask if I can declare a global variable to be shared within the different methods in the BADI ME_PROCESS_PO_CUST.
2007 Sep 14 6:46 AM
Hello Gundam
I have defined MD_TRTYP (most like of TYPE trtyp) as <i>private </i>instance attribute of the class implementing the BAdI interface. This way the transaction type is available in all methods of the BAdI.
Regards
Uwe
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |