Hitachi

JP1 Version 12 JP1/Client Process Automation Configuration and Administration Guide


B.2 How to use environment variables when an item is executed

When an item in a job is executed, CPA can reference the information of the job through environment variables. This section describes how to use environment variables when an item is executed.

Organization of this subsection

(1) Environment variables when an item is executed

When you execute commands from items, such as Command execution and Command execution in window, that are executed in a job of CPA, the environment variables listed in the following table can be used.

Table B‒1: Environment variables when an item is executed

No.

Environment variable

What value is specified

1

CPAJDS

Job name

A value specified in Job name when the job is registered.

2

CPAJCS

Job execution ID

A string of 36 half-width alphanumeric characters (hexadecimal numbers), assigned by CPA when an execution schedule is generated. The ID does not conflict with job execution IDs of other jobs and in the execution results in the past.

Example: e66bf2f5-b920-4faf-b1f0-a56418af4682

The environment variables (CPAJDS and CPAJCS) can be referenced within commands that CPA executes. For example, if a batch file is executed as a command, the environment variables are specified in the batch file.

They can also be used by defining them in the parameter of the command to be executed. The following table lists the setting items where the environment variables (CPAJDS and CPAJCS) can be defined.

Table B‒2: Setting items where the environment variables (CPAJDS and CPAJCS) can be defined

No.

Type

Item name

Possible setting item

1

Action

Command execution

Parameter

2

Command execution by list

Parameter

3

Command execution with recovery option

Parameter

Parameter for the recovery execution command

4

Command execution in window

Parameter

5

Send mail

--

6

Windows log on

--

7

Event monitor

Monitor file

--

8

Monitoring mail reception

--

9

Monitor any event

Parameter

10

Monitor Windows event

--

11

Execution condition

Monitor file event

--

12

Event monitoring for receiving mail

--

13

Monitor any event

Parameter

14

Monitor the linkage from JP1AJS3

--

15

Monitor Windows event

--

Legend:

-- : There is no setting item that can be defined.

(2) Usage example

In this example, the results from actions in an action flow are output to a temporary file, and subsequent actions reference the contents of the file.

At this time, use the environment variables (CPAJDS and CPAJCS) to create a file with a unique name for each job, so that the name of the temporary file used in the action flow does not conflict among multiple jobs that use the same action flow.

Command execution in window
Execution command:
cmd
Parameter:
/c sample1.bat >c:\temp\%CPAJDS%_%CPAJCS%.txt
sample1.bat contains:
@echo off
echo %DATE% %TIME%
echo CPAJDS:%CPAJDS%
echo CPAJCS:%CPAJCS%
cpasleep 10
Command execution
Execution command:
cmd
Parameter:
/c sample2.bat c:\temp\%CPAJDS%_%CPAJCS%.txt
sample2.bat contains:
@echo off
echo %DATE% %TIME%
echo FILE:%1
echo ----------
type %1
echo ----------

The following shows an example of executing the above action flow as a job with the job name of sampleA:

  1. The first Command execution in window action creates the following file.

    Job executed

    Job name: sampleA

    Job execution ID: cabc71f3-d402-4869-a651-1084fe7b7ae5

    Name of the file to be created

    c:\temp\sampleA_cabc71f3-d402-4869-a651-1084fe7b7ae5.txt

    Explanation

    One variable %CPAJDS% is replaced with the job name sampleA, and another variable %CPAJCS% with the job execution ID cabc71f3-d402-4869-a651-1084fe7b7ae5.

  2. The output result of the following action Command execution shows the contents of the file created by the first action. Note that the output result can be viewed in the Execution result dialog box opened from the Checking the status dialog box in the CPA Job Design View.

    Output result:

    2020/09/25 15:19:46.03
    FILE:c:\temp\sampleA_cabc71f3-d402-4869-a651-1084fe7b7ae5.txt
    ----------
    2020/09/25 15:19:35.59
    CPAJDS:sampleA
    CPAJCS:cabc71f3-d402-4869-a651-1084fe7b7ae5
    ----------