$DSNNUM is useful with Model 204 files that are comprised of multiple data sets. You specify the Model 204 file's DD name or file name and $DSNNUM returns the total number of data sets defined for the file.
The $DSNNUM syntax is:
ddname is a file or data set's DD name. The file that you specify must be OPEN by you while you are using $DSNNUM. This ensures reliable output.
$DSNNUM returns a zero if the file or data set is not found. It returns a -1 for an argument syntax error.
For a sequential file, the number of data set names is always one.
The following example combines the use of $DSNNUM to identify the number of data sets that a file maps to, and then uses $DSN to print out the data set name.
%FILENAME IS STRING LEN 8 %FILENAME = 'MYFILE' PRINT 'FILE ' WITH %FILENAME WITH - 'IS CONTAINED IN THE FOLLOWING DSNS ' - PRINT FOR %I FROM 1 TO $DSNNUM(%FILENAME) PRINT $DSN(%FILENAME,%1) END