All Products
Search
Document Center

Dataphin:Create a variable group and global variable

Last Updated:Jan 21, 2025

Dataphin enables the creation of global variables, streamlining task code by eliminating redundant definitions and reducing maintenance efforts. These global variables come with permission controls and code review features, bolstering security. This topic outlines the steps to create a variable group and a global variable.

Create a variable group

A variable group organizes variables for simplified management and retrieval.

  1. Navigate to the Dataphin home page and select Planning from the top menu bar.

  2. Refer to the instructions in the figure below to access the Create Variable Group dialog box.

    image

  3. In the Create Variable Group dialog box, enter the Variable Group Name and Variable Group Code as detailed in the table below.

    Parameter

    Description

    Variable Group Name

    Assign a unique name to the variable group, adhering to the following criteria:

    • Must be globally unique.

    • Cannot exceed 64 characters in length.

    Variable Group Code

    Create a distinctive code for the variable group, subject to the following conditions:

    • Must be globally unique.

    • Can include numbers, letters, and underscores.

    • Cannot exceed 64 characters in length.

  4. Click OK to finalize the variable group creation.

Create a global variable

  1. On the Common Business Logic page, within the Global Variable tab, click Create Global Variable.

  2. In the Create Global Variable dialog box, set the global variable parameters as outlined below.

    The system supports various variable types such as Common Variable, Datetime, and Account Password, each with specific configurations. The parameters for each variable type are described as follows:

    • Variable Type is selected as Common Variable or Account Password

      Area

      Parameter

      Description

      Basic Information

      Variable Name

      Customize the variable name, ensuring it does not exceed 64 characters.

      Variable Group

      By default, the Default Variable Group is selected. You can choose other variable groups from the drop-down list with a single click.

      Code

      Customize the code, which serves as the variable's reference name. It begins with the fixed prefix dp_glb. The code must adhere to the following criteria:

      • Must be globally unique.

      • Can only contain numbers, letters, and underscores.

      • Must not exceed 64 characters, including the prefix dp_glb_.

      Note

      The code is case-insensitive; uppercase letters will automatically be converted to lowercase.

      Permission Control

      When activated, permission is required to access the newly created global variable for the first time.

      Code Review

      When enabled, a code reviewer can be designated. Approval from the code reviewer is mandatory for any code submissions that reference the global variable.

      Description

      Provide a description for the global variable as needed.

      Variable Value

      Production and Development Environment Isolation

      • Disabled: A single variable value is utilized across both production and development environments.

      • Enabled: Distinct values can be set for production and development environments. The development value is used during debugging, while the production value is applied during scheduled production runs and manual operations.

      Variable Value

      Assign the variable value for the production or development environment. Note that the value is case-sensitive.

      • Common Variable: Limited to a maximum of 512 characters.

      • Account Password: Limited to a maximum of 5000 characters.

    • Variable Type is selected as Datetime Variable

      Area

      Parameter

      Description

      Basic Information

      Variable Name

      Customize the variable name, ensuring it does not exceed 64 characters.

      Code

      Customize the code, which serves as the variable's reference name. It begins with the fixed prefix dp_glb. The code must adhere to the following criteria:

      • Must be globally unique.

      • Can only contain numbers, letters, and underscores.

      • Must not exceed 64 characters, including the prefix dp_glb_.

      Note

      The code is case-insensitive; uppercase letters will automatically be converted to lowercase.

      Variable Group

      By default, the Default Variable Group is selected. You can choose other variable groups from the drop-down list with a single click.

      Permission Control

      When activated, permission is required to access the newly created global variable for the first time.

      Code Review

      When this feature is activated, you can designate a code reviewer who must approve the submission if it includes references to a global variable.

      Description

      Provide a description for the global variable as needed.

      Variable Value

      Production and Development Environment Isolation

      • Disabled: A single variable value is utilized across both production and development environments.

      • Enabled: Distinct values can be set for production and development environments. The development value is used during debugging, while the production value is applied during scheduled production runs and manual operations.

      Baseline Date Type is set to Data Timestamp (bizdate-yyyymmdd).

      This applies to all tasks.

      • Variable Output Format: Defines the output format for the calculated datetime variable. Click the drop-down list to select from the following formats:

        • yyyyMMdd: YYYYMMDD, e.g., 20220604.

        • yyyy-MM-dd: YYYY-MM-DD, e.g., 2022-06-04.

        • yyyy/MM/dd: YYYY/MM/DD, e.g., 2022/06/04.

        • yyyyMMddHHmmss: YYYYMMDDHHMMSS, e.g., 20220604000000.

        • yyyy-MM-dd HH:mm:ss: YYYY-MM-DD HH:MM:SS, e.g., 2022-06-04 00:00:00.

        • unixtimestamp: UNIX timestamp, representing the number of seconds since January 1, 1970, 00:00:00 UTC, e.g., 1654272000 for 2022-06-04 00:00:00.

      • Quick Date Selection: Provides common variable dates.

        Once Quick Date Selection is configured, the corresponding calculation logic is auto-filled in Variable Date. You can also customize the Variable Date.

      • Preview Baseline Date: The baseline date used to preview the variable value, solely for previewing configuration effects.

      • Variable Date: Determines the variable's calculation logic using the baseline date as input and allowing for offsets in Year, Quarter, Month, Week, and Day dimensions.

        If Add Offset Time is used, each row's input date is the output date from the previous row's calculation.

        After configuring Variable Date:

        • In Date Preview, you can view the date result of this row's calculation.

        • In Variable Output Format, see the variable value post-calculation for this row, displayed according to the selected Variable Output Format.

      Baseline Date Type is set to Business Time (bizdatetime-yyyymmddhhmmss)

      Applicable only to tasks that are scheduled by the hour and minute.

      • Variable Output Format: Defines the output format for the datetime variable after calculation. To select a format, simply click on the drop-down list. Available formats include:

        • yyyyMMdd: YYYYMMDD, e.g., 20220604.

        • yyyy-MM-dd: YYYY-MM-DD, e.g., 2022-06-04.

        • yyyy/MM/dd: YYYY/MM/DD, e.g., 2022/06/04.

        • yyyyMMddHHmmss: YYYYMMDDHHMMSS, e.g., 20220604000000.

        • yyyy-MM-dd HH:mm:ss: YYYY-MM-DD HH:MM:SS, e.g., 2022-06-04 00:00:00.

        • unixtimestamp: UNIX timestamp, representing the number of seconds since January 1, 1970, 00:00:00 UTC. For instance, the UNIX timestamp for 2022-06-04 00:00:00 is 1654272000.

      • Quick Date Selection: Provides commonly used variable dates.

        Once Quick Date Selection is configured, the corresponding calculation logic is automatically populated in Variable Date. You may also customize the Variable Date as needed.

      • Preview Baseline Time: Displays the baseline time for previewing the variable value, used exclusively for previewing configuration effects.

      • Variable Date: Specifies the variable's calculation logic, taking the baseline date as input and allowing offsets in the dimensions of Year, Quarter, Month, Week, and Day.

        If Add Offset Time is applied, each row's calculation input date is the output date from the previous row's calculation.

        After configuring Variable Date:

        • In Date Preview, you can view the date resulting from this row's calculation.

        • In Variable Output Format, the variable value after this row's calculation is displayed according to the selected Variable Output Format.

      • Quick Time Selection: After configuring Quick Time Selection, the corresponding calculation logic is automatically populated in Variable Time. You may also customize the Variable Time settings as needed.

      • Variable Time: Defines the calculation logic for the variable, using the reference date as input and performing offsets in the dimensions of Day, Hour, Minute, and Second.

        If Add Offset Time is enabled, the input date for each row's calculation is the output date from the previous row's calculation.

        After configuring Variable Time:

        • In Time Preview, view the time obtained from this row's calculation.

        • In Variable Output Format, view the variable value after this row's calculation, displayed in accordance with the chosen Variable Output Format.

  3. Click OK to finalize the creation of the global variable.