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

MOVE records from input dataset to VSAM file.


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
techslam

New User


Joined: 03 Dec 2010
Posts: 87
Location: India

PostPosted: Wed Dec 08, 2010 1:29 am
Reply with quote

Hi

I am a newbie to MAINFRAMES, so i need some help on my current task.

I have to write a cobol program which will do following :

Read an input file which looks like this :
Code:

123456788 XP 20100701 000000002
123456788 XP 20100707 000002006
123456788 XP 20100702 000000014
123456788 XP 20100706 000000002
123456788 YP 20100701 000000004
123456789 XP 20100701 000000002
123456789 XP 20100707 000002006
123456789 XP 20100702 000000014
123456789 XP 20100706 000000002
123456789 YP 20100701 000000004



where : 123456789 - admin key

X - code1
P - code2
20100701 - date
000000002 - count

The task is to create a VSAM file to store that the admin has been recieved and when it was received.

In the first run, empty VSAM file will be read.
So as it is not going to find any record, it must insert one record in it.
The record which must be inserted/moved should have the latest date for an admin key.

Thus output VSAM file will have records with unique admin key with the latest date.

Finally output must be like this :
Code:

123456788 XP 20100707 000002006
123456789 XP 20100707 000002006


i would also like to know how will I go ahead and create a new VSAM file to be usied in this program.

Any help would be highly appreciated and it will help me learn.
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: Wed Dec 08, 2010 1:34 am
Reply with quote

Hello,

Create a cobol layout for the new file (possibly/probably make this a COPY member so other programs can use it).

Use IDCAMS to delete/define the new vsam file.

Write code to read the sequential input and write the output into the vsam file.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8651
Location: Dubuque, Iowa, USA

PostPosted: Wed Dec 08, 2010 1:40 am
Reply with quote

Quote:
In the first run, empty VSAM file will be read.
Be careful here -- a VSAM file that has never had a record in it cannot be opened for input; you must write a record and delete that record to be able to open an empty VSAM file. So expecting to define the VSAM file, then read it will cause your program to fail.
Back to top
View user's profile Send private message
techslam

New User


Joined: 03 Dec 2010
Posts: 87
Location: India

PostPosted: Wed Dec 08, 2010 1:42 am
Reply with quote

Hello Dick,

Thanks for taking your time to help me with this task. Could you please elaborate on this ?

Thanks again.
Back to top
View user's profile Send private message
techslam

New User


Joined: 03 Dec 2010
Posts: 87
Location: India

PostPosted: Wed Dec 08, 2010 2:13 am
Reply with quote

Robert Sample wrote:
Quote:
In the first run, empty VSAM file will be read.
Be careful here -- a VSAM file that has never had a record in it cannot be opened for input; you must write a record and delete that record to be able to open an empty VSAM file. So expecting to define the VSAM file, then read it will cause your program to fail.



How do I do this ? Please guide.

Thanks
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: Wed Dec 08, 2010 2:46 am
Reply with quote

Hello,

I'm not sure why the first run should read an empty vsam file. . . There is no business reason to do this. . .

To make sure there is one record in the file use REPRO to load a record into the file.

What elaboration is needed? Do what is needed for each "step" and the job will be done. You should be able to find everything you need on your system - what you need to do is clone these and modify for your specifics. There are also many examples in our forum.

Suggest you also download the Redbook called VSAM Demystified:
www.redbooks.ibm.com/abstracts/sg246105.html?Open

We will help you work on the code and utility control statements if needed, but will not write them. . .
Back to top
View user's profile Send private message
techslam

New User


Joined: 03 Dec 2010
Posts: 87
Location: India

PostPosted: Wed Dec 08, 2010 3:47 am
Reply with quote

Thanks Dick for that manual on VSAM. it will help me a lot. icon_smile.gif
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: Wed Dec 08, 2010 4:15 am
Reply with quote

You're welcome - good luck icon_smile.gif

Someone will be here if there are questions,

d
Back to top
View user's profile Send private message
techslam

New User


Joined: 03 Dec 2010
Posts: 87
Location: India

PostPosted: Wed Dec 15, 2010 10:35 pm
Reply with quote

Hi

I have a VSAM file with a single record say,

Code:

123456789 20100701 20100707


where :
123456789 => admin-id
20100701 => first date
20100707 => last date

Now in my cobol program I read an input sequential file :

say, I have read a record for the same admin :

Code:

123456789 20100701 20100709


But this record has last date higher than the last date of vsam record.

All I want to do is update the VSAM file's last-date, whenever the last date read from sequential file is greater than last-date read of VSAM file.

How do I write this update code for VSAM.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8651
Location: Dubuque, Iowa, USA

PostPosted: Wed Dec 15, 2010 10:48 pm
Reply with quote

Quote:
I have a VSAM file
ESDS VSAM?
KSDS VSAM?
RRDS VSAM?
LDS VSAM?
You are not starting by providing enough information.

The solution will depend upon which kind of VSAM file you have.
Back to top
View user's profile Send private message
techslam

New User


Joined: 03 Dec 2010
Posts: 87
Location: India

PostPosted: Wed Dec 15, 2010 10:52 pm
Reply with quote

@Robert Sample

I have a KSDS VSAM file.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8651
Location: Dubuque, Iowa, USA

PostPosted: Wed Dec 15, 2010 10:57 pm
Reply with quote

Use REWRITE then.
Back to top
View user's profile Send private message
techslam

New User


Joined: 03 Dec 2010
Posts: 87
Location: India

PostPosted: Thu Dec 16, 2010 1:28 am
Reply with quote

Hi I have my VSAM definition in cobol program as :

Code:

FILE-CONTROL.                                   
    SELECT INPT-FILE            ASSIGN TO FILE1.
    SELECT VSAM-FILE            ASSIGN TO FILE2.
       ORGANIZATION IS INDEXED                 
       ACCESS MODE IS RANDOM                   
       RECORD KEY IS OP-ADMIN-KEY3.             


But after compilation, I end up with error

Code:

"ORGANIZATION" WAS INVALID.  SCANNING WAS RESUMED AT THE NEXT AREA "A" ITEM, LEVEL-NUMBER, OR THE START OF THE NEXT CLAUSE.


What am I doing wrong here ?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8651
Location: Dubuque, Iowa, USA

PostPosted: Thu Dec 16, 2010 1:38 am
Reply with quote

Code:
    SELECT VSAM-FILE            ASSIGN TO FILE2.
Take the period off -- the other clauses must be part of the SELECT statement.

And why is there no FILE STATUS clause?
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Selecting the max value from a file. DFSORT/ICETOOL 3
No new posts Change history of vsam file. JCL & VSAM 3
No new posts how to keep unpaired records with REPRO. JCL & VSAM 9
No new posts Repeat a DD line- comment and insert ... CA Products 3
No new posts Split large FB file based on Key coun... DFSORT/ICETOOL 4
Search our Forums:

Back to Top