Previous Topic: Mass Insertion into a VSAM FileNext Topic: Deleting a Record with a Large Key


Copy a VSAM Record from One File to Another

To copy a record from one file to a second file, specify the READ function for the first file and the ADD function for the second file.

  1. To retrieve the record you want to copy, specify the following, and then press Enter or browse the file:
    FILEID= file ID of source file
    FUNC= GET
    RCID= key
    
  2. After FILE displays the record, specify the following, and then press Enter:
    FILEID= file ID of destination file
    FUNC= ADDU
    
  3. Make any necessary changes, then specify the following, and press Enter:
    FUNC= PUT
    RCID= key
    SIZE= record length
    

    Note: Specify the SIZE field only when adding a variable length record.

    FILE redisplays the record and displays the message RECORD ADDED.

    Repeat Steps 1 through 3 to copy additional records.

    Note: If the LRECLs of the two files differ, the LRECL of the destination file determines the size of the record. The record will either be truncated or padded with binary zeros to meet that length.

Example

To copy a record with the key 'REC050' from the ACCTS file to the TEST file, follow these steps:

  1. Specify the following, and then press Enter to display the record:
    FILEID= ACCTS 
    FUNC= GET RCID= C'REC050
    
  2. Specify the following, and then press Enter:
    FILEID= TEST 
    FUNC= ADDU
    
  3. Specify the following, and then press Enter:
    FUNC= PUT
    RCID= C'REC001'
    

Delete VSAM Records

To delete a record, follow these steps:

  1. Specify the DELETE operation on the FILE definition.
  2. Specify the following required information:
    FUNC= DEL
    

To delete a single record, follow these steps:

  1. Specify the following:
    RCID= full record key
    
  2. Press Enter.

To delete all records having a generic (partial) key (KSDS files only), follow these steps:

  1. Specify the following:
    RCID= generic key
    SRCHTYP= GKEQ 
    ARGTYP= KEY
    
  2. Press Enter.

Notes:

Examples

  1. To delete the record NEWREC001 from the ACCTS file, specify the following, and then press Enter:
    FILEID= ACCTS
    FUNC= DEL
    RCID= C`NEWREC001'
    
  2. To delete all records whose keys start with the character string NEWREC from the ACCTS file, specify the following, and then press Enter:
    FILEID= ACCTS
    FUNC= DEL
    SRCHTYP= GKEQ
    RCID= C`NEWREC'
    ARGTYP= KEY