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

How to Append Records into KSDS VSAM file?


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

New User


Joined: 11 Apr 2006
Posts: 93

PostPosted: Mon Dec 21, 2009 12:05 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Dec 21, 2009 2:25 pm
Reply with quote

then use an ESDS vsam file.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Mon Dec 21, 2009 3:10 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Dec 21, 2009 8:13 pm
Reply with quote

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
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Tue Dec 22, 2009 3:09 pm
Reply with quote

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
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Tue Dec 22, 2009 3:15 pm
Reply with quote

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
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Tue Dec 22, 2009 3:26 pm
Reply with quote

Yes Garry.

Thanks for the explanation. Sigh.
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top