Tags

, , , , ,

REXX – READ, CREATE AND WRITE DATA TO A DATASET

Below Step shows us how to assign a dataset to a DDNAME and read it.

  1. Read the input dataset into an array variable

INPUTPS =’HLQ1.HLQ2.HLQ3.INPUT’

IF SYSDSN(“‘”INPUTPS”‘”) /= ‘OK’ THEN

DO

SAY ‘INPUT FILE ‘ INPUTPS ‘ DOESNOT EXIST’

EXIT(0)

END

“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.

  1. Creation of the output file

ADDRESS TSO

RPTCTL=’HLQ1.HLQ2.HLQ3.OUTPUT’

ADDRESS TSO

STATUS = SYSDSN(“‘”RPTCTL”‘”)

IF STATUS = ‘OK’ THEN

DO

“DELETE ‘”RPTCTL”‘”

END

“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.

  1. Writing data to output dataset

“EXECIO” LOT.0 “DISKW XXOUT (STEM LOT.”

“EXECIO 0 DISKW XXOUT (FINIS”

“FREE F(XXOUT)”

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
Important SQL CODES and ABEND CODES
SORT JOIN – TO JOIN TWO FILES BASED ON A KEY
KNOW YOUR MAINFRAME
REXX – INITIAL SETUP
EASYTRIEVE – A023 ABEND
EASYTRIEVE – SORT and FILE COMPARISION
EASYTRIEVE – Special-name Report Procedures
EASYTRIEVE – REPORT STAEMENT
EASYTRIEVE – Sample Program – Table And Search
EASYTRIEVE – Sample Program – Display Totals and Summary
EASYTRIEVE – Sample Program – Display Employee Data
CA-Easytrieve/Plus – Basics
REXX TOOL # 02 – FSAVE – Save member opened in VIEW mode
REXX TOOL # 01 – O – Open Any Mainframe Element from any ISPF Screen
REXX – INDEX, POS, SUBSTR, COMPARE
REXX – READ THE DSN PROVIDED AS DD IN JCL
REXX – SEND MULTIPLE ARGUMENTS THROUGH JCL
REXX – HOW TO COMPILE YOUR REXX EXEC
REXX – CHANGE UPPER TO LOWER CASE
REXX – GET LAST 4 DAYS FROM GIVEN DATE
REXX – PANEL Definition
REXX – READ, CREATE AND WRITE DATA TO A DATASET
REXX TOOL TO SUBSTITUTE SYMBOLICS IN A PROC
Advertisement