Library View Topics Framed Contents Revised Topics Previous Topic Next Topic Search Search ResultsPrevious Topic MatchNext Topic Match Notes List Notes Print Download No PDF Handheld DisconnectedHandheld ConnectedHelp

6.2.40 WRITE Statement



The WRITE statement releases a logical record for an output or input/output file.

When the WRITE statement is executed:


    ___ Format 1--Sequential Files ___________________________________________________________________ 
   |                                                                                                  |
   | >>__WRITE__record-name-1__ _______________________ ____________________________________________> |
   |                           |                    (1)|                                              |
   |                           |_FROM__identifier-1____|                                              |
   |                                                                                                  |
   | >__ _ ____________________________________________________________ __| phrase 1 |_ ____________> |
   |    | |_ _BEFORE_ __ ___________ __ _ _identifier-2_ __ _______ _ _|               |              |
   |    |   |_AFTER__|  |_ADVANCING_|  | |_integer-1____|  |_LINE__| |                 |              |
   |    |                              |                   |_LINES_| |                 |              |
   |    |                              |_mnemonic-name-1_____________|                 |              |
   |    |                              |_PAGE________________________|                 |              |
   |    |_| invalid_key |__| not_invalid_key |_________________________________________|              |
   |                                                                                                  |
   | >__ ___________ ______________________________________________________________________________>< |
   |    |_END-WRITE_|                                                                                 |
   |                                                                                                  |
   | phrase 1:                                                                                        |
   | |__ _________________________________________________ _________________________________________> |
   |    |_ ____ __ _END-OF-PAGE_ __imperative-statement-3_|                                           |
   |      |_AT_|  |_EOP_________|                                                                     |
   |                                                                                                  |
   | >__ ______________________________________________________ ____________________________________| |
   |    |_NOT__ ____ __ _END-OF-PAGE_ __imperative-statement-4_|                                      |
   |           |_AT_|  |_EOP_________|                                                                |
   |                                                                                                  |
   | invalid_key:                                                                                     |
   | |__ ________________________________________________ __________________________________________| |
   |    |_ INVALID __ _______ __ imperative-statement-1 _|                                            |
   |                 |_ KEY _|                                                                        |
   |                                                                                                  |
   |  not_invalid_key :                                                                               |
   | |__ ____________________________________________________ ______________________________________| |
   |    |_ NOT INVALID __ _______ __ imperative-statement-2 _|                                        |
   |                     |_ KEY _|                                                                    |
   |                                                                                                  |
   | Note:                                                                                            |
   | (1)  The BEFORE, AFTER, INVALID KEY, and AT END OF PAGE phrases are not valid for STL files,     |
   |      OS/390 and VM VSAM files, or OS/2 Btrieve files.                                            |
   |                                                                                                  |
   |__________________________________________________________________________________________________|


    ___ Format 2--Indexed and Relative Files _______________________________ 
   |                                                                        |
   | >>__WRITE__record-name-1__ ____________________ _____________________> |
   |                           |_FROM__identifier-1_|                       |
   |                                                                        |
   | >__ __________________________________________ ______________________> |
   |    |_INVALID__ _____ __imperative-statement-1_|                        |
   |               |_KEY_|                                                  |
   |                                                                        |
   | >__ ______________________________________________ __________________> |
   |    |_NOT INVALID__ _____ __imperative-statement-2_|                    |
   |                   |_KEY_|                                              |
   |                                                                        |
   | >__ ___________ ____________________________________________________>< |
   |    |_END-WRITE_|                                                       |
   |                                                                        |
   |________________________________________________________________________|

    ___________________________________________________________________________ 
 X |                                                                           |
 X | >>__WRITE__record-name-1__ ____________________ ________________________> |
 X |                           |_FROM__identifier-1_|                          |
   |                                                                           |
 X | >____ ___________________________________________________________ ______> |
 X |      |___AFTER____ ___________ __ _ _identifier-2_ __ _______ _ _|        |
 X |                   |_ADVANCING_|  | |_integer-1____|  |_LINE__| |          |
 X |                                  |                   |_LINES_| |          |
 X |                                  |_PAGE________________________|          |
   |                                                                           |
 X | >__ ___________ _______________________________________________________>< |
 X |    |_END-WRITE_|                                                          |
   |                                                                           |
   |___________________________________________________________________________|
record-name-1
Must be defined in a Data Division FD entry. Record-name-1 can be qualified. It must not be associated with a sort or merge file.


X If record-name-1 is defined as a DBCS data item, Identifier-1 must be
X a DBCS data item.


X For relative files, as an IBM extension, the number of character
X positions in the record-name can be different from the number of
X character positions in the record being replaced.

FROM phrase
The result of the execution of the WRITE statement with the FROM identifier-1 phrase is equivalent to the execution of the following statements in the order specified:


         MOVE identifier-1 TO record-name-1.
         WRITE record-name-1.

The MOVE is performed according to the rules for the MOVE statement without the CORRESPONDING phrase.

identifier-1
Identifier-1 can be any of the following:

  • The name of an entry in the Working-Storage Section or the LINKAGE SECTION
  • The name of a record description for another previously opened file
  • The name of an alphanumeric function identifier
  • X A floating-point data item or a DBCS data item
    
    
Identifier-1 and record-name-1 must not refer to the same storage area.

After the WRITE statement is executed, the information is still available in identifier-1. (See "INTO/FROM Identifier Phrase" under "Common Processing Facilities" in topic 6.1.8.9.)

identifier-2
Must be an integer data item.

Subtopics:



Previous Topic Next Topic © Copyright IBM Corp. 1991, 1998

IBM Library Server Copyright 1989, 2005 IBM Corporation. All rights reserved.





Return to library:   z/OS | z/OS.e | TPF | z/VSE | z/VM | IBM Hardware | IBM System z Redbooks
Glossary:   IBM terminology
Publications:   How to order publications
Readers:   Download IBM Library Reader | Download IBM Softcopy Reader | Download Adobe® Acrobat® Reader®
Library management:   Download IBM Softcopy Librarian
Contacts:   Contact z/OS


Adobe, the Adobe logo, Acrobat, the Acrobat logo, and Acrobat Reader are registered trademarks of Adobe Systems incorporated.