3

In JCL, normally Symbolic parameters is created using & (Ampersand sign) followed by the variable name.

But in dataset name, It has to followed by the dot sign after the variable name. Example:

//J&USER JOB 1
//MYSTEP EXEC PGM=MYPROG
//MYDATA DD DSN=&USER..MYCLASS.COOL

Why is that so? I am afraid of inconsistency later, so I ask this question. Thanks for any helps in advance.

Yeo
  • 11,416
  • 6
  • 63
  • 90

2 Answers2

4

In simple terms, if a symbolic parameter is followed by a period (.), then an additional period (.) needs to be added, thus resulting in 2 periods (.).

Based on your scenario, it is correct that you must use two periods (.).

This discussion said that the first period is used for concatenation, while some others said that it's part of the termination of the symbolic variable. But it doesn't really matter. The second period becomes part of the dataset name.

Example:

If &USER resolved as USR01, then it will be interpreted as

//JUSR01 JOB 1
//MYSTEP EXEC PGM=MYPROG
//MYDATA DD DSN=USR01.MYCLASS.COOL

Only the second period will be used in your dataset.

But, imagine if you have something like this, what will happen

//MYDATA DD DSN=&USER.MYCLASS.COOL

The dataset will be something like USR01MYCLASS.COOL. This is an error, as each level shouldn't have more than 8 characters.

zarchasmpgmr
  • 1,422
  • 10
  • 21
Yeo
  • 11,416
  • 6
  • 63
  • 90
4

Just as the beginning of a symbolic parameter is marked by an ampersand (&). It may be terminated by a space or a period. When terminated by a period, the period is not part of the name (just as the opening ampersand isn't).

When an entire string is replaced by a symbolic parameter it is just coded as is:

  // SET MYPROG=FRED
  //RUNIT EXEC PGM=&MYPROG

Here &MYPROG is replaced with its value, FRED. No problem figuring out where the symbolic name started or ended. Now suppose you wanted to run 3 programs: FRED1, FRED2 and FRED3. You could do something like:

  //RUN3 EXEC PGM=&MYPROG.3

Here, program FRED3 is being run. The symbol MYPROG terminated by a period and equates to FRED, to this the rest of the text is added yielding FRED3.

Same thing applies when using symbolic parameters within dataset names. The first period is needed to terminate the symbol name, the next period is part of the dataset name itself. For example, if symbol USER evaluates to ABC123, then

  //MYDSN DD DSN=&USER..MYDATA

evaluates to ABC123.MYDATA as a data set name. Similarly,

  //MYDSN DD DSN=&USER.X.MYDATA

evaluates to: ABC123X.MYDATA Note that the resulting DSN has a single period, because the first one terminated the symbolic name and is not part of the result.

NealB
  • 16,670
  • 2
  • 39
  • 60