Sometime there are requirements when one wants the flexibility to have configurable validations in a program on top of existing validation happening in the program. This gives flexibility to the customers to change/add validation based on individual requirements. FI validation subsitution and rule component has a generic formula builder which can be used by other component to build configurable validations. This component(transaction GGB0) provides the standard way of creating logical expressions. It is possible to plugin your component to this subsystem and use it to build your validation. Following steps are required to plugin your component to use this.
1. In order to plug in your component, one has to configure some of the tables used by this component.
a. GB03 - This table stores different application areas
e.g FI, CO, AR etc. You need to add an entry for your
application area.
b. GB31 - This table stores different call points for an
application area. Call points are name of logical area
where you want the validation to happen e.g. FI
document header, item level validation and complete
document validation. You need to specify which boolean
class needs to be used for each call point. Boolean
class is described in following points. Make sure
field GBVALUSE is 'X'.
c. GB02 - This table stores Boolean classes. Boolean
class are used to link message class used to show
the error messages if validation fails and what
table/structure need to be used for validation.
d. GB01 - This table stores the table/structure name and
its fields for a Boolean class which will be showed up
for validation creation in formula builder. '*' means
all fields.
You can create a report program to insert records to
these tables. Take care of text tables also. After
inserting the records, call following report to get
the required code generation for validation subsystem
to work.
submit rgugbr18
with x_code = 'X'
with x_off = space
with x_on = 'X'
2. Once you have the configuration done mentioned in Step 1
your application area and call point will appear in
transaction GGB0 where you can create a validation
using fields from the structure regsitered to boolean
class.
Validation can have multiple steps. Each step can have
pre-requisite which decides if check needs to be done,
a check and a message from the message class regisered
with boolean class. In check creation, it will show the
fields of the structure/table registerd with the boolean
class.
3. In you main program, call following FM to invoke the
configurable validation created in transaction GGBO.
data: vaktab like rgbl5 occurs 1.
data: wa_vatab like rgbl5.
wa_vatab-tabname = 'Your registered Str/table name'.
APPEND wa_vatab TO vaktab.
CALL FUNCTION 'G_VSR_VALIDATION_CALL'
EXPORTING
tab_data1 = 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
You are done!!!!! validation configured using the structure registered with boolean class will be invoked in your main program on top of what you have coded. This gives more flexibility to the customer to manage its own validations.
You can use this for subsitution also. For more infomration on how to create rule, validation and subsitution use standard SAP help document.