FAQ about validations and substitutions part 3

III. Problem analysis

1. What must I take into account before I analyze the problem?

Before you analyze a problem with validations/substitutions, make sure that the generated source code is up-to-date. You can use Report 'RGUGBR00' to do this.
Call this report in Transaction SE38. You receive the following selection screen:

Application area ' '
Application callup point ' '

' ' Regenerate main program
' ' Generate table file
' ' Generate rules
' ' Generate validations
' ' Generate substitutions
' ' Generate sets
' ' Generate rule use
' ' Generate validation use
' ' Generate substitution usage
' ' Generate substitution export routines
' ' Generate substitution routines in all clients
' ' Generate trace program calls

Now update the source code for the application area and application callup point in which the validation or substitution was created.
To do this, enter the application area, for example FI, and the application callup point (0003/complete document), and set all indicators except for 'Generate substitution routine in all clients' and 'Generate trace program calls'. Then execute the report.

The source code is now at its current status.

2. How can the validation and substitution trace be used?

a) Validation trace

You created and activated a validation.
You can now activate the trace, for example in Transaction GGBO. To do this, place the cursor on the validation and select 'Extras -> Activate trace'.
Example:
You created an FI validation on the 'Line item' callup point. To test the validation, execute, for example, Transaction FB01. The trace is displayed as soon as the validation is run. You can now see different things in the trace, for example the values contained in the fields of the various structures. From this, you can deduce whether additional checks are required, or tell what the cause of a problem is.

b) Substitution trace

Activate the trace in the same way as you activate validations.
Example:
You created a substitution in the same way as you activated the trace in the case of the validation. The trace for substitutions has an additional function, in that you can view the field contents before the substitution as well as after the substitution. There, problems can be reproduced in the same way.

3. How can I use the DEBUGGER to analyze a problem?

a) Basic information

All Includes for validations and substitutions are created in this form: GBTmmaa0.
mm stands for two digit client key.
You can use the G_CLIENT_ENCODE function module to convert a three-digit client (>099) to a two-digit client, for example: client 100 --> AA
client 800 --> TQ
AA stands for the application area, for example FI --> Financial Accounting
CO --> Cost Accounting
You will find this abbreviation in the maintenance transaction.
Therefore, GBTAAFI0 is the Include in client 100 for FI validations and substitutions.

b) Structure of the Includes and form routines for validations and substitutions and tips on how to 'debug'


The above-mentioned Includes are structured in the following way (sample Include in FI, Client 800):

INCLUDE GBTTQFIA. " Rules
INCLUDE GBTTQFIB. " Substitutions
INCLUDE GBTTQFIC. " Substitution conditions
INCLUDE GBTTQFID. " Validations
INCLUDE GBTTQFIE. " Validation conditions
INCLUDE GBTTQFIF. " Validation checks
INCLUDE GBTTQFII. " Application rules
INCLUDE GBTTQFIJ. " Substitution export routines
INCLUDE GBTTQFIM. " Trace/simulation
INCLUDE GBTTQFIS. " Substitution import routines

c) The form routines for validations have the following sample structure (sample validation with the name VAL01):


FORM VAL_VAL01.
G_BFOUND = B_TRUE.
DATA: COND LIKE D_BOOL,
CHECK LIKE D_BOOL,
NVALSEVEREST LIKE SY-SUBRC VALUE -1.

G_STEP = '001'.
PERFORM VALCOND_1VAL01##001
CHANGING
COND.

IF COND = B_TRUE .
PERFORM VALCHCK_2VAL01##001
CHANGING
CHECK.

IF CHECK = B_FALSE .
PERFORM MESSAGE_OUTPUT
USING
" ...Nachrichtenparameter
CHANGING
NVALSEVEREST.
ENDIF.
ENDIF.
ENDFORM. " VAL_VAL01

Statement G_STEP = '001' indicates the step that is executed.
The prerequisite of the step is defined in Form Routine VALCOND_..., the form routine VALCHCK_... checks the validation step.

To analyze this step, you should create breakpoints on these two PERFORM statements and also on the code line 'IF CHECK = FALSE'. In doing so, you can determine whether your prerequisite or the check is causing the problem you have, for example a field that is to be checked does not contain the value that you expect.

d) The form routines for substitutions have the following sample structure (sample substitution with the name SUB01):


FORM SUB_SUB01.
G_BFOUND = B_TRUE.
DATA: COND LIKE D_BOOL.
G_CLASSID = '009'.
G_SUBST_PERFORMED = B_FALSE.

IF G_TAB_FLAG-BSEG <> B_TRUE .
PERFORM READ_MASTER_DATA
USING
'BSEG'
G_BFOUND.
IF G_BFOUND = B_FALSE .
MESSAGE E083 WITH 'BSEG'.
ENDIF.
ENDIF.

G_STEP = '001'.
PERFORM SUBCON_3SUB01##001
CHANGING
COND.

IF COND = B_TRUE .
BSEG-SGTXT = 'This is a Test'. " Text
G_SUBST_PERFORMED = B_TRUE.
ENDIF.
ENDFORM. " SUB_SUB01

As mentioned above for validations, 'G_STEP = '001' indicates the step, and the prerequisite of the substitution is defined in Form Routine SUBCON_.... The actual substitution is carried out by the statements in the 'IF COND = B_TRUE --> ENDIF' structure. These statements vary depending on the 'type' of substitution created (field allocation, constant value, user exit).

In the substitutions, you should also set a breakpoint on the PERFORM on the prerequisite and the statement 'IF COND = B_TRUE'.

4. Function modules that call validations and substitutions


Validations - Function module G_VSR_VALIDATION_CALL
The different structures/tables, the name of the validation, callup point and application area are assigned to this function module.
Substitutions - Function module G_VSR_SUBSTITUTION_CALL
The parameters transferred to validations are also transferred to this function module. However, structures/tables that contain the changed values are also returned.

You could set a breakpoint to analyze both function modules. In doing so, you could see which data was transferred, which data the validation or substitution attains, and which values are returned.

5. What must I take into account during the set usage?


When sets are used in validations or substitutions, source code is generated from the values in the sets.
Performance problems can occur if a set is of a certain size, since the generated source code causes longer runtimes.
A runtime error can also occur.

To reduce the size of the source code of the sets used, you can proceed as follows:

Use a smaller set in the validation, substitution or rule. To do so, group single values in the set into intervals (for example, instead of the single values 0001, 0002 and 0003, use the interval 0001 - 0003)

Instead of " IN SET", use the rule "( IN SET1 OR IN SET2)" in which SET1 and SET2 contain the values from SET (for example, subhierarchies on the highest hierarchy level).

The simplest way to determine the number of single values or intervals in a set hierarchy is to execute Program RGSEX000.
Enter the name of the set and execute the program. All contained sets and values/intervals are listed and the sequential number of the entries is contained in the first column.

6. Why does a validation or substitution work in the development system, but not work in another system after a transport?


You should make sure that validations and substitutions are activated in the target system. You can also use Report RGUGBR00 to execute the regeneration of the source code again.

There could be another cause in the case of substitutions:
You try to substitute a field that is not released as a default by SAP. To substitute a field, you have adjusted Table GB01 in your development system. However, this did not occur in the target system. The generated source code is correct and the value was changed in the substitution, but the change was not returned to the calling application via the export routines.

0 Comments:

Post a Comment




 

Copyright 2006| Blogger Templates by GeckoandFly modified and converted to Blogger Beta by Blogcrowds.
No part of the content or the blog may be reproduced without prior written permission.