IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

KSDS direct READ clause after READ NEXT


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sophia.lee

New User


Joined: 25 Jul 2019
Posts: 2
Location: Repulic of Korea

PostPosted: Tue Oct 01, 2019 10:10 am
Reply with quote

Hi, all.

I'd like to ask the correct behavior of START-READ clause like below:

1. READ
No 'KEY IS' option defined. -> READ with its main key.
2. START
AIX is used as a key.
3. READ NEXT
AIX is used as a key for a sequential READ after START.
4. READ
No 'KEY IS' option defined. -> Which KEY should be used, main key or AIX used at the previous READ NEXT clause?


Code:
       IDENTIFICATION                                          DIVISION.
       PROGRAM-ID. DPTLMH.
       ENVIRONMENT                                             DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.

       SELECT IX-DPT-DATA-FILE ASSIGN TO DPTDD
              ACCESS MODE  IS  DYNAMIC
              ORGANIZATION IS  INDEXED
==>           RECORD KEY   IS  IX-DPT-DATA-KEY <==
              ALTERNATE RECORD KEY IS IX-DPT-DATA-ALT-KEY-01
==>           ALTERNATE RECORD KEY IS IX-DPT-DATA-ALT-KEY-02 <==
              FILE STATUS  IS  IX-DPT-DATA-FILE-STATUS.

       DATA DIVISION.
       FILE SECTION.

       FD  IX-DPT-DATA-FILE.
       01  IX-DPT-DATA-REC.
           03 IX-DPT-DATA-KEY.
              05 IX-DPT-DATA-KEY-NUM                       PIC 9(4).
              05 IX-DPT-DATA-KEY-BLOCK                     PIC X(41).
           03 IX-DPT-DATA-ALT-KEY-01.
              05 IX-DPT-DATA-KEY-NUM-01                    PIC 9(4).
              05 IX-DPT-DATA-CTR-01                        PIC 9(8).
           03 IX-DPT-DATA-ALT-KEY-02.
              05 IX-DPT-DATA-KEY-NUM-02                    PIC 9(4).
              05 IX-DPT-DATA-KEY-BLOCK-02                  PIC X(41).
           03 IX-DPT-DATA-BLOCK                            PIC X(512).

       WORKING-STORAGE SECTION.
       01  IX-DPT-DATA-FILE-STATUS              PIC X(02).

       PROCEDURE DIVISION.

           OPEN INPUT IX-DPT-DATA-FILE.

           MOVE 6666 TO IX-DPT-DATA-KEY-NUM.
           DISPLAY '### READ IX-DPT-DATA-FILE'
==>        READ IX-DPT-DATA-FILE <==
                                 INVALID KEY
                 DISPLAY '*** INVALID KEY ***'
           END-READ.

           MOVE 5555 TO IX-DPT-DATA-ALT-KEY-02.

           DISPLAY '### START IX-DPT-DATA-FILE KEY >= AIXKEY'
==>           START IX-DPT-DATA-FILE KEY >= IX-DPT-DATA-ALT-KEY-02 <==
                 INVALID KEY
                 DISPLAY '*** INVALID KEY ***'
           END-START.

           DISPLAY '### READ IX-DPT-DATA-FILE NEXT'
==>       READ IX-DPT-DATA-FILE NEXT AT END <==
                DISPLAY '*** AT END ***'
           NOT AT END
                DISPLAY '*** NOT AT END ***'
           END-READ.

           DISPLAY '### READ IX-DPT-DATA-FILE MAIN KEY'
==>        READ IX-DPT-DATA-FILE <==
                                 INVALID KEY
                 DISPLAY '*** INVALID KEY ***'
           END-READ.

           DISPLAY '### START IX-DPT-DATA-FILE = MAIN KEY'
           START IX-DPT-DATA-FILE KEY = IX-DPT-DATA-KEY

           CLOSE IX-DPT-DATA-FILE.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts FILE STATUS - 39 ON VARIABLE LENGTH V... COBOL Programming 2
No new posts Need to read duplicate rows from tabl... DB2 3
No new posts Read 4MB message and split into multi... COBOL Programming 9
No new posts how to read accounting information in... COBOL Programming 1
No new posts Dynamically read input files using BP... COBOL Programming 20
Search our Forums:

Back to Top