With dynamic filename assignment, the filename is specified in the SELECT clause as a COBOL data item:
select filename assign to dynamic data-item
where the parameters are:
If the filename of the physical file that you are creating contains spaces, you should surround the filename with quotes - see Example 2 below.
Example 1
In the following example, the file input.dat is created in the current directory:
... select fd-in-name assign to dynamic ws-in-file. ... working-storage section. 01 ws-in-file pic x(30). ... move "input.dat" to ws-in-file. ... open output fd-in-name.
Example 2
The following example shows how to use quotes to create the file spacey filename.dat, where the filename contains spaces:
select f1 assign to dynamic f1-name. ... working-storage section. 01 f1 pic x(30). ... move """spacey filename.dat""" to f1-name .... open output f1.