Skip to Content
Author's profile photo Former Member

Validation: Prevent GL Account Sets from Posting to Cost Centers


There’s always an issue that SAP users by mistake post production consumption to cost centers through MIGO or manually although production consumption accounts should only be posted to production orders.

The best way to prevent this mistake is to use Validation Rules (Trx GGB0) and specify the GL accounts that are not allowed on a cost center so the user gets an error whenever SAP is posting these GLs to a Cost Center.

Since validation rules are part of system config, it’s a lot of headache to change the GLs in the rule later in case a new GL is created or an exception is needed.

To be able to edit the rule’s GLs without doing any configuration, we can maintain an Account Set in the validation rule instead of specific GL accounts, in this case the Set can be edited freely in Production environment (by authorized users).

This will involve creating a user exit and editing a copy of a standard SAP program


1) Trx GS01 > Create the Account set

2) Trx SE38 > Copy program RGGBR000 to ZRGGBR000 and add the below code at the end of the standard code

exits-name = ‘ZCC’.

exits-param = c_exit_param_none.
exits-title = text-103.
APPEND exits.

FORM ZCC USING b_result.
b_result b_true.
b_result b_false.


GL_CC_BLOCK is the name of the Account Set
3) Trx  GCX2  >> Assign program ZRGGBR000 to Validation Rule Exits

4)Trx  GGB0  >> Create Validation

5) Trx OB28  >> Activate Validation on the company code level

Now test the validation using any transaction, try FB50

Thank you for reading.

Best regards,
Abdullah Galal

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      hi Former Member

      good information thanks to share this to all



      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thank you Krishna

      Author's profile photo Paulo Vitoriano
      Paulo Vitoriano

      I just do not get why we need an exit named ZCC, it is a standard boolean statement to check if account is making part of the set.  Operator IN.  This can be done without any ABAP. 

      Author's profile photo Partha sarathy
      Partha sarathy

      The above mentioned validation works only during the execution of transaction . how do we validate  after changing the values in transaction.


      Author's profile photo KK Lam
      KK Lam

      Agree with Paulo, this can be done without exit.