FAQ about validations and substitutions part 2
Published by Abraham on Wednesday, March 28, 2007 at 1:25 AMII. Using user exits in validations or substitutions
1. Where can I maintain user exits for validations and substitutions?
The exits for validations and substitutions are stored in an Include of your choice.
The following Includes are delivered as examples by default:
RGGBR000 Val/Sub: Exits for rules
RGGBS000 Val/Sub: Exits for substitutions
You should copy these into the customer namespace, for example ZGGBR000.
The length of the name you choose should not exceed 8 characters. This is because the name is also generated in the source code, and so a certain line length may be exceeded as a result.
You can also create a separate Include per client as this can improve performance.
In Transaction GCX2, you should then define where your Include is used. To do this, enter the name of your Include as a form pool in the relevant application area.
2. How should I create a user exit?
Define your user exit in the FORM Routine GET_EXIT_TITLES with the correct exit category (EXITS-PARAM). You can use the existing sample entries as a model for this.
The exit types required in the FORM Routine GET_EXIT_TITLES are organized as follows:
- C_EXIT_PARAM_NONE No parameter
Apart from the return value (B_TRUE or B_FALSE), you do not need any parameters for the validation. If you do not want to substitute a field, use this parameter in the substitution (select "Only exit").
However, you must then use a TABLE statement in the formpool (not in the actual form) to identify the structure concerned.
- C_EXIT_PARAM_FIELD A Field is transferred as a parameter
You only use this type in the substitution. Exactly one field is substituted. Enter user exits of this type in the substitution maintenance instead of assigning a constant value.
- C_EXIT_PARAM_CLASS A complete type is transferred as a parameter
Matrix validations/substitutions ("Only exit"). This exit type can only be used in the case of callup points with complete documents, for example in the FI and the LC. You cannot use this exit category on any other callup points. The transferred type contains all information of a class. An example is the use of the document header and all corresponding line items in the FI area.
In the FORM routine GET_EXIT_TITLES, change the NAME and TEXT field of the EXITS internal table to the values you want.
Use one of the sample routines as a model and copy these to the names you selected. You can now implement the functions you want in this form routine.
After you have finished creating the user exit, you can use it in your validations or substitutions.
3. What must I take into account when implementing the user exit?
Do not use any ABAP commands that cause the exit to be left directly, for example 'LEAVE (TO) SCREEN ...' or 'SUBMIT
In an exit, use only structure fields that belong to the Boolean class of the calling substitution, validation or rule. The other structure fields are not filled or are not filled properly on the callup point of the calls of the substitution, validation or rule.
Changes to field contents may only be made in a substitution exit if this field can be substituted in the Boolean class. You can display such fields by selecting the "Add entry" function in the substitution maintenance.
In the Includes of the substitution exits, you must not use the commands MODIFY, INSERT or DELETE in the internally used structures such as BSEG or BKPF. These structures are interpreted internally as database tables because they are defined by a TABLES statement. As a result, database records are written, deleted or changed when you use the commands mentioned above. This can cause serious inconsistencies and problems in the document processing.
If you want to change field contents in Exit Types C_EXIT_PARAM_CLASS, you should make the changes in the internal table BOOL_DATA (for example BOLL_DATA-BSEG).