Skip to Content
avatar image
Former Member

Cost center to be blocked for posting for particular cost center in ME21N


Hi Experts,

Requirement: To block the PO creation for the cost center (KOSTL) = '19001' and Acc. Assignment Category(KNTTP) = 'K' for the tcodes ME51N, ME52N, ME54N ,ME21N, ME22N ME29N.,


For this i used BADI -ME_PROCESS_REQ_CUST , but i m unable to get both kostl value and knttp value in any of the methods .so i tried using BADI -ME_REQ_POSTED and its working fine for other tcodes but it is not triggering for ME21N,

Pl help to block the cost center for me21n tcode .

Pl find the attached program.

Thanks in Advance,



me21n.png (28.9 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Jan 02, 2018 at 06:40 AM

    For ME2*N, use BAdI ME_PROCESS_PO_CUST, for ME5*N use BAdI ME_PROCESS_REQ_CUST. In both case use method PROCESS_ACCOUNT and macros from mm_messages_mac.

    Navigate from both method parameters to find available methods to read required information.(Look for get_data and get_exkn)

    NB: You could also consider a CO validation (tr. OKC7) to get similar result.

    Add comment
    10|10000 characters needed characters exceeded

    • You didn't raise an error with the macros provided and didn't invalidate the item accounting...

      * include mm_messages_mac. " Read BAdI documentation!
      * mmpur_context mmcnt_context_badi. " set context
      *  if not ls_accounting-id is initial. 
      *    " remove previous error(s) raised by BAdI on this item
      *    mmpur_remove_msg_by_context ls_accounting-id mmcnt_context_badi. 
      *  endif.
      * Raising error and invalidate item
      mmpur_metafield mmmfd_cost_ctr. " field related to error (Look at type-pools MMMFD)
      mmpur_message_forced 'E' 'ZMSG' '999' ls_account-kostl ls_item-knttp ' ' ' '. 
      im_account->invalidate( ). 

      (And don't paste a screen capture of the code but paste 'unformated' part of the code in block created with 'insert code')

      NB: Also consider to remove the hard-coded cost centers, ask functionals to (at least) handle some 'set' (GS01) or 'group' (KSH1) of cost centers (and to look at Customizing for any option already allowing this check...)