(DV-2211) Conversion Rules

The conversion rules functionality provided by Validate offers another option how data can be adjusted to allow seamless usage in complex transformation scenarios. It enables you to define a conversion rule applied on key and value fields, to be used during the comparison of data images.

Before the rule is set, the relevant variant must be created. By using the “Set Conversion rules” button in advanced settings, rules can be assigned and defined.

The functionality provides you with two types of rules

·       ABAP rule

·       Value mapping.

 It is possible to use both options within the same variant, but only one rule can be defined for each field in the data image.

 

The ABAP rule allows the runtime execution of a piece of ABAP code which enables users to create their own conversion of a field value. To be able to use conversion ABAP rules, the impacted field must be filled in the key or value fields of the variant. This is an advanced feature; it is expected that the user has at least basic knowledge of the ABAP syntax and coding.

In case of rules where data is selected from the database, caution is advised. The code is executed for every line of the data image. Therefore, all accesses to the DB should be optimized. It is recommended to use STATIC local variables to store this kind of content. Using this approach, the data only needs to be selected once and will be reused in every following line evaluation.

 

To create an ABAP rule, click on the insert row button.

First, fill in the Field name (specifies to which column, the rule should be applied), then fill in the Rule Type A (ABAP rule) and the rule name. The ABAP rule name is restricted to a Z prefix for those created by the customer.

 

The ABAP code of an ABAP rule can be opened by double-clicking on its name. If the ABAP rule doesn't exist, a pop-up will ask for confirmation to create it. Each field of a table can have a maximum of one ABAP Conversion Rule defined in a Variant.

The ABAP editor is opened, which allows the edition of the code.

 

The code's syntax can be checked with the Check syntax button.

 

The code can be pretty printed by clicking on the “Pretty print” button.

 

By clicking on the “Confirm” button, the code will be saved regardless of the validity of its syntax to allow for continuous writing of the ABAP.

 

By clicking on the “Cancel” button, all the changes made for the code from the last confirmation will be discarded. A Variant can be saved with a syntactically incorrect ABAP rule, at saving a warning pop-up will inform the user of the code's incorrectness.

 

The code of the ABAP rule is locked. Only a part of the form is editable, where the ABAP conversion rule code should be written. The user is able to access the context class within the form. Furthermore, the original table line, converted table line, field name and changed value are available as well.

Available information from the context class

  • lo_run_ctx->A_VARIANT_ID - after image id

  • lo_run_ctx->INITIALIZED - is context class initialized

  • lo_run_ctx->LAST_START_TIMESTAMP - the timestamp of the last run

  • lo_run_ctx->PL_TECHNAME - testplan technical name

  • lo_run_ctx->RFC_DEST - RFC destination of the Variant

  • lo_run_ctx->RUNID - runID of the Variant execution

  • lo_run_ctx->START_TIMESTAMP - timestamp of the start of the run

  • lo_run_ctx->TC_TECHNAME - testcase technical name 

  • lo_run_ctx->TC_TYPE - testcase type

  • lo_run_ctx->VARIANT_ID - VariantID

  • lo_run_ctx->TABLE_NAME - tablename for the Variant (30c)

  • lo_run_ctx->ROWCOUNT - is rowcount selected

  • lo_run_ctx->STORAGE_ID - StorageID for SM Table Variant

  • lo_run_ctx->T_FIELD_MAPPING - table of Field Mapping definition

  • lo_run_ctx->T_CHAR_FIELD - table of selected key fields of the Variant

  • lo_run_ctx->T_KYF_FIELD - table of selected value fields of the Variant

  • lo_run_ctx->T_TAGS - table with Variant TAGs

  • lo_run_ctx->EXT_TABNAME_LONG - external table name for SM Table Variants

  • lo_run_ctx->T_DYN_FLT - table with Dynamic Filters of the Variant

  • lo_run_ctx->T_CONTENT - table of DF ABAP codes  

 

The Value Mapping gives the ability to apply simple mapping within the comparison task.

No logic is required, only a list of old and new values corresponding to one another needs to be provided.

 

  To create a value mapping rule, click on the insert row button.

First, fill in the field name (specifies to which column value mapping should be applied), then fill in the rule type V (value mapping rule) and then the rule name. The rule name is restricted to a Z prefix for those created by the customer.

The mapping can be opened by double-clicking on the rule name. If the rule doesn't exist, a pop-up will ask for confirmation to create it. Column “Old value” specifies the value to be replaced. Column “New value” represents the value to which the corresponding old value which change.