You are on page 1of 5

Go to T.

code ME21N

1. Choose Order type

2. Enter Vendor

3. Enter Document Date

4. Enter Organization group

5. Enter Material code (Note : you can overwrite material description if


necessary )
6. Enter P.O. Quantity

7. Enter Net Price

8. Delivery date by default is the same with document date

Enter Delivery date if necessary


9. Enter Plant & Hit "Enter" button

10. Enter storage date


11. You may add line item as neccessary

12. At this point showing line item detail 10's information.

13. To check Net Price go to "condition" tab. Notice the relation of the price

14. Add comment at the header "texts" tab if necessary.


15. Click "check" icon to see whether there are errors/warnings.

Note that document with error cannot be saved.

16. Note the saved document number.

Use Tcode ME23N to view this document

Enhancement of ME21N/ME22n:

1. I have a requirement where I need to make the material PO text in ME21N / ME22N obligatory
for all items in some types of POs. Also, this text must not be changed after saving the PO.
2. 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!

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 unambigous 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.
...
1. The possible transaction types can be found at: im_trtyp -> data element -> domain (fixed
values).
2. 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).
3. 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.
4. I have defined MD_TRTYP (most like of TYPE trtyp) as private instance attribute of the class
implementing the BAdI interface. This way the transaction type is available in all methods of the
BAdI.

You might also like