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
 

 

Need logic to read the last record

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
maheshurstd

New User


Joined: 16 Feb 2006
Posts: 14

PostPosted: Wed Jun 21, 2006 10:57 am    Post subject: Need logic to read the last record
Reply with quote

Hi

My requirement is that i have some records in a VSAM file, i want to read only the last record & i don't have record key values.
would it be possible for to read the last record.if any one has the code please send it or tell me a way to do it.
How to read the last record in case of DB2


Thanks in advance

Regards

Mahesh
Back to top
View user's profile Send private message

rdr

New User


Joined: 26 May 2006
Posts: 35
Location: india

PostPosted: Wed Jun 21, 2006 1:58 pm    Post subject:
Reply with quote

Hi,

(For VSAM)

Sort the file in decending order.

Now read the file you are actually reading the last record.....

Regards,
Rohit.
Back to top
View user's profile Send private message
kgumraj

Active User


Joined: 01 May 2006
Posts: 151
Location: Hyderabad

PostPosted: Wed Jun 21, 2006 6:46 pm    Post subject: Re: Need logic to read the last record
Reply with quote

Hi,
In DB2 you can give the query as follows

Select * from table order by <field name> DEC fetch 1 row only;
Back to top
View user's profile Send private message
rajandhla

Active User


Joined: 18 Oct 2005
Posts: 182
Location: Luton UK

PostPosted: Wed Jun 21, 2006 7:30 pm    Post subject:
Reply with quote

If you can use DFSsort , there is ENDREC option is available which you can use to get the last record......

Regards
jai
Back to top
View user's profile Send private message
maheshurstd

New User


Joined: 16 Feb 2006
Posts: 14

PostPosted: Fri Jun 23, 2006 10:21 am    Post subject: Re: Need logic to read the last record
Reply with quote

Hi Aji,

would it be possible to use the read file previos record syntax in cobol,
I need the logic by using the cobol program,please give me the syntax

Thanks

Mahesh
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Jun 24, 2006 9:08 pm    Post subject:
Reply with quote

Hi Mahesh,

You can only use that technique in a pgm that uses CICS.

Another way is to use FileAid in a prev step to get the last rec in a VSAM file and use COBOL in the next step to read it. Will that work for you?
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 Need to write record of PS File in ex... Chandan1993 JCL & VSAM 1 Wed Jun 07, 2017 1:35 am
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts Sort Large record length cmsmoon DFSORT/ICETOOL 14 Tue Apr 11, 2017 5:49 pm


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