(DV-2411) SAP Report Mapping

The mapping helps to distinguish the differences between two report outputs caused by report layout changes on different releases. Technically it translates corresponding report output (before or after image) to be in the same layout (e.g. column orders, headers differences, split lines, description differences) before comparing of lines starts. With the mapping is possible to define also lines that should be ignored in the process of comparison (e.g. split lines, headers, date, and times).

The following comparators support mapping applications:

  • Advanced Report Comparator,

  • Report Comparator with Threshold

  • Default BAdI Report Comparator

  • Python Report Comparator

All comparators are applying the mapping on the report output in the same way by the same rules.

Mapping editor

The creation, deletion, update, or display of mapping can be done in two ways:

  1. Directly via SNP Validate report test variant: Type the name of the mapping (use F4 search help to display existing mapping) in the report test variant and double-click on the name. A new pop-up with the mapping editor will be displayed.

  2. Call transaction /DVD/VAL_REP_MAP: Choose a mapping on the selection screen (use F4 search help to display existing mapping) and execute. The mapping editor will be displayed.

The name of the mapping can be up to 30 characters long and should start with the letter Z (otherwise, it is not guaranteed that mapping will not be overwritten with the importing new SNP Validate version).

Deleting the mapping is enough to delete the content of the mapping in the editor.

The mapping with the name VALIDATE_PREDEF_MAP is the default predefined mapping distributed with SNP Validate. It is used when the checkbox Use Predefined Mapping is checked in the SNP Validate report test variant. The mapping can be displayed in the mapping editor but it is not recommended to change it! For your own mapping rules create a copy of the predefined mapping.

The mapping editor is an ALV table with a toolbar.

Except for standard ALV buttons for working with ALV (add/copy/paste/cut/delete line(s), sort lines, filter lines, etc.) some special buttons are on the toolbar. They have the following functions:

  • Display / Change: Switches between edit and display mode. If the mapping editor is in edit mode then the displayed mapping is locked by the user who is editing. Another user may only display such mapping.

  • Check (only in edit mode): Performs some checks for correctness on entered mapping. It will remove empty lines and sort the mapping based on the current line position. The check is always performed before each save to DB and before exporting to the CSV file. If some errors are found in the mapping then the mapping is not saved/exported and a pop-up with the error findings is displayed.

  • Export: Exports the mapping to a CSV file on the local PC. After pressing the button pop-up will be displayed for entering the path and filename. The CSV file will contain all columns from the editor.

  • Import (only in edit mode): Imports CSV file from local PC to the mapping editor. After pressing the button pop-up will be displayed for choosing the file. The CSV file has to contain a header line with at least one technical name of the column from the editor. If the mapping editor contains already some mapping a question pop-up is displayed asking if you want to overwrite the mapping in the editor or if you want to append imported mapping to it.

The mapping editor’s ALV table has the following columns [ with a technical name (with max. length) ]:

  • Mapping ID [MAP_ID(integer)]: Unique key of each mapping statement. The Mapping ID also represents an order of applying the mapping on the report output. The order can be changed by drag&drop within the report name, image type, variant ID, Test case, and test plan names. The ID is automatically re-calculated after saving any performed changes.

  • Report Name [REPORTNM(40)]: Used to set dependency of mapping statement on the report name. If it is empty then the mapping statement can be applied to any report output.

  • Image Type [IMG_TYPE(1)]: Used to set dependency of mapping statement on image type. If it is empty then the mapping statement is applied to the before and after image.

  • Mapping Function [MAP_FUNC(10)]: Name of mapping specific function which will be applied on each line of report output. The application depends also on function parameters in the mapping statement.

  • 1st Parameter of Mapping Function [FUNC_PARAM1(string)]: The meaning of the first parameter is function-specific.

  • 2nd Parameter of Mapping Function [FUNC_PARAM2(string)]: The meaning of the second parameter is function-specific.

Non-editable columns:

  • Changed At [CHANGED_AT(timestamp)]: Contains the date and time when the mapping statement was changed.

  • Changed By User [CHANGED_BY(12)]: Contains the user name who changed the mapping statement.

  • Created At [CREATED_AT(timestamp)]: Contains the date and time when the mapping statement was created.

  • Created By User [CREATED_BY(12)]: Contains the user name who created the mapping statement.

Hidden columns (displayed via changing ALV layout):

  • Report Test Variant ID [VARIANT_ID(13)]: Used to set dependency of mapping statement on SNP Validate report test variant ID.

  • Report Test Run ID [RUNID(10)]: Used to set dependency of mapping statement on SNP Validate test Run ID.

  • Test Plan Technical Name [PL_TECHNAME(20)]: Used to set dependency of mapping statement on SNP Validate test plan name.

  • Report Test Case Technical Name [TC_TECHNAME(20)]: Used to set dependency of mapping statement on SNP Validate test case name.

Reserved columns (internal usage):

  • Software Component [COMPONENT(30)]: Used to set dependency of mapping statement on SAP software component. The mapping statement is only applied if a software component exists on the system.

  • Software Component Release [COMP_RELEASE(10)]: Used to set dependency of mapping statement on SAP software component release. The mapping statement is only applied if a software component exists on the system in this release. If the value in the software component is not set then this dependency is ignored.

  • Software Component Support Package Level [COMP_SP_LEVEL(4)]: Used to set dependency of mapping statement on SAP software component SP level. The mapping statement is only applied if a software component exists on the system with this SP level. If the value in the software component is not set then this dependency is ignored.

ALV fields in column 1st Parameter of Mapping Function and 2nd Parameter of Mapping Function are editable up to 128 characters. To edit longer parameters always use a pop-up for editing parameters by double-clicking on the corresponding parameter field in the ALV. After closing the pop-up the parameter field in ALV internal table s updated with a new longer value.

Dependency of the mapping statements

The mapping statements can be created generically for all comparisons (all the dependency fields are blank) or comparisons specific to a defined report, variant, test run, test case, or test plan.

The comparison of the reports is applying the comparison-specific mapping statements concerning the following priority order:

  1. Variant ID

  2. Run ID

  3. Test plan name

  4. Test case name

  5. Report name

  6. Software component

  7. Component release

  8. Component SP level

Only one combination of the comparison-specific field values is applied during the comparison concerning the priority order with the following meaning: Combination of non-empty fields with higher priority determines the dependency.

Example:

Let’s assume a comparison of variant ID NSD0000006035, in test plan TP1, in test case TC1, for report RM07MTRB.

All following mapping statements may be applied in the comparison, but only statements with test plan value TP1 will be used.

It is because the test plan name in the combination variant ID + test plan name + report name has higher priority than the more general test case name in the combination variant ID + test case name + report name.

All mapping statements are automatically sorted and grouped by image type with respecting line position.

Mapping functions

The goal of the mapping functions is to make an automated comparison of the same report with a different layout or description easier. A mapping function defines a logic in which line in the report output will be processed and how it will be modified. Based on the value in the field “Image type”  (Relevant Image Type or IMG), the mapping function can be applied on:

  • Before image: value “B”

  • After image: value “A”

  • Both images: value “ “ (space)

Each mapping function is always processed on all report output lines before the next mapping function. The order of applying mapping functions is defined by mapping ID.

More mapping functions can be applied on the same line.

The following mapping functions are currently supported:

1. IGNO_EXACT: Ignore the line if it contains the same string as defined in the first parameter. The second parameter has to be empty!

2. IGNO_SUBST: Ignore the line if it contains a substring defined in the first parameter. The second parameter has to be empty!

3. IGNO_PATRN: Ignore the line if it matches a pattern defined in the first parameter. The second parameter has to be empty!

4. REPL_SUBST: Replace all substrings in the line. The substring which is searching is defined in the first parameter. In the second parameter is a defined string that will be used as a replacement.

5. REPL_WMASK: Replace characters with the mask. This function searches for a pattern defined in the first parameter. If a line matches the pattern then the function applies the mask (2nd parameter) on it.

6. REPL_REGEX: Replace all regex findings in the line. This function search for regex defined in the first parameter. If a regex match is found then is replaced with a string defined in the second parameter.

7. REPL_COLUM: Replace column order or add/delete column. This function search for the pattern defined in the first parameter. If the line matched the pattern then the function applies column order change on the line. The second parameter contains the column order.

8. CNCT_PATRN: Concatenate the line to the following line with another pattern. This function search for the pattern defined in the first parameter. If the line matched the pattern then the function search for the second pattern in the next line. The second pattern is defined in the second parameter. If also the second line matched the pattern then the function applies two-line concatenation.

9. IGNO_LINES: Ignore the line(s) on the position(s) defined in the first parameter. The second parameter has to be empty!

Each mapping function may have up to two parameters. The purpose of the parameter depends on a specific mapping function. In general, the parameter can have one of the meanings explained in the next parts.

Search for the substring [functions IGNO_SUBSTR and REPL_SUBSTR]

The functions search for lines that contain a substring set in the 1st parameter.

Example:

Original lines ------------------------------------------------------------------------------------------------- |Article Article Description Site Name 1 | |SLoc MvT S Art. Doc. Item Pstng Date Quantity in UnE EUn Ext. Amount LC Crcy | |-----------------------------------------------------------------------------------------------| Defined substring for replacement PARAM1: Article -> PARAM2: Material PARAM1: Description -> PARAM2: description PARAM1: Site -> PARAM2: Plnt PARAM1: Art. -> PARAM2: Mat. Result after replacement ------------------------------------------------------------------------------------------------- |Material Material description Plnt Name 1 | |SLoc MvT S Mat. Doc. Item Pstng Date Quantity in UnE EUn Ext. Amount LC Crcy | |-----------------------------------------------------------------------------------------------|

Search for a pattern [function IGNO_PATRN]

Some of the mapping functions allow you to use patterns in the 1st parameter to search for relevant lines. The SNP Validate search engine supports the following wildcards characters for the pattern definition:

  • * represents any character string

  • + represents any character

  • ! represents any alphanumerical character

  • # is the escape symbol for the wildcard characters

Upper/lower case is not taken into account.

Examples:

Original line: Blava Ledger 01 RFBILA00/UNAME Page 10 Define matching pattern */* Page * (it finds all lines with "/" sign before a word " page " or " Page ")

Search for a regex [function REPL_REGEX]

The function with this parameter definition searches for a line which is matching the regex pattern from the parameter. Extended regular expressions can be used by POSIX standard 1003.2. The regex pattern can be tested in the ABAP program DEMO_REGEX_TOY.

Apply mask [function REPL_WMASK]

The function REPL_WMASK identifies a line based on a pattern defined in parameter 1 and replaces the line by applying a character mask defined in parameter 2. The pattern in parameter 1 is defined in the same way as described above. The mask is using two special characters:

  • = is a special character keeping the original character in its position.

  • # is the escape symbol for the special character. Using the #= will use the = sign on the # position in the mask.

All other characters are used for replacing the characters in the output line on their position in the mask.

All spaces are shrinking to 1 space during the comparison. It means the comparison of texts “|* 00001100 ABC |” and “|* 00001100 ABC |” are considered equal.

Upper/lower case is not taken into account.

Example 1:

Original lines |Purch.Doc. SPlt Item S Quantity BUn Amt.in Loc.Cur. Crcy Order Quantity OUn Net Order Value Crcy | |1234567890 DC01 12 12 AB 123,45 ABC 1 ABC 123,45 ABC | Parameter 1 (mask definition): |+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++| Parameter 2 (change logic - add splitter "|" after each column and change 3 chars as of 64th char to "CDE"): |===========|====|====|=|========|========|====|===============|CDE=====|=====|========|====|===|===========|=========| Result after applying the mask (the logic is applied on every line starting and ending with "|") |Purch.Doc. |SPlt|Item|S| |Quantity|BUn |Amt.in Loc.Cur.|CDEy |Order|Quantity|OUn |Net|Order Value|Crcy | |1234567890 |DC01| 12| | | 12 |AB | 123,45 |CDE | | 1 |ABC | | 123,45 |ABC |

Example 2:

Apply for column order [function REPL_COLUM]

The function of this application changes the order of columns in the processed line. First, the line is split by the character | into columns. The original order of columns is marked from 1 to the last column. Then the function creates new line output as a concatenation of columns with column order based on the column indexes definition in the parameter of the function. All indexes in the definition have to be split by the character |. The first and last character in the definition has to be also character |. The maximum index of columns used in the definition has not exceeded the real number of columns. The minimum index of columns is 1. The same index can be repeated more than once. No index between two pipes (like | |) will create an empty column. The concatenated columns are separated with |. The first and last character in the result of the concatenation is also |. Columns are concatenated concerning spaces.

Allowed column orders in the definition for a line with 5 columns:
 |1|2|3|4|5|: Simple one
 |4|5|3|1|2|: Changed order
 | 1  |3   |2|   4| 5 |: Spaces are allowed
 |1|1|1|1|5|3|2|: Multiple replications of the same column, more columns in the result
 |4|: At least one column in the result
 |1|| |4|5|: Empty columns
 ||||||||||| |1|| |: Empty columns, more columns in the result

Not allowed column orders in the definition for the line with 5 columns:
1|2|3|4|5|: Missing pipe at the beginning of columns
|1|2|3|4|5: Missing pipe at the ending of column
|1|2 3|4|5: Missing pipe/not a number
|1|2|3|4|6|: Max. index of the column is exceeded
|abc|2|3|4 3|5|: Not a number/string used in the mask

Example:

Apply two lines of concatenation [function CNCT_PATRN]

The function of this application will join two consecutive lines. The result is concatenated to the first line and the second line is deleted.

Example:

Ignore line(s) [function IGNO_LINES]

The function of this application is very simple. It allows us to ignore and skip specified lines from the comparison. The line numbers provided in the report output can be used for reference. Only the first parameter is used and contains the selected line numbers, separated by a semi-column. No other characters, such as thousands separators, are allowed or needed.

Example (ignores first 5 lines)

Mapping log

The number of mapping functions applied is documented for each comparison within the comparison log.

Testing of mapping

Transaction /DVD/VAL_REP_MTEST was created for testing custom-specific mapping. On the selection screen of the transaction is possible to define a specific run, variant, or line for which the mapping should be tested. The parameter option Apply predefined mapping first will apply default mapping before custom mapping will be applied. A parameter Apply final row normalization will apply final correction on each line and display the line in the internal normalized form which is used for final comparison.

The execution of the transaction does not do any change on DB, it only writes an output with detailed information if and how the mapping was applied.