Ampersand as character, not as prefix for variables

Document ID : KB000074725
Last Modified Date : 23/03/2018
Show Technical Document Details
Introduction:
It happens that you want to use the Ampersand '&' as a character and not as a prefix for variable names. For example you want to put a line like this into a variable:

//SYSLIN   DD  DSN=&&OBJECT,DISP=(OLD,DELETE)
Instructions:
In order to get the string

//SYSLIN   DD  DSN=&&OBJECT,DISP=(OLD,DELETE)

into a variable you use these two lines of code:

&DSN = &CONCAT & & OBJECT                          
&Q = &STR //SYSLIN   DD  DSN=&DSN,DISP=(OLD,DELETE)

Variable &DSN is filled with the three character which are concatenated by &CONCAT: '&', '&' and 'OBJECT'. Thus, &DSN is filled with the string '&&OBJECT'