Create Substitution Variables

When you edit test data in the repository, you can use variables that are substituted when you publish the test data. Variables have the format ‘~variablename~’. The two types of substitution variables are Standard and User Defined. 
tdm41
When you edit test data in the repository, you can use variables that are substituted when you publish the test data. Variables have the format ‘~variablename~’. The two types of substitution variables are
Standard
and
User Defined
  • Standard
    variables are standard functions that you use to manipulate data when you publish.
    For example, ‘~SDATE~’ resolves to the current system date, and ‘~CDATE~’ resolves to the current date as defined in the project settings.
  • User Defined
    variables are created by the user and allow you to substitute specific application variables.
You can change the default value of a substitution variable when you publish the data.
Variable Scope
A variable is available only on the level where it was defined, and below. You add variables with datagroup, dataset, or datapool scope on the datagroup, dataset, or datapool level, respectively. Additionally, you can add variables with project or even repository scope from any level. A variable on repository level has the widest scope and it is accessible in all projects.
Example:
You create a variable
abc
at project level and set its value to
~CD~
. You create another variable
abc
at dataset level and set its value to
123
. At datapool and dataset level,
abc
 now resolves to
123
. At datagroup and project level,  
abc
 resolves to
~CD~
. The variable is only accessible in the one project where it was defined.
Variable Resolution
A variable value can be dynamic, for example, if it is a function such as
@randrange(1,20)@
. If a variable is used multiple times within a row, and the table repeat count is larger than 1, and the variable value is dynamic, you must define how and when Datamaker resolves the repeated variable. In the New Variable dialog, choose
one
of the following behaviors:
  • No selection (default)  —  The repeated variable is resolved each time it is used. 
  • Resolve Prior to Publish — The repeated variable is resolved once per publish and the value is the same in all rows.
  • Resolve Per Published Row — The variable is resolved once per row and the value is the same within one published row. Values can be different in other rows.
Create Substitution Variables
  1. Open the Datamaker UI and choose 
    Projects, Project Manager
    from the main menu.
  2. Navigate the hierarchy in the left pane and drill down to either project, datagroup, dataset, or datapool level.
  3. Click
    Variables
    .
    All the variables available on this level are displayed in the right pane.
  4. Right-click in the right pane and select
    New Variable
    from the context menu.
  5. Specify variable details in the dialog.
  6. Validate the variable by clicking the tick mark icon in the
    Validation
    area. 
    The available validation functions are as follows:
    • IN(…,…)
      Specifies that the only valid values are in this list.
    • MIN(…)
      Specifies that the value cannot be less than this value.
    • MAX(…)
      Specifies that the value cannot be more than this value.
    • RANGE(…,…)
      Specifies that the value must be within this range.
  7. Save your changes.
Create Substitution Variables Dynamically
If you enter a substitution variable into your data as it is being edited,
Test Data Management
 verifies whether it already exists. If it does not exist, it prompts you to create a new variable. You can perform one of the following actions:
  • Ignore
    If you ignore the message, you can return later to create a substitution, or enter a value during data publishing.
  • Edit Data
    If you edit the data, you can correct or remove a variable.
  • Create Substitution
    If you click
    Create Substitution
    , you are prompted to add the substitution to the local level (Set Level) or to the global (Project) level. If no local level exists, the substitution is created for you. 
Available standard substitution variables are as follows:
  • ~CD~
    Specifies the day of the current date.
  • ~CDATE~
    Specifies the user-specified current date as defined in the project settings.
  • ~CM~
    Specifies the current month.
  • ~COLNUM~
    Specifies the ordinal position of the column in the table.
  • ~COLUMN_NAME~
    Specifies the name of the column in the table that you are editing.
  • ~CY~
    Specifies the year of the current date.
  • ~EMPTY~
    Shows an empty string.
  • ~ITERATION~
    Specifies when you publish data multiple times using either a control file or by entering the number of iterations in the publish screen.
  • ~LD_DESC~
    Specifies the description of the publish details.
  • ~LD_ID~
    Specifies the numeric ID of the publish level.
  • ~LD_NAME~
    Specifies the name of the publish level.
  • ~MAX~
    Changes the maximum value in a cell.
  • ~NEXT~
    Specifies that the next highest value of the column is found when you publish the data.
    Note:
    ~NEXT~ can only be used in one column per table.
  • ~NEXTSUB~
    Specifies that the function is used with ~NEXT~ if a multi-part key is used. When the ~NEXT~ value is set, the next part of the key is set to 1 and incremented until the ~NEXT~ value is updated.
  • ~PUBROW~
    Specifies the published row number. The published row number is a combination of the rownum plus the iteration minus one times the total number of rows to be published.
  • ~ROWNUM~
    Specifies the number of the row for the table.
  • ~SDATE~
    Specifies the date as defined by the system.
  • ~SDATETIME~
    Specifies the date and time as defined by the system.
  • ~SPACE~
    Enters a space within a string.
  • ~STIME~
    Specifies the time as defined by the system.
  • ~STIMESTAMP~
    Specifies the time as defined by the system, to fractions of a second.
  • ~TABLE_NAME~
    Specifies the name of the table you are editing.
  • ~USER~
    Specifies the CA TDM user for the Datamaker UI.
  • ~WINUSER~
    Specifies the Windows user that is logged in.