JOBNAME: Retrieving the Current Process Identification String

How to:

The JOBNAME function retrieves the raw identification string of the current process from the operating system. This is also commonly known as a process PID at the operating system level. The function is valid in all environments, but is typically used in Dialogue Manager and returns the value as an alphanumeric string (even though a PID is pure numeric on some operating systems).

Note: JOBNAME strings differ between some operating systems in terms of look and length. For example, Windows, UNIX, and z/OS job names are pure numeric (typically a maximum of 8 characters long), while an OpenVMS job name is a hex number (always 8 characters long), and an IBM i job name is a three-part string that has a 26 character maximum length. Since an application may eventually be run in another (unexpected) environment in the future, it is good practice to use the maximum length of 26 to avoid accidental length truncation in the future. Applications using this function for anything more than simple identification may also need to account for the difference in the application code.

Syntax: How to Retrieve the Current Process Identification String

JOBNAME(length, output)

where:

length

Integer

Is the maximum number of characters to return from the PID system call.

output

Alphanumeric

Is the returned process identification string, whose length depends on the platform on which the function is issued. Provide a length as long as required for your platform. Otherwise, the output will be truncated.

Example: Retrieving a Process Identification String

The following example uses the JOBNAME function to retrieve the current process identification string to an A26 string and then truncate it for use in a -TYPE statement:

-SET &JOBNAME = JOBNAME(26, 'A26');
-SET &JOBNAME = TRUNCATE(&JOBNAME);
-TYPE The Current system PID &JOBNAME is processing.

For example, on Windows, the output is similar to the following:

The Current system PID 2536 is processing.