REXX – READ, CREATE AND WRITE DATA TO A DATASET
Below Step shows us how to assign a dataset to a DDNAME and read it.
Read the input dataset into an array variable
IF SYSDSN(“‘”INPUTPS”‘”) /= ‘OK’ THEN
SAY ‘INPUT FILE ‘ INPUTPS ‘ DOESNOT EXIST’
“ALLOC DD(INP1) DA(‘”INPUTPS”‘) SHR REUS”
“EXECIO * DISKR INP1 (STEM IN1. FINIS”
SYSDSN – Checks the availability of the File
ALLOC – Allocates the input file to the DD INP1
EXECIO * DISKR – Reads the input file using the DD name INP1 into the array variable IN1.
Please note that IN1.0 contains the record count of the input file.
- Creation of the output file
STATUS = SYSDSN(“‘”RPTCTL”‘”)
IF STATUS = ‘OK’ THEN
“ALLOC FI(XXOUT) DA(‘”RPTCTL”‘) SHR NEW SPACE(50,20)
DSORG(PS) RECFM(F,B) LRECL(200) BLKSIZE(30000)”
DELETE – Deletes the dataset if it is already available
ALLOC – Allocates the file which is assigned to the DD name XXOUT. You can see that all the dataset parameters that define the dataset can be given as provided above.
- Writing data to output dataset
“EXECIO” LOT.0 “DISKW XXOUT (STEM LOT.”
“EXECIO 0 DISKW XXOUT (FINIS”
The first line writes all the data (Number of lines to be written is present as LOT.0, which specifies the number of array occurrences for the array LOT.) into the DD XXOUT, which is our output file RPTCTL.
The second line is used to mention that the writing is finished.
Once the usage of the file is done, we need to free the DD name, which is done in the third line. This is done so that the DD name can be used for other datasets.
In United States, If you would like to Earn Free Stocks, Credit card Points and Bank account Bonuses, Please visit My Finance Blog
You may also like to look at:
|Working on Mainframes – Is Change to a different technology necessary|
k klein said: