Variable processing

USE:

At this level, we can specify a set of actions for each selected variable. An action defines how and when the chosen variable is going to be processed. 

Each processing instruction contains an Action, Variable Procedure, and Processing Parameter.

Action specifies when and in which situation the Variable Procedure will be triggered. Each variable contains a container with two values: the one calculated based on the reference message/document and the one calculated ad-hoc during test case execution. Actions determine if the reference value or current value will be modified. As an example, please see two values in the Int4 IFTT test case execution report:

In this case, the value PO146753/2020 was read from the reference input XML message from the test case definition. The value IFTT_B_80173 was generated before test case execution. It replaced the original value in the message that was injected for current testing.

Variable Procedure specifies how the value to the variable will be loaded or how the variable should be filled with a new ad-hoc generated value during test case execution.  

Processing Parameter is an input string with instruction that is consumed by the variable procedure.


There are four actions (scroll the page to see four columns in below table):


Populate variable before execution

Generate value for a new message:

Populate variable after execution:

Locate new message using variable value: 

Action:

This action is triggered before test case execution. It is used to load to the variable containing the reference value.

Action:

This action is triggered before test case execution. It is used to generate new values and to substitute the message that will be injected into the middleware for processing. The values will be stored In the container as current values.

Action must be always preceded by Action 10 Populate Message before execution to mark the place in the message that will be substituted with a new value.

The variable scope influences this action. Scope determines the processing of procedures that generate unique values like, e.g., GUID or NUM_RANGE.

  • Test Case Scope - variable is replaced with new values considering values from the currently processed test case. The variable value, which occurs multiple times in the test case payload, is replaced with the same new value. The variable value in different test cases from the currently processed test run is replaced with a new value for each test case.
  • Test Run - variable is replaced with new values considering values from the currently processed test run. The variable value in different test cases from the currently processed test run is replaced with the same new value.

Action:

This action is triggered after the execution of the test case. It will populate value from assertion results into "reference" and "current value" fields in the container.

Action:

This action is limited only to outbound test types. This testing type must be preceded by another test case that will trigger the interface document to the middleware. This might be eCATT recording, another interface posting that triggers the response or calls by API from external testing software.

The action will be triggered to find specific message in the middleware. The value that would be searched must be previously read by Action 10: Populate variable before execution 

Available variable procedures:

1.a) READ_MSG Read variable from saved message (XPath)

Populate the variable with value fetched from the saved reference input payload. The value is fetched by running the XPath expression or Int4 Flat File syntax (depending on message format).


It is possible to use regular expressions also for XML messages. In case of REGEX expression is used XML file is treated as a flat-file. See details about REGEX syntax on this page: Expression language for flat files

Apart from the loading value, the place in the message will marked and used by the following action, 'Generate value for the new message', to substitute reference value with a new one.

The XPath or flat expression must be provided as a string in the parameter field. XPath expressions must end with /text() function to extract node value, not the node object. Please follow the example section of this page for more guidelines.

1.b) READ_PREV Read variable from the previous case

This procedure can be used only for test cases run in sequence. It will load the variable value of the previous test case. The variable name from previous test cases must be provided as a parameter. Test cases are linked in sequence in the test cockpit.

1.c) USER_DEF Read user-defined value from the cockpit

The variable is populated using the value provided by the user during the test case creation. The value is provided for each variable only once per test case. Read more.

1.d) READ_MSGH Read variable from message header (XPath)

The variable is populated using the value from message header. Currently this is supported for SAP PI/PO test cases.

1.e) CONCAT Concatenate one or more variables and static text

The value of the variable is a result of concatenation of other variable values and static text. Values of variables are put in place of placeholders, e.g.: [VAR_PO] will be replaced by a value of the PO variable.

Available variable procedures:

2.a) CONSTANT Replace value with constant

The current value will contain the constant passed in the parameter. The constant should be provided as is without any brackets.

2.b) GUID Generate GUID

Generate random values in a GUID format.

2.c) NUM_RANGE Generate number from number range

generate value for a new message from a predefined number range. More details are presented in the Number ranges section. Using number ranges is the most common way to generate new document numbers in end-to-end testing together with the SAP back-end.

Please provide as a parameter the name of the number range that was created for a particular variable.

2.d) RANDOM Generate a random value

generates a random value. The value of the parameter defines the upper limit of the range. It is also possible to generate negative numbers. For example, passing -100 in parameter will generate random numbers from -1 to -100

2.e) PREFIX add prefix

use reference value read by the previous action and add prefix specified in the parameter. Prefixes might be helpful to indicate other systems that messages are coming from automated testing.
It is possible to combine PREFIX with Number range by including Number range name in square brackets.

Example:
Prerequisite - number range 'NR1' configured for Automation Object
Example prefix - 'IFTT[NR1]_'

2.f) SUFFIX add suffix 

use reference value read by the previous action and add suffix specified in the parameter. Suffix might be helpful to indicate other systems that messages are coming from automated testing.

It is possible to combine SUFFIX with Number range by including Number range name in square brackets.

Example:
Prerequisite - number range 'NR1' configured for Automation Object
Example suffix - '_IFTT[NR1]'

2.g) READ_PREV Read variable from the previous case

This procedure can be used only for test cases run in sequence. It will load the variable value of the previous test case. The variable name from previous test cases must be provided as a parameter. Test cases are linked in sequence in the test cockpit.

2.h) USER_DEF Read user-defined value from the cockpit

The variable is populated using the value provided by the user during the test case creation. The value is provided for each variable only once per test case. Read more.

2.i) SYST Read value from the SY structure

The variable is populated using values from the SY structure (type SYST). The parameter defines the field to be read e.g., UNAME, DATUM.

2.j) TVARVC Read parameter value from the TVARVC

The variable is populated using parameters from the TVARVC table.  TVARVC table contains parameters useful in background processing. It can be maintained in transaction STVARV.
More details: https://help.sap.com/viewer/12aa7f056c531014aa5bca7aee037e55/7.0.37/en-US/c09803a7e58611d194cc00a0c94260a5.html

2.k) DATE Generate date

The variable is populated using the Date value. Parameter defines additional options for date generation: FORMAT,BASE_DATE,OFFSET

The format can be composed with following parts:
YYYY - 4 digit year
YY - 2 digit year
MM - month
DD - day

The base date can be one of the following:
CD - current date
FDCM -first day of the current month
LDCM - last day of the current month
FDNM - first day of next month
FDPM - first day of the previous month
LDPM - last day of the previous month
FDCY - first day of the current year
LDCY - last day of the current year
The offset can be an integer number with a sign:

Offset can be an integer number with sign:
+1 - add one day
-7 - subtract seven days

Examples (assume the current date is 2nd Nov 2020):
'' (empty  parameter) -  02.11.2020

Formats

'YYYY-MM-DD' 2020-11-02

'DD-MM-YYYY' 02-11-2020

'YY/MM/DD' 20/11/02

Base dates

'DD-MM-YYYY,CD' 02-11-2020

'DD-MM-YYYY,FDCM' 01-11-2020

'DD-MM-YYYY,LDCM' 30-11-2020

'DD-MM-YYYY,FDNM' 01-12-2020

'DD-MM-YYYY,FDPM' 01-10-2020

'DD-MM-YYYY,LDPM' 31-10-2020

'DD-MM-YYYY,FDCY' 01-01-2020

'DD-MM-YYYY,LDCY' 31-12-2020

Offset

'DD-MM-YYYY,CD,+7' 09-11-2020

'YYYY-MM-DD,CD,-7' 2020-10-26

'DD-MM-YYYY,FDCM,+9' 10-11-2020

'YYYY.MM.DD,FDPM,+14' 2020.10.15

2.l) ENV_VALUE Replace value based on value mapping

The variable value is replaced based on a Mapping Object's value defined for source and target environments. The Mapping Object can be defined in transaction /n/INT4/IFTT_IMG → Landscape configuration → Define Mapping Objects.

2.m) CONCAT Concatenate one or more variables and static text

The value of the variable is a result of concatenation of other variable values and static text. Values of variables are put in place of placeholders, e.g.: [VAR_PO] will be replaced by a value of the PO variable.

Available variable procedures:

3.a) DB_RES Read variable from DB res (XPath)

Populates variables with data obtained from the Database.

As a prerequisite, the configuration object must contain database comparison rules and choose for comparison tables and fields that later on will be loaded to the variable.

The field and table are specified in the parameter as XPath expression like:

//TBL_NAME/FIELD_NAME/text()

example: //VBAK/VBELN/text()

If there would be more than one value, then all of them will be returned. Additionally, you can extract a particular row by adding its number. For example:

//VBAP[2]/POSNR/text()

will extract the second line from table VBAP presented in the validation results.

A more detailed example is available below in example sections. 

3.b) ECATT_LOG Read variable from eCATT log (XPath)

If the test type is eCATT, a variable can be populated from the eCATT execution log. The value is obtained from the log using the XPath expression. See details here

3.c) ECATT_EXP Read variable from eCATT export parameters

If the test type is eCATT a variable can be populated from the eCATT export parameter.

3.d) READ_MSG0 Read variable from outbound msg (XPath)

Applicable only for outbound test types.

Populate variable with data fetched from the outbound message using XPath or flat expression after test case execution. The expression is passed in the parameter field.

3.e) READ_MSGID Read message ID

Populate the variable with the ID/GUID of the tested message.

3.f) CONCAT Concatenate one or more variables and static text

The value of the variable is a result of concatenation of other variable values and static text. Values of variables are put in place of placeholders, e.g.: [VAR_PO] will be replaced by a value of the PO variable.

Available variable procedures:

4.a) XPATH | Find using XPath

This procedure will search all middleware messages of the tested interface from the recent period to look for the value loaded by Action 10.

The value will be checked in the field specified by XPath or flat-file expression and passed as a parameter.

Like in other cases, the XPath expression must end with the function "text()".

4.b) XPATH_C1 | XPath value contains Variable

Similar to 4a, but will not require that the variable value is equal to the value extracted by XPath expression.
It will check if the value extracted by expression contains the variable value.

Example:

Variable value: DD01609
Value from message extracted by the expression: 00XBDD01609XYZ

00XBDD01609XYZ contains DD01609 so that the message will be selected

4.c) XPATH_C2 | Variable contains XPath value

Similar to 4B, however, the variable needs to contain the value extracted by expression.

4.d) CONCAT Concatenate one or more variables and static text

The value of the variable is a result of concatenation of other variable values and static text. Values of variables are put in place of placeholders, e.g.: [VAR_PO] will be replaced by a value of the PO variable.

More information about XPath and the examples are available on this page: XPath expressions.

EXAMPLES:

For more information about how to use the variables for different business purposes, please refer to examples:

Example 1 - Substitution of the document number for test type PI inbound

Example 2 - Substitution of the document number for test type SAP Backend testing

Example 3 - XPath expression to ignore the payload's namespace

Example 4 - Configure variable to accept an external value

Example 5 - Configure the variable to read a value from the eCATT recording


© 2017 - 2022 Int4 AG All rights reserved