Question & Answer
Question
I want to execute my program at the command line like this: $ myprog < XYZ.txt What is the syntax of the SELECT statement to allow this?
Cause
This is unsupported. The SELECT statement requires a file name. If you try
SELECT IN-FILE ASSIGN TO stdin ORGANIZATION IS LINE SEQUENTIAL
then the OPEN verb will expect a file with the name of stdin. You could use the AIX
$ export stdin=XYZ.txt
but that's not what you want. You want the re-direction.
Answer
It is possible using the ACCEPT verb instead of the OPEN verb. Although more limited, using a construct such as
01 IN-DATA PICTURE X(80).
ACCEPT IN-DATA.
Then you can execute with the syntax
$ myprog < XYZ.txt
But the limitation is that in this case, 80 bytes will be read from XYZ.txt without regard of end-of-line bytes.
Then on file XYZ.txt we have these 2 lines, each line is 40 bytes with end of line x'0D' making the whole file 82 bytes long.
AAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDD
EEEEEEEEEEFFFFFFFFFFGGGGGGGGGGHHHHHHHHXX
The result will be one long AAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDDEEEEEEEEEEFFFFFFFFFFGGGGGGGGGGHHHHHHHH
Notice the last two XX are missing.
If the input file (the entire file) is less than 80 bytes, you'll correctly receive whatever it there. For example if XYZ.txt has these two lines
KKKK
LLLL
The result will be KKKKLLLL Notice the end of line byte is removed.
Historical Number
PMR_74661_004_000
Was this topic helpful?
Document Information
Modified date:
08 August 2018
UID
swg21206848