Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

MOVE records from input dataset to VSAM file.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: MOVE records from input dataset to VSAM file.
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

Site Director


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

PostPosted: Wed Dec 08, 2010 1:34 am    Post subject:
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: 7913
Location: Bellevue, IA

PostPosted: Wed Dec 08, 2010 1:40 am    Post subject:
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    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Wed Dec 08, 2010 2:46 am    Post subject:
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:
http://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    Post subject:
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

Site Director


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

PostPosted: Wed Dec 08, 2010 4:15 am    Post subject: Reply to: MOVE records from input dataset to VSAM file.
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    Post subject:
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: 7913
Location: Bellevue, IA

PostPosted: Wed Dec 15, 2010 10:48 pm    Post subject:
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    Post subject:
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: 7913
Location: Bellevue, IA

PostPosted: Wed Dec 15, 2010 10:57 pm    Post subject:
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    Post subject:
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: 7913
Location: Bellevue, IA

PostPosted: Thu Dec 16, 2010 1:38 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 24 Tue Dec 06, 2016 8:04 pm
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us