The value of a procedure parameter, an S variable expression or a job variable can substitute a command/statement portion. The expression to be substituted is marked by a '&' character, followed immediately by the name of the procedure parameter or job variable or by an S variable expression enclosed in parentheses. SDF substitutes the actual value for the expression prior to execution of the command/statement. It performs a syntax check on the resulting input. This substitution of expressions is permissible in unguided dialog, in procedures, and in batch mode. In (temporarily) guided dialog, it is restricted to the NEXT line and to input for operand values.
Substituting procedure parameters
In non-S procedures, expressions of the form '¶meter', when used in commands, are replaced by the value assigned to parameter in the command BEGIN-PROCEDURE or CALL-PROCEDURE or during prompting. Expressions are replaced in commands. When used in input data (read from SYSDTA), such expressions are replaced only if an escape character (#, @, & or *) has been defined in the ESCAPE-CHARACTER operand of the BEGIN-PROCEDURE command and the expression begins with this character. When used in statements (read from SYSSTMT), such expressions are currently replaced as in commands. It is, however, advisable to define ESCAPE-CHARACTER='&', because the handling of such expressions may be modified.
The following restrictions apply to substituting procedure parameters:
No substitution is possible within CJC command sequences.
In procedures or ENTER files, procedure parameters cannot replace the slash introducing commands or the two slashes introducing statements, the period introducing non-S labels, the semicolon separating commands or the continuation character.
Expressions cannot be nested.
A double “&” or escape character inhibits substitution, the second “&” or escape character is ignored.
Substituting job variables
This function requires the chargeable subsystem JV to be loaded.
Expressions to be replaced by job variables are specified as follows:
directly via the job variable name in the form “
&(jv-name)
”indirectly via the job variable link name in the form “
&(*jv-link)
”. The assignment of the link name to the job variable takes place prior by means of 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 substituting job variables:
An expression can be replaced only by a job variable in its full length.
Read access must have been granted to the job variable value to be substituted for the expression, otherwise, the input will be rejected as a syntax error.
No substitution is 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, job variables cannot replace the slash introducing commands or the two slashes introducing statements, the period introducing non-S labels, the semicolon separating commands or the continuation character.
Job variables cannot be used as procedure parameters. This restriction can be circumvented, for instance, by using a link name (see example 3).
Expressions cannot be nested.
With interactive mode or S procedures, job variable substitution in the manner outlined above is effected only if no identical S variable or builtin function is known. This mechanism can be replaced, however, by the builtin function JV(). In this case, the appropriate entry would take the form
“&(JV(JV-NAME=<c-string 1..54>))”
. (See builtin function "JV( ) - Interrogate job variable". If the job variable name contains the catalog and/or user ID, only job variable substitution is possible.
Substituting S variable expressions
In dialog mode and in S procedures, expressions of the form “&(expression)”, when used in commands, are replaced by the value of expression, where expression may be the name of an S variable, a builtin function or a valid S variable expression. If the expression is to be substituted by an S variable whose name does not contain any period, it may also have the form “&s-variable”. Procedure parameters of an S procedure are S variables and are replaced in expressions also.
Expressions are replaced in commands. When used in input data (read from SYSDTA), such expressions are replaced only if an escape character (#, @, & or *) has been defined in the DATA-ESCAPE-CHARACTER operand of the SET-PROCEDURE-OPTIONS command and the expression begins with this character. When used in statements (read from SYSSTMT), such expressions are currently replaced as in commands.
Expressions may be nested.
The following restrictions apply to substituting S variable expressions:
Control flow commands cannot be generated.
The S variable expression to be replaced is converted to type STRING.
S labels cannot be generated.
No substitution is possible within CJC command sequences.
In procedures or ENTER files, S variable expressions cannot replace the slash introducing commands or the two slashes introducing statements, the period introducing non-S labels, the semicolon separating commands or the continuation character.
A double “&” or escape character inhibits substitution, the second “&” or escape character is ignored.
Examples
1. Substituting job variables in dialog mode
/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=egon,set-value='-FILE-ATTR F-NAME=PROC.' —————————————————— (4)
/set-jv-link link-name=walter,jv-name=egon ——————————————————————————— (5)
/sh&(*walter)
% 3 :2OSG:$USER1.PROC.JV ———————————————————————————————————— (6) %:2OSG: PUBLIC: 1 FILE RES= 3 FRE= 2 REL= 0 PAGES
(1) | The job variable name ‘CMD’ is declared. |
(2) | The job variable CMD is assigned the value ‘SHOW-FILE-ATTR’ (short for the name of the command SHOW-FILE-ATTRIBUTES). |
(3) | After the command has been sent off, the variable string is replaced with the command defined in the job variable, and the command is executed. |
(4) | The value of job variable EGON is changed. It now contains only part of the command name (‘-FILE-ATTRIBUTES’) and the partially qualified file name ‘PROC.’. |
(5) | Job variable EGON is assigned the link name ‘WALTER’. |
(6) | After the command has been sent off, the variable string is replaced with the command portion assigned to the job variable, and the command is executed. The reference to the job variable is established via the link name. |
2. Substituting job variables and S variables in dialog mode
/sh-jv cmd -------------------------------------------------------------- (1) %SHOW-FILE-ATTR /&(cmd) proc.jv --------------------------------------------------------- (2) % 3 :2OSG:$USER1.PROC.JV %:2OSG: PUBLIC: 1 FILE RES= 3 FRE= 2 REL= 0 PAGES /cmd='PRINT-DOCUMENT' ---------------------------------------------------- (3) /sh-var cmd CMD = PRINT-DOCUMENT /&(cmd) proc.jv --------------------------------------------------------- (4) % SCP0810 SPOOLOUT FOR FILE ':2OSG:$USER1.PROC.JV' ACCEPTED. TSN: '1FAL', SPOOL OUT-NAME: 'SDFTEST', MONJV: '*NONE' % SCP1025 PRINT JOB ACCEPTED BY SERVER 'GH5090Y0' WITH TSN '5BXC' /&(:2osg:cmd) proc.jv ---------------------------------------------------- (5) % 3 :2OSG:$USER1.PROC.JV %:2OSG: PUBLIC: 1 FILE RES= 3 FRE= 2 REL= 0 PAGES /&(jv(jv-name='CMD')) proc.jv -------------------------------------------- (6) % 3 :2OSG:$USER1.PROC.JV %:2OSG: PUBLIC: 1 FILE RES= 3 FRE= 2 REL= 0 PAGES /
(1) | The job variable |
(2) | The command name from the job variable |
(3) | The S variable |
(4) | The expression |
(5) | The name of the job variable |
(6) | Job variable substitution can alternatively be achieved using the builtin function JV( ). |
3. Submitting the name of the job variable to be substituted as procedure parameter of 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 to be specified via procedure parameter PARAM1 is to contain the current command to be executed. As the entry “&(&PARAM1)” is illegal, a link name will have to be assigned. See (4) in Example 4 for the optional use of a nested expression. |
(2) | The current job variable name is inserted for procedure parameter PARAM1 and assigned the link name PARAM1. |
(3) | The contents of the declared job variable are substituted for the link name PARAM1. For instance, if the job variable value is |
4. Substituting job variables and S variables in an S procedure, the job variable name being submitted as a procedure parameter:
Contents of procedure file DO.JVTEST:
/ SET-PROC-OPT JV-REPLACE=*AFTER-BUILTIN / DECL-PAR JV-1(INIT=*PROMPT) / &(JV(JV-NAME=JV-1)) FILE-NAME=LST.JOB /ERR: IF-BLOCK-ERROR / WRITE-TEXT C'** Error &MC **' / ELSE / WRITE-TEXT C'** Command &(&(JV-1)) executed **' / END-IF /END: EXIT-PROC
Procedure execution:
/show-jv jv=cmd ------------------------------------------------------------ (1) %SHOW-FILE-ATTR /call-proc do.jvtest,log=*yes % 1 1 /SET-PROC-OPT JV-REPLACE=*AFTER-BUILTIN % 2 1 /DECL-PAR JV-1(INIT=*PROMPT) %JV-1: cmd ---------------------------------------------------------------- (2) % 3 1 /SHOW-FILE-ATTR FILE-NAME=LST.JOB ------------------------ (3) % 3 :N:$USER0001.LST.JOB %:N: PUBLIC: 1 FILE RES= 3 FREE= 3 REL= 3 PAGES % 4 1 /FEHL: % 4 1 / IF-BLOCK-ERROR % 6 1 /ELSE % 7 1 /WRITE-TEXT C''** Command SHOW-FILE-ATTR executed **' '** Command SHOW-FILE-ATTR executed ** ------------------------------------ (4) % 8 1 /END-IF % 9 1 /ENDE: % 9 1 / EXIT-PROC /
(1) | SHOW-FILE-ATTR is displayed as the contents of job variable CMD. |
(2) | After invoking the procedure |
(3) | The command SHOW-FILE-ATTRIBUTES is executed. |
(4) | A nested expression is used at this point: A job variable is to be substituted, its name being derived from the expression to be substituted for S variable |