In order to read or write a file using REXX, first step is to allocate a DDNAME. This step is required only when REXX is executed through Foreground mode. We can also execute REXX through background mode using JCL. In background mode, we aren't required to allocated DDNAME. It is auto allocated by the system.
Reading a file in REXX:
Step 1: Allocate ddname to the input file
"ALLOC FI(INDD) DA('"PDSNAME"("MEMNAME")') SHR "
Step2: Read all records from the file and store in the stem variable Line.
The command * indicates all records, if you wish to read only one record, you can say 1 instead of * and make it in a loop.
"EXECIO * DISKR INDD (STEM LINE. FINIS"
Step3: Processing --- loop to process all records
DO I=1 TO LINE.0
CALL PROCESSING
END
Step 4: This step deallocates the ddname.
"FREE FI(INDD)"
Writing a file in REXX:
Writing file is similar to reading. Only difference is DISKW command is used instead of DISKR.
Step 1: Allocate DDNAME to the output file
"ALLOC FI(OUTPUT) DA('"OUTPDS"("MEMBER")') SHR "
Step 2: Write the stem into the output file
"EXECIO * DISKW OUTPUT (STEM WRITEDA. FINIS"
Step 3: Deallocate the DDNAME
"FREE FI(OUTPUT)"
Subscribe to:
Post Comments (Atom)
Featured Post
REXX Skeleton: Submitting jobs through Rexx
Submitting jobs through REXX and reading the spool through REXX gives us immense potential to automate many manual activities in mainframes....
-
Abend S013 SYSTEM COMPLETION CODE=013 REASON CODE=00000018 AN OPEN WAS ISSUED FOR A PARTITIONED DATASET. THE SPECIFIED MEMBER NAME WAS N...
-
A word is defined as a blank delimited set of characters within a string in REXX. The characters in a word can be alpha, numeric, alphanume...
-
String functions interrogate, compare, and manipulate character strings of data. Some of the built-in function are listed below: COPIES...
Nevernevernever "EXECIO * DISKW".
ReplyDeleteThere is ALWAYS enough information available such that the "*" can be replaced by a real value, whether it be 'stem.0' or 'queued()' or something else.
Ofcourse, it can be. But "*" can be very well used without any issues. When working with the same stem variable, it is necessary to drop the stem variable before using for the next time.
Delete