Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How to Append Records into KSDS VSAM file?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: How to Append Records into KSDS VSAM file?
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: 6968
Location: porcelain throne

PostPosted: Mon Dec 21, 2009 2:25 pm    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Mon Dec 21, 2009 3:10 pm    Post subject:
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

Site Director


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

PostPosted: Mon Dec 21, 2009 8:13 pm    Post subject:
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: 2442
Location: Netherlands, Amstelveen

PostPosted: Tue Dec 22, 2009 3:09 pm    Post subject:
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

Active Member


Joined: 08 May 2006
Posts: 998
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Tue Dec 22, 2009 3:15 pm    Post subject:
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: 2442
Location: Netherlands, Amstelveen

PostPosted: Tue Dec 22, 2009 3:26 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Addition of two records on 2 fields amar143 SYNCSORT 8 Tue Oct 03, 2017 11:14 am
No new posts Execute JCL step based on the content... sprikitik JCL & VSAM 2 Tue Oct 03, 2017 10:03 am
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am
No new posts VSAM RLS Wait time blayek JCL & VSAM 2 Mon Oct 02, 2017 9:05 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us