How do you update a PDS member with VISION:Results?

Document ID : KB000021891
Last Modified Date : 14/02/2018
Show Technical Document Details

The documentation has good examples of various PDS actions, but not how to update a member.

In order to update a PDS member, you must rewrite the entire member. You cannot just change individual lines.

The READDIR command opens a PDS member. Then issue the READMEM command to retrieve all the records for that member. After all the records have been retrieved, the STATUS field should be reset to blank and a READDIR executed again to open up the next PDS member. The READMEM will then be executed in a loop until all the records have been retrieved for that member. This process of READDIR and READMEM will continue until all the members in the PDS have been accessed.

A WRITEDIR is the same as doing a PF3 in ISPF to close a member. When you issue a WRITEDIR immediately after a WRITEMEM, only one line will make up that member. You must do a WRITEMEM for all the records, even if you not changing them, before issuing a WRITEDIR or you lose those records.

IBM does not support I/O update directly to individual records of a PDS member. Any changes to a record in a PDS member requires the entire PDS member to be rewritten. When you are in ISPF, the rewriting of the entire member is done for you. Unfortunately, VISION:Results does not do this for you. Every record must be rewritten with the WRITEMEM before doing a WRITEDIR. That is why in the documentation it is referred to as copying and updating a member rather than just updating a member.

Following is an example. For further information please refer to Chapter 10 of the VISION:Results Toolkit Reference Guide.

 //PDSUPDT EXEC PGM=DYL280        
 //STEPLIB DD DSN=vision.results.loadlib,DISP=SHR 
 //SYSOUT DD SYSOUT=*
 //SYSPRINT DD SYSOUT=*
 //SYS004 DD UNIT=VIO,SPACE=(TRK,(5,5))
 //SYS280R DD SYSOUT=*
 //SYS280R1 DD SYSOUT=*
 //PDSIN DD DISP=OLD,DSN=TESTPDS.JCL
 //PDSNEW DD DISP=OLD,DSN=TESTPDS.JCL
 //SYSIN DD *
 OPTION STRUCTURED2
 REPORT 100 WIDE
 *******************************************************************       
 * 
 * This programs demonstrates the how to use VISION:Results to
 * UPDATE PDS members.
 * It is not possible to update a member at the record level.
 * When there is a need to update a member, the entire member
 * must be rewritten.
 *
 *******************************************************************
 FILE PDSIN   PDS PINAREA     MEMBER OLDNAMEI  STATUS PDSISTAT  F 80
  IN_REC    80    1
  IN_FLD1    7    1
 
 FILE PDSNEW  PDS POUTAREA    MEMBER OLDNAMEO  NEWNAME NEWINFO
                          OUTPUT FROM PDSNEW  STATUS PDSOSTAT  F 80
  OUT_REC    80    1
  OUT_FLD1    7    1
 
 WORKAREA   DIRINFOI 75 1
 WORKAREA   DIRINFOO 75 1
 ***************************************
 READDIR PDSIN DIRINFOI                     ; FIRST READ DIRECTORY
 DOWHILE PDSISTAT NE 'E'                    ; LOOP TO READ DIRECTORY
     LIST 'MEMBER< '  AT 1  OLDNAMEI  AT 11
   READMEM PDSIN                           ; FIRST READ MEMBER RECORD
   DOWHILE PDSISTAT NE 'E'                 ; LOOP TO READ MEMBER
     LIST IN_REC AT 1                      ; LIST ORIGINAL CONTENT
     MOVE IN_REC TO OUT_REC                ; IN_REC -> OUT_REC
     MOVE OLDNAMEI  TO OLDNAMEO            ; MEMBERNAME IN -> OUT
 *****************************************
    IF IN_FLD1 EQ 'CHANGED'               ; CHANGE LOGIC ON RECORD
        MOVE 'CONTENT'  TO OUT_FLD1        ; CHANGE LOGIC ON RECORD
     ELSE                                  ; CHANGE LOGIC ON RECORD
       IF IN_FLD1 EQ 'CONTENT'             ; CHANGE LOGIC ON RECORD
          MOVE 'CHANGED'  TO OUT_FLD1      ; CHANGE LOGIC ON RECORD
       ENDIF                               ; CHANGE LOGIC ON RECORD
     ENDIF                                 ; CHANGE LOGIC ON RECORD
        LIST OUT_REC AT 1                  ; LIST CHANGED CONTENT
        WRITEMEM PDSNEW                    ; WRITE CHANGED CONTENT
     READMEM PDSIN                         ; NEXT READ MEMBER RECORD
   ENDDO
   LIST 'MEMBER> '  AT 1  OLDNAMEO  AT 11  ; LIST UPDATED MEMBER
   WRITEDIR PDSNEW REPLACE                 ; UPDATE DIRECTORY
   MOVE ' ' TO PDSISTAT                    ; RESET STATUS AT END
                                           ;    OF MEMBER
   READDIR PDSIN DIRINFOI                  ; NEXT READ DIRECTORY
 ENDDO
 STOP
 /*
 //