MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

File I/O Mode

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12370
Topics: 75
Location: San Jose

PostPosted: Sun Dec 01, 2002 10:50 pm    Post subject: File I/O Mode Reply with quote

Q.I want a sequential File to be opened in the i/o mode and if a condition is matched I will be updating the said sequential file.Can I have a sample code of how to do this task in cobol??

Answer:

Code:

IDENTIFICATION DIVISION.
PROGRAM-ID.    INOUT.   
AUTHOR.        KOLUSU. 
DATE-WRITTEN.  12/01/2002
DATE-COMPILED.
ENVIRONMENT DIVISION.                                           
CONFIGURATION SECTION.
SPECIAL-NAMES.
INPUT-OUTPUT SECTION.
FILE-CONTROL.

     SELECT INPUT-PARM-FILE
            ASSIGN TO INPARM
            FILE STATUS IS W-PARM-FILE-STATUS
            ORGANIZATION IS SEQUENTIAL.
 DATA DIVISION.

 FILE SECTION.
                                                                 
 FD  INPUT-PARM-FILE
     RECORDING MODE F
     LABEL RECORDS ARE STANDARD
     BLOCK CONTAINS 0 RECORDS
     DATA RECORD IS INPUT-PARM-REC.

 01  INPUT-PARM-REC.
     05  I-KEY                   PIC X(5).
     05  FILLER                  PIC X(09).
     05  I-VAR                   PIC X(3).
     05  FILLER                  PIC X(63).

 WORKING-STORAGE SECTION.
 01 S-INPUT-PARM-EOF             PIC X(01)  VALUE 'N'.

 01 W-REC.
    05  W-KEY                    PIC X(5).
    05  FILLER                   PIC X(09).
    05  W-VAR                    PIC X(3).
    05  FILLER                   PIC X(63).

 01 W-PARM-FILE-STATUS           PIC X(02) VALUE '00'.
 01 W-COUNT                      PIC 9(09) VALUE 0.
******************************************************************
 PROCEDURE DIVISION.
******************************************************************

 0000-MAINLINE.

      OPEN I-O  INPUT-PARM-FILE
      PERFORM 2000-READ-PARM-FILE

      PERFORM UNTIL S-INPUT-PARM-EOF = 'Y'
         IF W-KEY   = ('23456' OR '67890')
            MOVE  'ABC'           TO W-VAR
            REWRITE INPUT-PARM-REC   FROM W-REC
            ADD +1                TO W-COUNT
         END-IF
         PERFORM 2000-READ-PARM-FILE
      END-PERFORM
                                                                 
      CLOSE  INPUT-PARM-FILE
      DISPLAY 'NO: OF REWRITES:' W-COUNT
 
     GOBACK
     .
                                                                 
 2000-READ-PARM-FILE.
******************************************************************
* THIS PARAGRAPH IS PERFORMED TO READ THE INPUT FILE.            *
******************************************************************

      MOVE SPACES TO W-REC

      READ INPUT-PARM-FILE  INTO W-REC
         AT END
            MOVE 'Y'           TO S-INPUT-PARM-EOF
      END-READ
      .                                                         
Back to top
View user's profile Send private message Send e-mail Visit poster's website
GaneshB
Beginner


Joined: 03 Dec 2002
Posts: 17
Topics: 5
Location: Columbus, GA

PostPosted: Sat Dec 07, 2002 3:26 pm    Post subject: Reply with quote

Kolusu,

Your post is very useful. Thanks for the information. Is it possible to update a record in an ESDS file?
_________________
Regards,
Ganesh.B
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12370
Topics: 75
Location: San Jose

PostPosted: Sat Dec 07, 2002 5:45 pm    Post subject: Reply with quote

GaneshB,

An ESDS is comparable to a sequential non-VSAM data set in the sense that records are sequenced by the order of their entry in the data set, rather than by key field in the logical record. This could be fixed or variable length records.All new records are placed at the end of the data set. Existing records can never be deleted. If the application wants to delete a record, it must flag that record as inactive. As far as VSAM is concerned, the record is not deleted. It is the responsibility of the application program to identify that record as invalid.

Records can be updated,but without length change. To change the length of a record, you must either store it at the end of the data set as a new record, or override an existing record of the same length that you have flagged as inactive.

A record can be accessed sequentially or directly by its RBA:


  • Sequential processing: VSAM automatically retrieves records in stored sequence. Sequential processing can be started from the beginning or somewhere in the middle of a data set. If processing is to begin in the middle of a data set, positioning is necessary before sequential processing can be performed.

  • Direct processing: When a record is loaded or added, VSAM indicates its RBA. To retrieve records directly, you must supply the RBA for the record as a search argument. Although an ESDS does not contain an index component, you can build an alternate index to keep track of these RBAs.Skip sequential processing is not allowed for an ESDS.


Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
GaneshB
Beginner


Joined: 03 Dec 2002
Posts: 17
Topics: 5
Location: Columbus, GA

PostPosted: Sun Dec 08, 2002 8:59 am    Post subject: Reply with quote

Kolusu,

Thanks for the information & quick response.
_________________
Regards,
Ganesh.B
Back to top
View user's profile Send private message Send e-mail
Bechu
Beginner


Joined: 02 Dec 2002
Posts: 2
Topics: 0
Location: Kottayam, Kerala, India

PostPosted: Mon Dec 09, 2002 5:29 am    Post subject: Reply with quote

Kolusu,

Excellent piece of information. However I beg to differ on one small point:

Quote:
Skip sequential processing is not allowed for an ESDS.


I too had the same impression till the middle of last week. I came across a program(online) that plays with an ESDS, using RBA. I distinctly remember that the program did skip sequential processing too.

Perhaps we can say "Skip sequential processing is not allowed for an ESDS in a batch program (COBOL)". Or is that possible too ? Confused

Thanks,
Bechu
Back to top
View user's profile Send private message Send e-mail
Mike Tebb
Beginner


Joined: 02 Dec 2002
Posts: 20
Topics: 0
Location: Yorkshire, England

PostPosted: Mon Dec 09, 2002 5:58 am    Post subject: Reply with quote

Bechu, yes you are quite right that in CICS it is possible to read directly from an ESDS file by using the Relative Bytes Address.

That is not an option in batch COBOL as far as I am aware.
_________________
Cheers - Mike
Back to top
View user's profile Send private message
Manas Biswal
Intermediate


Joined: 29 Nov 2002
Posts: 382
Topics: 27
Location: Chennai, India

PostPosted: Mon Dec 09, 2002 6:23 am    Post subject: Reply with quote

Hi Bechu, Ravi and Mike
Kolusu is talking about skip sequential processing and not Random Read using RBA. You can very well specify the exact RBA and do a random read from an ESDS in CICS. But I am not too sure about skip sequential processing. In skip seq processing, you basically read records sequentially using STARTBR and READNEXT with the option of skipping some records by directly specifying the key in the RIDFLD parameter. And I am not sure that you can do the same for VSAM ESDS in CICS.
As a matter of fact, I think you cannot also use the GTEQ option(in STARTBR) to position the pointer to the next record after your partial key.
Whatever programs that I have seen using CICS-VSAM ESDS(Not many) first of all move LOW VALUES or HIGH VALUES to the RBA WS field and then issue successive READNEXT or READPREV commands to process records forward or backward sequentially. There is of course a RANDOM READ using RBA which is separate from this.
Please correct me if I am wrong.
Regards,
Manas
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
Bechu
Beginner


Joined: 02 Dec 2002
Posts: 2
Topics: 0
Location: Kottayam, Kerala, India

PostPosted: Mon Dec 09, 2002 8:24 am    Post subject: Reply with quote

Manas,

We too were talking about skip sequential processing and not random read using RBA.

1. Yes, you can use STARTBR and READNEXT with ESDS in CICS, provided you know the RBA.

2. You may be right about the GTEQ option (I have never tried it), but we really don't need GTEQ. If you know the RECL and the record number you are trying to access, RBA can be easily computed and used with STARTBR and EQ itself. (i.e. RBA of first record is 0, LRECL is 100, then you can know that the second record's RBA is 100, third's is 200, tenth's is 900 etc.) I don't see any reason why we'll ever have to do a GTEQ 250 or so! It also does not make sense to use a 'partial key' for an ESDS, which you have mentioned.

Anyway, why worry too much about things that can be easily done with a KSDS? Why force an ESDS to behave like a KSDS? Let us use it for simple functions it is capable of. The others we'll leave to the KSDS.

My question was "Is it right to say skip-sequential processing is not possible on an ESDS?". The answer just happens to be NO (at least, in CICS).

Thanks,
Bechu
Back to top
View user's profile Send private message Send e-mail
Manas Biswal
Intermediate


Joined: 29 Nov 2002
Posts: 382
Topics: 27
Location: Chennai, India

PostPosted: Mon Dec 09, 2002 9:12 am    Post subject: Reply with quote

Hi Bechu,
Let me make myself a little bit clearer. The following is for KSDS.
Code:

EXEC CICS STARTBR
                 DATASET(FCT ENTRY)
                 RIDFLD(WS-RECORD-PARTIAL-KEY)
                 GTEQ
END-EXEC
 

The above code positions the pointer at the first record greater than or equal to the partial key mentioned in the RIDFLD parameter.
Code:

EXEC CICS READNEXT
                  DATASET(FCT ENTRY)
                  INTO(WS-AREA)
                  RIDFLD(WS-RECORD-KEY)
END-EXEC.

The above code will read the first record into the ws area and at the same time will populate the entire key in WS-RECORD-KEY for that record.
Now, if we want to do skip seq processing, we will move a record key(some other record key other than the sequentially next record) into WS-RECORD-KEY and then execute
Code:

EXEC CICS READNEXT
                  DATASET(FCT ENTRY)
                  INTO(WS-AREA)
                  RIDFLD(WS-RECORD-KEY)
END-EXEC.
 

This will now start sequential processing from the record whose key is mentioned in WS-RECORD-KEY.
Basically, we are not doing a random read.(WE ARE STILL USING READNEXT AND NOT READ) We are processing sequentially only but with skips in between by specifying a record key which is not the next seq key.
Now, my question is can we do the same thing for an ESDS using RBA? I am not talking of a random read but seq processing with skips like this.
Regards,
Manas
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 699
Topics: 63
Location: USA

PostPosted: Wed Jan 22, 2003 8:07 am    Post subject: Reply with quote

Hi,

Through a single CICS program I want to add a record to a VSAM ESDS and update it a few times. I don't know how to go about it. Can some body help me here, starting from add step.

Thanks,
Dibakar.
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12370
Topics: 75
Location: San Jose

PostPosted: Wed Jan 22, 2003 8:46 am    Post subject: Reply with quote

Dibakar,

Adding records

Updating records with the READ command

READ Syntax

WRITE Syntax

REWRITE Syntax


Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 699
Topics: 63
Location: USA

PostPosted: Wed Jan 22, 2003 9:37 am    Post subject: Reply with quote

It helped.
Thanks,
Dibakar.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group