(DV-2011) 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 same layout (e.g. column orders, headers differences , spited lines, description differences) before comparing of lines starts. With the mapping is possible to define also lines which 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 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. New popup window with the mapping editor will be displayed.

  2. Call transaction /DVD/VAL_REP_MAP - chose a mapping on 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 letter 'Z' (otherwise is not guarantied 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 name ‘VALIDATE_PREDEF_MAP’ is default predefined mapping distributed with validate. It is used when checkbox 'Use Predefined Mapping' is marked in Validate report test variant. The mapping can be displayed in the mapping editor but it is not recommend to change it!

The mapping editor is ALV table with a toolbar.

Except standard ALV buttons for working with ALV (add/copy/paste/cut/delete line(s), sort lines, filter lines, …) some special buttons are on the toolbar. They have 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 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 priority criteria. The check is always performed before each save to DB and before exporting to CSV file. If some errors are found in the mapping then the mapping is not saved/exported and 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 path and filename. The CSV file will contains 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 header line with at least one technical name of the column from the editor. If 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.

Mapping editor’s ALV table has following columns [ with technical name (with max. length ) ]:

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

  • Report Name [REPORTNM(40)] - used to set dependency of mapping statement on report name. If it is empty then the mapping statement can be applied on 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 on 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 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 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 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 software component exists on the system in this release. If 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 software component exists on the system with this SP level. If 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 character. To edit longer parameter always uses popup for editing parameters by double click on corresponding parameter field in the ALV. After closing popup the parameter field in ALV internal table s updated with 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 form the mapping,

Dependency of mapping statements for the specific comparison can be set by combination of dependency fields in the statement with the respect of 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 following meaning: combination of non-empty fields with higher priority determine the dependency.

Example:

Let’s assume 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 test plan name in the combination “variant ID + test plan name + report name” has higher priority than more general test case name in the combination “variant ID + test case name + report name“.

All mapping statement are automatically sorted and grouped by dependency combination with higher priority after each pressing of check button in the mapping editor.

Mapping functions

Mapping function defines which and how a line in the report output will be modified to remove layout differences between before and after image. 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 next mapping function. The order of applying mapping functions is defined by mapping ID. More mapping function 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 specific mapping function. In general, the parameter can have one of the meaning explained in next parts.

Search for exact string

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

Search for substring

The function with this parameter definition search for line which is containing 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 search for line which is matching pattern from the parameter. The pattern may contains 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 search for line which is matching 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 character mask with 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 of characters in output line on same position. The special character can be set for direct replace 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 column order

The function with this application change the order of columns in the processed line. First the line is splited by character ‘|' to columns. Original order of columns is marked from 1 to last one column. Then the function creates new line output as concatenation of columns with column order based on column indexes definition in the parameter of the function. All indexes in the definition has to be spitted by character ‘|’. The first and last character in the definition has to be also character ‘|’. Maximum index of columns used in the definition has not to exceed the real number of columns. Minimum index of columns is 1. Same index can be repeated more then once. No index between two pipes (like ‘| |’) will create empty column. The concatenated columns are separated with ‘|’. The first and last character in the result of concatenation is also '|’. Columns are concatenated with respecting of spaces.

Allowed column orders in the definition for 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 replication of same column, more columns in result
 |4| - at least one column in result
 |1|| |4|5| - empty columns
 ||||||||||| |1|| | - empty columns, more columns in result

Not allowed column orders in the definition for 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 column is exceeded
|abc|2|3|4 3|5| - not a number/string used in the mask

Example:

Apply two lines 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

Number of mapping function 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 specific run, variant or line for which the mapping should be tested. 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 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 write output with detail information if and how the mapping was applied.