(DV-2105) ERP Report Mapping

The mapping helps to distinguish 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).

Following comparators support mapping applying:

  • 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 Validate report test variant - type a 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 popup window with the mapping editor will be displayed.

  2. Call transaction /DVD/VAL_REP_MAP - chose 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 mapping can be up to 30 characters long and should start with the letter 'Z' (otherwise is not guaranteed that mapping will not be overwritten with the importing new Validate version).

To delete 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 validate. It is used when the checkbox 'Use Predefined Mapping' is marked in Validate report test variant. The mapping can be displayed in the mapping editor but it is not recommended to change it!

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 - switch 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) - perform some check 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 popup with the error findings is displayed.

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

  • Import (only in edit mode) - will import CSV file from local PC to the mapping editor. After pressing the button popup 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 popup is displayed asking if you want to overwrite the mapping in the editor or 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 ) ]:

  • Report mapping ID [MAP_ID(integer)] - unique key of each mapping statement which represents also an order of applying on the report output. It is automatically re-created after each check with respect to the line order created by the user.

  • 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 applying depends also on function parameters in the mapping statement

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

  • 2nd Parameter of Mapping Function [FUNC_PARAM2(string)] - 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 user name who changed 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 user name who created mapping statement

Hidden columns (displayed via changing ALV layout):

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

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

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

  • Report Test Case Technical Name [TC_TECHNAME(20)] - used to set dependency of mapping statement on 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 parameter always uses popup for editing parameters by double click on corresponding parameter field in the ALV. After closing the popup the parameter field in ALV internal table s updated with a new longer value.

Mapping statements

The mapping may contain more mapping statements for more reports, variants, test runs, test cases, or test plans. Only comparison’s specific mapping statements are used from the mapping,

The dependency of mapping statements for the specific comparison can be set by a combination of dependency fields in the statement with respect to 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 dependency field values is applied while comparison with the respect of priority order with the following meaning: a 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 mapping function defines which and how a line in the report output will be modified to remove layout differences between before and after images. If the mapping function is applied on before or after image or both depends on the value of image type in the mapping statement. 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.

Following mapping functions are currently supported:

1. IGNO_EXACT - Ignore line if it contains exact string defined in the first parameter. Second parameter has to be empty!

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

3. IGNO_PATRN - Ignore line if it matches a pattern defined in the first parameter. 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 defined string which will be used as replacement.

5. REPL_WMASK - Replace characters with the mask. This function search for pattern defined in the first parameter. If line matched the pattern then function applies mask on it. The mask is defined in the second parameter.

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

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

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

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 an exact string

The function with this parameter definition search for line which has the same content as the parameter.

Search for substring

The function with this parameter definition searches for a line that contains a substring from the 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 pattern

The function with this parameter definition searches for a line which is matching the pattern from the parameter. The pattern may contain all characters. Upper/lower case is not taken into account. Wildcard characters can be used for forming the pattern, where ‘*' represents any character string, ‘+’ represents any character, and ‘!’ represents any alphanumerical character. The wildcard character can be set for direct comparison by adding the escape symbol '#’ before it.

Examples:

Original line: Blava Ledger 01 RFBILA00/UNAME Page 10 Define mathing pattern *+/+* Page *+* Original line:

Search for 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 in accordance with POSIX standard 1003.2. The regex pattern can be tested in the ABAP program DEMO_REGEX_TOY.

Apply mask

The function with this parameter definition is applying a character mask with the preservation of character position. A special character '=' can be used in the mask to define character position which should be preserved. All other characters are used for replacing characters in the output line in the same position. The special character can be set for direct replacement by adding the escape symbol '#’ before it.

Example:

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 | Defined mask |===========|====|====|=|========|========|====|===============|CDE=====|=====|========|====|===|===========|=========| Result after applying the mask |Purch.Doc. |SPlt|Item|S| |Quantity|BUn |Amt.in Loc.Cur.|CDEy |Order|Quantity|OUn |Net|Order Value|CDEy | |1234567890 |DC01| 12| | | 12 |AB | 123,45 |CDE | | 1 |ABC | | 123,45 |CDE |

Apply for column order

The function of this application changes the order of columns in the processed line. First, the line is split by the character ‘|' to columns. The original order of columns is marked from 1 to the last one column. Then the function creates new line output as a concatenation of columns with column order based on 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 with respecting of 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 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

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

Example:

Mapping log

The number of mapping functions applying is counted while comparison. The results are written to 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 comparing.

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