z/OS TSO/E CLISTs
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Updating a file

z/OS TSO/E CLISTs
SA32-0978-00

To update a record in an open file, use the GETFILE and PUTFILE statements. After opening a file for updating (OPENFILE filename UPDATE), perform successive GETFILE statements until the desired record is read. After assigning the new value to a variable of the same name as the file name, perform a PUTFILE statement to update the record.

As long as the file remains open, you may update records.

Assume a data set called D58TAN1.CHECKS.DATA has a variable-blocked record format and contains the following records:
200BLACKBUY
449REFY
450YARRUM
To update the record for REFY, you can code the following:
⋮
  (error routine)
⋮
allocate file(paycheks) da('d58tan1.checks.data') shr reu
OPENFILE PAYCHEKS UPDATE   /* Open file for updating      */
GETFILE PAYCHEKS           /* Read first record           */
DO WHILE &SUBSTR(4:7,&PAYCHEKS)¬=REFY
 GETFILE PAYCHEKS          /* Read another record         */
END
SET PAYCHEKS = 000REFY     /* Set new value               */
PUTFILE PAYCHEKS           /* Write new value to data set */
CLOSFILE PAYCHEKS          /* Close the file              */

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014