Monday, August 27, 2012

File Handling In Rexx

File handling or Dataset Handling in REXX is done Using it's EXECIO function's.


To write a Dataset in Rexx

Write Link


To Read a Dataset in Rexx

Read Link


How To Write a Dataset In Rexx



Writing a file in REXX is a kind of a easy job . Generally we have to store all the lines which we want to WRITE in an array. And Once we are done with what we want to write in an array we can write it into a PS or member of PDS.



  • Initializing  (i.e Array.="") the array which we are going to write is a very good practice.
  • At times you end up with writing errors if we don't initialize the array.
  • You can load any number of arrays and write one array in one or more dataset by repeating the dataset syntax for various PS or PDS.
       

                      "ALLOC FI(LNAME) DA('MY.PS.WRITE') SHR"
                      "EXECIO * DISKW LNAME(STEM ARRAY. FINIS"

                      "FREE FI(LNAME)"


      • Where LNAME is the logical name of the dataset 'MY.PS.WRITE'.

      •  Finally it is a good practice to free the file you are writing.

      •  Now you could also write the same array into a different Dataset in the same REXX program.

                      "ALLOC FI(LNAME) DA('MY.PS.WRITE.NEW') SHR"
                      "EXECIO * DISKW LNAME(STEM ARRAY. FINIS"
                      "FREE FI(LNAME)"