Problem:
It is easy to fully path to a file or files in the SELECT statement however this doesn't allow the root directory path to be changed at runtime without rewriting the application.
Resolution:
By using the RUNPATH environment variable and the RUN-FILES-ATTR EXPANDED-PATH-SEARCH configuration option allows for a more flexible solution. For example, if you wanted to open the following files :
/home/trpos/2012/FILE.DAT
/home/trpos/2013/FILE.DAT
Instead of fully pathing to them in the SELECT statement like this :
SELECT DOSYA ASSIGN TO RANDOM "/home/trpos/2012/FILE.DAT"
SELECT DOSYB ASSIGN TO RANDOM "/home/trpos/2013/FILE.DAT"
You could assign them like this :
SELECT DOSYA ASSIGN TO RANDOM "2012/FILE.DAT"
SELECT DOSYB ASSIGN TO RANDOM "2013/FILE.DAT"
NB: Note the lack of a leading /
Then set the RUNPATH environment variable to :
/home/trpos
This instructs the runtime to start it's file search path in the /home/trpos directory. Create a configuration file (simple text file for example called "c.cfg") containing the following :
RUN-FILES-ATTR EXPANDED-PATH-SEARCH=YES
Then run using the command line :
runcobol <program> c=c.cfg
The configuration file will instruct the runtime to look in all the RUNPATH locations appending the path/filename in SELECT statement.