A job variable can replace parts of commands or statements. SDF replaces the job variable with its value prior to execution. The resulting input is checked syntactically by SDF.
Job variable replacement is possible in unguided dialog, in procedures and in batch operation. In (temporary) guided dialog, replacement is only permissible in the NEXT line and in the input for operand values.
The job variable is specified:
directly by its name in the form "
&(jv-name)"
.indirectly by its job variable link name in the form "
&(*jv-link)"
. Prior linkage of the link name with the job variable takes place via the commandSET-JV-LINK LINK-NAME = jv-link, JV-NAME = jv-name
.
Note
Before job variable replacement, ACS, if required, replaces the alias of a JV by its real path name (in accordance with the alias catalog entry).
The following restrictions apply to job variable replacement:
An expression can be replaced only by a job variable in its full length.
The job variable to be used must have read access, otherwise the input is rejected as a syntax error.
Replacement is not possible within CJC command sequences.
Job variables cannot be substituted for input data. SDF treats statements intended for programs with SDF interface like commands and not like input data.
In procedures or ENTER files, job variables cannot replace the leading slash that precedes commands or the two leading slashes that precede statements, the leading period of non-S-marks, the semi-colon as command separator and continuation mark.
Job variables cannot be used as procedure parameters.
This restriction may be circumvented, e.g. by using a link name (see Example 2 below).Expressions cannot be nested.
In interactive mode, JV-REPLACEMENT=*AFTER-BUILTIN-FUNCTION is set; i.e. job variable replacement in the form shown above is performed only if no identically named S variable or built-in function is known. The replacement is performed in the order: S variable, built-in function, and, finally, job variable.
When a user or catalog ID is entered in the job variable name, a job variable is uniquely referenced.
Job variable replacement in S procedures is affected by the JV-REPLACEMENT setting in the SET-PROCEDURE-OPTIONS command in the following manner:
In S procedures, JV-REPLACEMENT=*NONE is preset; i.e. only S variables or built-in functions are replaced in the specified order.
The JV-REPLACEMENT setting can be changed by means of the operand of the same name in the SET-PROCEDURE-OPTIONS command in S procedures. When JV-
REPLACEMENT=*AFTER-BUILTIN-FUNCTION is set, incompatibilities can be
avoided if the JV name is specified with the user ID and/or catalog ID in the previous form of job variable replacement.
Job variable replacement is also possible using the built-in function JV(). In this case, it is specified in the form "&(JV(JV-NAME=string_expression,...))
". Specification of a subarea is permissible and optional. See also built-in function JV() in the manual
“Commands” [ 1].
Example 1: Replacement in dialog
/cre-jv jv=cmd ———————————————————————————————————————————————————— (1) /mod-jv jv=cmd,set-value='SHOW-FILE-ATTR' ———————————————————————————— (2) /&(cmd) ——————————————————————————————————————————————— (3) % 3 :2OSG:$USER1.ALT.SYS.LOGON.USERPROC.X1 % 51 :2OSG:$USER1.ALT.SYSSDF.USER.EXAMPLE.1 % 21 :2OSG:$USER1.DATEI.1 % 48 :2OSG:$USER1.DATEI.2 % 84 :2OSG:$USER1.DATEI.3 % 66 :2OSG:$USER1.OUT.SORT1-2 % 3 :2OSG:$USER1.PROC.JV %:2OSG: PUBLIC: 7 FILES RES= 276 FRE= 39 REL= 21 PAGES /mod-jv jv-=cmd,set-value='-FILE-ATTR FILE-NAME=PROC.' ——————————————— (4) /set-jv-link link-name=cmdlink,jv-name=cmd ———————————————————————————— (5) /sh&(*cmdlink) % 3 :2OSG:$USER1.PROC.JV ———————————————————————————————————— (6) %:2OSG: PUBLIC: 1 FILE RES= 3 FRE= 2 REL= 0 PAGES
(1) | The job variable name 'CMD' is created. |
(2) | The job variable CMD contains the value “SHOW-FILE-ATTR”. |
(3) | After the command has been sent, the variable string is replaced by the command defined in the job variable and the command is executed. Note The job variables are replaced because no S variables or built-in function with the name “CMD” exists. If a user ID or catalog ID is used in the job variable name (e.g. “ |
(4) | The value of the job variable CMD is changed. It now only contains a part of the command name “-FILE-ATTR” and the partially qualified file name “PROC.”. |
(5) | The link name “CMDLINK” is assigned to the job variable CMD. |
(6) | After the command has been sent, the variable string is replaced by the command part assigned to the job variable and the command is executed. The reference to the job variable is formed by the link name. |
Example 2: Replacement in a non-S procedure
/BEGIN-PROC PAR=YES(PROC-PAR=(&PARAM1)) ——————————————————————————————— (1) . . /SET-JV-LINK LINK-NAME=PARAM1,JV-NAME=&PARAM1 —————————————————————————— (2) /&(*PARAM1) FILE-NAME=LST.JOB ———————————————————————————————————— (3) . . /END-PROC
(1) | The job variable specified by the procedure parameter PARAM1 is to contain the command to be executed in each case. Since the specification “&(&PARAM1)” is not permissible, the alternate route via a link name is taken. |
(2) | The current job variable name is used for the procedure parameter PARAM1 and is linked with the link name PARAM1. |
(3) | The contents of the specified job variable are used for the link name PARAM1. If, for example, the job variable contains the value PRINT-DOCUMENT the file LST.JOB is printed out. |
Example 3: Replacement in an S procedure
S procedure sproc:
/ SET-PROC-OPT JV-REPLACE=*AFTER-BUILTIN —————————————————————— (1) / DECL-PAR JV-1(INIT=*PROMPT) —————————————————————————————— (2) / &(JV(JV-NAME=JV-1)) FILE-NAME=LST.JOB —————————————————————— (3) /FEHL: IF-BLOCK-ERROR / WRITE-TEXT C'** Error &MC **' / ELSE / WRITE-TEXT C'** Command &(&(JV-1)) executed **' / END-IF —————————————————————————————————————————————————————— (4) /ENDE: EXIT-PROC
Calling the sproc procedure:
/create-jv jv=jv.command /modify-jv jv=jv.command,set-val='SHOW-FILE-ATTRIBUTES' /call-proc sproc %JV-1: jv.command % DMS0533 REQUESTED FILE NOT CATALOGED IN PUBSET '1OSN'. COMMAND TERMINATED % SDP0004 ERROR DETECTED AT COMMAND LINE: 3 IN PROCEDURE':1OSN:$USER1.SPROC' ** ERROR DMS0533 **———————————————————————————————————————————————————— (5)
(1) | The JV-REPLACEMENT operand of the SET-PROCEDURE-OPTIONS command specifies that job variable replacement is allowed. |
(2) | Defines the procedure parameter JV-1. The value for this parameter is to be requested in interactive mode. |
(3) | Job variable replacement is implemented using the built-in function JV() (irrespective of the JV-REPLACEMENT setting). When the procedure is called, the expression &(JV(JV-NAME=JV-1)) is replaced by the value of the job variable whose name is transferred in the procedure parameter JV-1. |
(4) | If an error occurs during job variable replacement, the text “** Error” is output with the corresponding message code (&MC). If the procedure executes without error, the text of the ELSE loop is displayed. Here too, the expression &(&(JV-1)) is replaced by the value of the defined job variable. During the first step of the replacement of &(JV-1), irrespective of the JV-REPLACEMENT setting (JV-1 is uniquely an S variable), the second step of the replacement is only carried out with the setting JV-REPLACEMENT=*AFTER-BUILTIN. |
(5) | The requested file cannot be found in the desired pubset. |