Example: marketing

Reading and Writing Data Using REXX EXECIO on …

Technical Support | April 2003 Reading and Writing DataUsing rexx EXECIO onOS/390 and z/OSBy Lionel DyckThis article offers tips on Reading and Writing data Using theREXX programming language and the EXECIO command andconcludes with some useful resources on learn rexx , one of the things that you will findvery useful is the ability to read data from a datasetand to write data to a dataset. Fortunately for the rexx user, this is aseasy as doing anything else in article does assume that the reader has a basic understanding ofTSO commands such as Allocate and Free, of ISPF, as you will beusing the ISPF Editor to code your rexx programs (also known asREXX Execs), and of basic rexx coding and rexx programming language was developed in the VM envi-ronment (if you don t remember what VM is I suspect that you will inthe near future if your insta)

Technical Support | April 2003 Reading and Writing Data Using REXX EXECIO on OS/390 and z/OS By Lionel Dyck This article offers tips on reading and writing data using

Tags:

  Using, Data, Reading, Writing, Rexx, Reading and writing data using rexx execio, Execio, Reading and writing data using

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of Reading and Writing Data Using REXX EXECIO on …

1 Technical Support | April 2003 Reading and Writing DataUsing rexx EXECIO onOS/390 and z/OSBy Lionel DyckThis article offers tips on Reading and Writing data Using theREXX programming language and the EXECIO command andconcludes with some useful resources on learn rexx , one of the things that you will findvery useful is the ability to read data from a datasetand to write data to a dataset. Fortunately for the rexx user, this is aseasy as doing anything else in article does assume that the reader has a basic understanding ofTSO commands such as Allocate and Free, of ISPF, as you will beusing the ISPF Editor to code your rexx programs (also known asREXX Execs), and of basic rexx coding and rexx programming language was developed in the VM envi-ronment (if you don t remember what VM is I suspect that you will inthe near future if your installation is considering running Linux on yourS/390 or zSeries processor).

2 VM, or Virtual Machine, is an operatingsystem that IBM developed 30 years ago to provide each user withtheir own virtual personal computer. Today s VM is known as reason for that short history lesson is because the command syntaxfor Reading and Writing data Using rexx is based on a VM commandcalled EXECIO , or Execute I/O. This syntax is different from the syntaxyou are used to with the CLIST programming language and with themajority of TSO commands. This doesn t make it worse, or better, justdifferent and that difference you will need to remember as it couldcause you coding problems when you code the EXECIO command.

3 Beaware that the EXECIO method of Reading and Writing is not part ofthe rexx standard, so you will not find it in other implementations( Regina rexx ). Reading data FROM A DATASETLet s start by Reading data from a dataset. To do this you will needto first allocate the dataset Using the TSO Allocate command. The com-mand syntax in rexx for this is in ddname in the ALLOC command is the same as the ddname onthe DD statement in JCL. The shr is the same as the DISP=, or dispo-sition, on the DD statement. The ds is the same as the DSN= on the DDstatement. The dataset name must be a sequential dataset or a memberof a partitioned dataset, as rexx can only read sequential data withthe EXECIO EXECIO command in rexx is very powerful, however for thepurpose of this introductory article, I will focus on the usage that I havecome to prefer over the years.

4 See FIGURE2 for an example of the syntaxfor Reading the this example, the command is EXECIO . It is enclosed withinquotes along with all of the parameters used. If any of the parametersare variables, then those variables would be outside the quotes seeFIGURE3 for an example where the ddname is a should have noticed by now that rexx is not case is a good thing as it makes Reading rexx code much easier, andimportant parts of the code can be highlighted by Using capital FIGURE2 and 3 the * is used to indicate to EXECIO to read all ofthe records in the input dataset.

5 If you only needed to read a few records Alloc F(ddname) shr ds(dataset-name) FIGURE 1: ALLOCATING A DATASET EXECIO * Diskr ddname (Finis Stem in. FIGURE 2: Reading A DATASET ddname = input EXECIO * Diskr ddname (Finis Stem in. FIGURE 3: Reading A DATASET WITH THE DDNAME AS A VARIABLE EXECIO 0 Diskr ddname (Finis FIGURE 4: CLOSING A READ DATASET 2003 Technical Enterprises, Inc. Reproduction of this document without permission is the * could be replaced by that number. You would then have torepeat the EXECIO multiple times to read the entire dataset. The DISKR keyword is used to indicate that the dataset is to be read and not ddname is the same ddname used in the previous ALLOC com-mand.)))

6 This is because rexx needs to have the dataset already allocatedbefore it can access any of the records in the left parenthesis, (, is an artifact of the VM heritage of the com-mand and is used to indicate that additional options follow. In this casethe Finis is a keyword used to tell EXECIO to close the dataset when itis finished Reading all the records. You would not use this if readingonly a few records at a time, then you would close the dataset usingcode similar to FIGURE4 (on page 22). The keyword Stem indicates thatthe records are to be read into the stem variable that follows the Stemkeyword.)

7 In this case the stem variable is in. and the period after thevariable name indicates that it is a stem THE DATASET ALLOCATIONAt this point the dataset has been processed, and all the records arein the stem variable. As the dataset will no longer be used, the datasetallocation can be released Using the Free command as shown in keyword F or File references the ddname of the allocation. This isnormal TSO syntax, where the keyword parameter is enclosed inparenthesis compared to the VM syntax of EXECIO , where the key-word parameter is just coded next as in the Stem keyword and the stemvariable this point the dataset has been allocated, all the records have beenread into the stem variable in.

8 , and the dataset allocation has beenreleased. You are now ready to begin processing all of the records thatwere just read from the THE RECORDSThe stem variable now contains a count of the number of recordsthat were read in. This count is very helpful should you want to processeach record individually Using a DO processing the records you will want to write out the modifiedrecords, a report of some kind, or just create a copy of the records intoa new dataset. The steps to write out the records are very similar to thesteps to read in the records. First the output dataset must be allocated,then the records written out, and finally the dataset allocation allocate the output dataset, the ALLOC command is once againused.

9 Assuming the output dataset has already been allocated andexists, then the command used in FIGURE1 (on page 22) will workagain. If you need to allocate a new dataset, then you will need to spec-ify SPACE and DCB information. See the TSO Help information forthe ALLOC command for more information on the available options,and there are many options you can use. If you can do it in a JCL DDstatement then you can do it in an ALLOC command (with the excep-tion of allocating a GDG dataset which ALLOC can not THE RECORDS OUTTo write the records out, you will use the EXECIO command onceagain.)

10 The syntax will be similar to what you ve already seen, with theexception that the DISKR will be replaced by DISKW, for Disk Write. SeeFIGURE6 for an example of how to write all the records to an output Support | April 2003 Useful rexx reference materials are:The rexx Language Association on the Web at excellent list of rexx Publications on the Web at maintained by theoriginator of rexx , Mike IBM rexx Web site at IBM rexx Product Web page at IBM z/OS TSO/E rexx Reference at IBM z/OS TSO/E rexx User s Guide at IBM rexx Compiler Web site at you are new to rexx check out Jeff Glatt s site which claims you can Learn rexx Programming in 56,479 steps ~jglatt/ rexx /scripts/ you can find a lot of rexx examples for OS/390 and z/OS at my Web site at Look onboth the ISPF and the TCP/IP pages.


Related search queries