View previous topic :: View next topic
|
Author |
Message |
babu_hi
New User
Joined: 11 Apr 2006 Posts: 93
|
|
|
|
I have a daily run job and it generates Sequntial file daily.Once this Sequential file generated i need to insert the recoreds in to KSDS VSAM file.This Vsam file should be conatain lsat 6 days data.
For that i opend the this KSDS VSAM file in EXTEND mode.Then i READ sequential file and write records in to KSDS VSAM file.First time(First day) all recoreds are write in to KSDS VSAM File But when i tried to Append second day recored in to KSDS VSAM file,First day recoreds are Override.But i want to append seconed day recored at end of the KSDS VSAM file.
COBOL Code:
SELECT OPTIONAL VSAM-OUT-FILE ASSIGN TO GENE220O.
ORGANIZATION IS INDEXED
ACCESS MODE IS SEQUENTIAL
ACCESS MODE IS DYNAMIC
RECORD KEY IS WS-VSAM-KEY
FILE STATUS IS VSAM-FILE-STATUS.
FD VSAM-OUT-FILE
LABEL RECORDS ARE STANDARD
DATA RECORD IS WS-VSAM-REC.
01 WS-VSAM-REC.
05 WS-VSAM-KEY.
10 WS-ACCOUNT-NUM.
15 WS-ACCNUM PIC X(10) VALUE SPACES.
15 FILLER PIC X(24) VALUE SPACES.
10 WS-AMOUNT PIC 9(12)V9(2) COMP-3.
10 WS-SQN PIC 9(05) VALUE ZEROS.
OPEN EXTEND VSAM-OUT-FILE
PERFORM UNTIL EOF-FLAG
READ DAILY-FILE
AT END
SET EOF-FLAG TO TRUE
NOT AT END
MOVE DAILY-VSAM-KEY TO WS-VSAM-KEY
WRITE WS-VSAM-REC
END-READ
END-PERFORM.
CLOSE VSAM-OUT-FILE.
JCL DD Statement:
//GENE220O DD DSN=IXXXD.VSAM.FILE,
// DISP=MOD |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
then use an ESDS vsam file. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
You DO NOT append, or mod, or much else to a KSDS file.
You INSERT records at the correct position within the file based on the key value.
As suggested by DBZ, use an ESDS. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
How is the file to be referenced after the data is put into the file?
Is it ok for the same "key" to exist for different "days"? Does having activity for a different day make duplicates ok?
Depending on how the data is to be used, you might add the "day" to the high-order part of the current key and inserts would be in the desired order.
If the actual need is that the data be "appended", yup, use an ESDS. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
IDCAMS REPRO will do the following :
Merges records by key and updates the index. Unless the REPLACE option is specified, records whose key duplicates a key in the output data set are lost.
The term merge is discutable, cause if the input keys are higher than
the highest key already present in the vsam dataset one could say the
records are appended. The input needs to be sorted of course. |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1193 Location: Dublin, Ireland
|
|
|
|
Quote: |
Unless the REPLACE option is specified, records whose key duplicates a key in the output data set are lost. |
And what happens to the original records if REPLACE is specified? I would have thought that they were lost?
If you don't specify REPLACE, the originals are retained and the new records are 'lost'.If you do specify REPLACE, the old records are replaced by the new ones - so the old ones are'lost'.
Garry. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Yes Garry.
Thanks for the explanation. Sigh. |
|
Back to top |
|
|
|