Mainframe Tutorial-CICS File Control Commands-WRITE Command

The WRITE command
{ WRITE DATASET(filename) | FILE(name) }
[ LENGTH(data-area) ]
[ KEYLENGTH(data-value) ]
[ SYSID(name) ]
[ RRN | RBA ]

DATASET or FILE Specifies a 1 to 8 character name for the datset as specified using CEDA DEFINE FILE(name)

FROM The source data area

LENGTH Specifies in a half word PIC S9(4) COMP field. This specifies the length of the record to be written. Not needed for fixed length records.

RIDFLD If RRN or RBA is specified refers to relative record number of a RRDS or RBA of a ESDS file. If neither is specified this field contains the key of the KSDS record.

KEYLENGTH Specifies in a half word field ( PIC S9(8) COMP) field the length of the key. It is used only if SYSID is specified and RBA / RRN is not specified, in other words a remote KSDS file.

SYSID Specifies a 1 to 4 character connection name that represents a remote system.

RBA Full word PIC S9(8) COMP field which specifies the relative byte address of the record for a KSDS or ESDS file.

RRN Full word PIC S9(8) COMP field which specifies the relative record number of the record for a RRDS file.

MASSINSERT Specifies that the write is part of a VSAM mass insert operation. A mass insert operation splits the CI at the key of the record being inserted, which improves mass sequential inserts.

The RESP field can have the following values:-

DISABLED file is disabled using CEMT SET

DSIDERR File is not defined to CICS. In later systems also indicated by FILENOTFOUND.

LENGERR The buffer provided is too small to hold the record.

DUPREC A record with the specified key already exists in the file. Can also occur if the record contains an alternate key value that already exists, the alternate index does not allow duplicate keys and the alternate index is part of the files upgrade set or access is via the path.

ILLOGIC A serious VSAM error occurred

INVREQ The write operation is not enabled for this File when it was defined using CEDA , or the key length specified is incorrect, or a READ UPDATE has exclusive control of this record.

IOERR An IOERR occurred

NOTAUTH The transaction’s definition specified resource Checking and the operator is not authorized to Access the data set.
NOTOPEN the data set is not open

SYSIDERR The system identified by SYSID could not be found.

  • When you write to an ESDS the record is always added to the end of the file. The input via RIDFLD is ignored. On return though, it has the RBAS of the record that has just been added.
  • If you are inserting several records in key sequence, use massinsert. It is more efficient. You need to take a SYNCPOINT or issue an UNLOCK command before the records can be read by any task.
  • The only exception condition that you normally can expect to handle in your program is DUPREC.


Computers TopOfBlogs Technology Blogs Mainframe interview question and answers,mainframe jobs,cobol,vsam,jcl,cics,db2,rdbms,mvs,tso,ispf,ibm,hcl,tcs,cts,wibro Blog Directory