Programming Tutorials
WRITE Command
Written by VR Thursday, 04 August 2011 06:02
The WRITE command is used to write a record directly ito a file based on the key specified.
Format
EXEC CICS WRITE
DATASET (name)
FROM(data-value)
LENGTH(data-value)
RIDFLD(data-area)
END-EXEC.
DATASET names the file to which the record is to be written from names the field where the record data exist.LENGTH indicates the length of the record to be written.
The following are the exceptional conditions common to the WRITE command:-
DUPREC: The duplicate record is found.
OSPACE: No disk space is available for the record addition.
LENGERR: The length specified is greater than the maximum length the VSAM cluster.
READ,UPDATE and WRITE command
Written by VR Thursday, 04 August 2011 05:48
A combination of the READ command with the UPDATE option and the REWRITE command is used to update a record.Between these two commands,exclusive control over the record will be maintained for this task, so that no other task can access this record for updates.Therefore, the interval between these two commands be as short as possible.
An example of record update achieved by the combination of the READ/UPDATE command and the REWRITE command:
MOVE 35 TO WK-LEN.
MOVE 'NY001' TO REC-A-KEY.
EXEC CICS READ
DATASET('FILEAAA')
INTO(FILE-IOAREA)
RIDFLD(REC-A-KEY)
LENGTH(WK-LEN)
UPDATE
END-EXEC.
::
MOVE 'THIS IS TEST FOR UPDATE'
TO REC-A-DESC.
EXEC CICS REWRITE
DATASET('FILEAAA')
FROM(FILE-IOAREA)
LENGTH(WK-LEN)
Durng the execution of this program logic, the following activities will occur.
At the completion of the READ/UPDATE command, record NY001 will be read and reserved for the subsequent UPDATE.That is exclusive control over the record is maintained for this task.
At the completion of the REWRITE command, the same record NY001 will be rewritten and the and the record will be exclusive control.
The following is exceptional condition common to the REWRITE command.
INVERQ: The REWRITE command is issued without a prior READ command with the UPDATE option.
READ command with GTEQ Option
Written by VR Thursday, 04 August 2011 05:42
The READ Command with the GTEQ option is used to read a non-specific record whose key is equal to or greater than full key specified.This is useful when you know the full key, but you are not sure that record with that key exists in the file.
The format of READ command with the GTEQ option using the INTO option for VASM/KSDS file is shown in the
Example
MOVE 35 TO WK-LEN.
MOVE 'NY003' TO REC-A-KEY.
EXEC CICS READ
DATASET('FILEAAA')
INTO(FILE-IOAREA)
RIDFLD(REC-A-KEY)
GETQ
LLENGTH(WK-LEN)
END-EXEC.
READ Command with GENERIC Option
Written by VR Thursday, 04 August 2011 05:38
The READ command with GENERIC option is used to read a nonspecific record based on the generic key instead of the full key.This is useful when you do not know the complete information of the key.
Examples
MOVE 35 TO WK-LEN.
MOVE 'NY' TO REC-A-KEY.
EXEC CICS READ.
DATASET('FILEAAA')
INTO(FILE-IOAREA)
RIDFLD(REC-A-KEY)
KEYLENGTH(2)
GENERIC
LENGTH(WK-LEN)
END-EXEC.
READ Command with SET option using Full Key
Written by VR Thursday, 04 August 2011 05:29
The READ command with the SET option using the full key is used to read a specific record in the full key.CICS sets the address pointer to the address of the record in the file input area within CICS,so that the application program can directly refer to the record without moving the record content into the Working-Storage Section in the program.Therefore, the SET option provides a better performance than the INTO option.
Example
01 LK-FILE-IO AREA.
05 LK-REC-A-KEY.
15 LK-SEC-A-KEY-CITY PIC XX.
::
EXEC CICS READ
DATASET ('FILEAA')
SET (FILE-PTR)
RIDFLD(WK-REC-A-KEY)
LENGTH(WK-LEN)
END-EXEC.
SERVICE RELOAD LK-FILE-10AREA.
During the execution of the READ command,CICS will acquire the I/O area, palce the record and read, and place the address of the I/O area into the pointer-reference.
Therefore,after the SERVICE RELOAD statements, the application program will be able to refer to any field in LK-FILE-IOAREA.
More Articles...
Page 1 of 43
«StartPrev12345678910NextEnd»