In this article we will discuss about Validation and Substitution in SAP Accounting Documents, Perhaps you are wondering why we discuss validation and substitution in SAP Financial ( SAP FI ) the answer is that numerous MM Documents have an FI document as a follow-on.
With SAP validation and substitution, you have two very similar tools provided. The difference between the two is as follows:
With validation, you can check the field contents of the accounting document and prevent the posting of a document if required by displaying an error message.
With substitution, you can overwrite some field contents of the accounting document.
Of course, you also have the option in many MM enhancements to check an input or overwrite field contents. However the advantage of validation and substitution is that there is a central item in the interface between MM and FI. Therefore you can implement a central set of rules in validation that will always run regardless of whether the original document is material document, a logistics incoming invoice or a document from another SAP module.
Validation of SAP Accounting Documents
You can use SAP validation to check an accounting document and to reject the posting, You can create validation in transaction OB28. A validation for a specific callup point is therefore created and contains one or several steps. Each step in turn consists of prerequisite, a check and a message displayed if check fails.
SAP Validation and Substitution – Callup Points
Validation can be triggered at various callup points, usually this happen during the check for the document at header or the document item takes place. Callup points consist of 3 points such as :
- Document Header ( BKPF )
- Document Item ( BSEG )
- Complete Document ( BKPF + BSEG )
SAP Validation and Substitution – Steps
Each validation consists of one or several steps that are executed in succession. Each step consists of the following sections :
In the PREREQUISITES section, you can entered the condition that step is required to executed, it may you entered only BKPF-BLART EQ ‘PY’ is allowed to run this validation and substitution.
In the CHECK section, you specify condition that must be fulfilled to run the program without error and therefore to post the document. You can also go to validation exit for complex checks and carry out the checks via ABAP coding and you need to return the result of your check to variable B_RESULT ( false or true ).
In MESSAGE section you have to define the message displayed to the user if the previously defined check has failed.
Example SAP Validation without Exit Routine
Now you understand the basic concepts for validation, the following brief example show you how to set up validation.
- Start the transaction OB28, you can create a validation for each company code with each of callup point ( Header, Item and Header + Item ).
- In validation editor, click toolbar button to insert new step or use Ctrl + Shift + F5.
- Give the step name name and switch to PREREQUISITE section and entered following condition for example :
BSEG-BSCHL = '31' AND ( BKPF-BLART <> 'PY' AND
BKPF-BLART <> 'AB' AND
BKPF-BLART <> 'TM' ) AND
SYST-TCODE <> 'MRKO'
Or you can navigate to Menu Extras -> Substitution Fields and you can select allowed fields from popup dialog screen.
- Now switch to CHECK section , for example condition, we should check BKPF-XBLNR not allowed empty so input following condition.
BKPF-XBLNR <> ''
- Now switch to MESSAGE section, and maintain message and enter text for the message. you can see the picture above.
Example SAP Validation with Exit Routine
For simple validation without exit routine is sufficient, but assume you also need to check the custom table, this means you must execute database query and this is possible via an exit routine.
Exit routine for SAP Validation and Substitution are form routines that are stored in a specific program. You can find those program in the customizing table T80D .
How to implement SAP validation and substitution exit routine.
Copy program RGGBR000 to customer namespace i.e : ZRGGBR000 and change entry in T80D for work are GBLR.
User routines should always start with U and three digit number. you can see the template of the exit routine below.
* Validation Exit
* <-B_RESULT T = True F = False *
FORM u900 USING b_result.
Now you can program exit routine and don’t forget to populated B_RESULT with (T) True or (F) False.
Restart transaction OB28 and switch to the expert mode via Menu Settings -> Expert Mode and click tab Exits and double click your exit routine to insert into CHECK Section.
Substitution of SAP Accounting Documents
Substitution allows the replacement of some fields of SAP Accounting Documents during its posting, Substitution is very similar to Validation. You should already understand the concept of times and step on the beginning article.
You can access the substitution via transaction OBBH, In substitution you can longer display error message like Validation because Substitution doesn’t include MESSAGES section.
Which fields are available in Substitution are controlled in table GB01. you able to maintain this GB01 table, All listed field with Classtype = S are able to substituted if the indicator in field BEXCLUDE is not set. After you maintain GB01 table you must start report RGUGBR00 to generate substitution program.
As far the substitution without exit routine and exit routine is similar with implementation validation before. you can refer it.