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
 

 

Reading last 2 records from ESDS

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

New User


Joined: 25 Aug 2006
Posts: 3

PostPosted: Sat Dec 30, 2006 10:09 pm    Post subject: Reading last 2 records from ESDS
Reply with quote

Hi All,

I want 2 know that,in ESDS if we have 10 records n i want to read last 2 record's /rewirte record's so its possible by COBOL.

Cheers
virat
Back to top
View user's profile Send private message

William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Sat Dec 30, 2006 10:39 pm    Post subject:
Reply with quote

From the FM:
Quote:
For ESDS, declare ACCESS IS SEQUENTIAL,
then OPEN EXTEND, WRITE & CLOSE
or OPEN I-O, READ, REWRITE & CLOSE
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Wed Jan 03, 2007 6:16 am    Post subject: Re: Reading last 2 records from ESDS
Reply with quote

Bill,

virat is looking to read/rewrite the last two records in a ESDS file.

How does you post answer his question icon_question.gif icon_eek.gif
Back to top
View user's profile Send private message
h.dinesh

New User


Joined: 06 Dec 2006
Posts: 46
Location: Chennai

PostPosted: Wed Jan 03, 2007 12:22 pm    Post subject:
Reply with quote

Virat,

Yes, you can rewrite last two records of an ESDS.

Dinesh
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Wed Jan 03, 2007 2:16 pm    Post subject: Re: Reading last 2 records from ESDS
Reply with quote

DavidatK wrote:
virat is looking to read/rewrite the last two records in a ESDS file.
How does you post answer his question icon_question.gif icon_eek.gif
Simple, the post listed the COBOL verbs needed to do what he wanted, I'm sure that he is smart enough to use the information.
Back to top
View user's profile Send private message
prav_06
Warnings : 1

Active User


Joined: 13 Dec 2005
Posts: 154
Location: The Netherlands

PostPosted: Fri Jan 05, 2007 2:48 pm    Post subject: Reading last 2 records from ESDS
Reply with quote

Virat there are many ways to read the last 2 rec. from your ESDS , one of the ways is to open your file, count the number of records in it and assign it to variable 'n' then close the file , read the same file again repeatedly till n-2 times then read or re-write the records , this is one ways to access the last two records of a ESDS (Sequential approach), if you want to dynamically access the last two records in a ESDS it can be done only via a CICS- COBOL pgm with the help of the parameter called RBA in VSAM ..... William Could you please explain your approach plz...

Cheers,

Thamilzan.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Fri Jan 05, 2007 3:31 pm    Post subject:
Reply with quote

Assuming (as stated) 10 records:
Code:
access is sequential
open file i-o
perform 8 times
  read file
    at end display 'not enough records'
           abend
end-perform
read file
  at end display 'not enough records'
         abend
rewrite record
read file
  at end display 'not enough records'
         abend
rewrite record
read file
  at end display 'success'
         goback
display 'too many records'
abend
If not sure about exactly 10 records, Thamilzan's plan to count first and replace the "8 times" in the above code with Thamilzan's "n-2".
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Sat Jan 06, 2007 4:55 am    Post subject: Re: Reading last 2 records from ESDS
Reply with quote

virat,

Since ESDS files can only be read sequentially in COBOL, before you can re-write the last two records, you need to know how many to bypass. I cannot imagine why someone would need to re-write the last two records, as such. I can see that someone may need to re-write, say the two invoice records from company ?A? that were received today, and they could be the last two physical records on the file, but you would have some type of key to test against.

Back to the original question! My assumption is that, in fact you may or may not have exactly 10 records on the file, but need to re-write the last two records regardless of how many total records there are. ?Thamilzan? post looks like it is the only practical way to accomplish this. There are some other ways, that are somewhat controversial, like running the MVS control blocks via. the linkage section, and setting the current record pointer, but I don?t think that?s in the realm of what I would call ?COBOL?.

Again, I think ?Thamilzan? has got the solution.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Sat Jan 06, 2007 5:19 am    Post subject: Re: Reading last 2 records from ESDS
Reply with quote

DavidatK wrote:
There are some other ways, that are somewhat controversial, like running the MVS control blocks via. the linkage section, and setting the current record pointer,
Could you expand on that, I'm always looking for ways to do things that need to be done?
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Sat Jan 06, 2007 5:32 am    Post subject: Re: Reading last 2 records from ESDS
Reply with quote

Bill,

Start with this PREVIOUS POST

You will have to expand on some of the copybooks, and have a good understanding of the MVS control blocks (That I'm a little out of date on).

I've run the MVS control blocks in Assembler many times, but this is the first time trying it in COBOL. I played with this and I was supprised at where I probably should not have been able to go.

Have fun icon_biggrin.gif
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Sat Jan 06, 2007 5:47 am    Post subject:
Reply with quote

Aw, David, You miss the point of this forum....The original question included the words "if we have 10 records", so sometimes you have to deal wth people that want direct answers, the only problem with that is trying to figure out WHAT are they really asking for. Without full information, maybe just answering their "questions" might be enogh to allow them to think enough to pose the question they REALLY need answered.
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Sat Jan 06, 2007 7:59 am    Post subject: Re: Reading last 2 records from ESDS
Reply with quote

Come on William, The point of this forum is to help people with questions. I see, generally, those people that are just starting to learn programming and are asking very basic question, best as they can. (Don?t you remember when you were just starting out? When I was first introduced to programming, there was a period of time that I needed answers to questions and didn?t even know what the correct question to ask was). And another group of people that sound like they have been in the trade and asking more complex business/technical question.

Many, if not most of the members that post here have a limited ability in the English language, and if YOU read the rules, proper grammar is not being graded here. I give all the none-native English speaking a lot of credit, why don?t you try posting some of your response in one of the Indian dialects and see how you fare.

The point of this forum is NOT to criticize where it?s not due, but to ?read between the lines? and think about what the poster, without a good English background is trying to ask. "if we have 10 records" did not say "we have 10 records", ( and if your taking them verbatim, why did you check for less than 10 and greater than 10????). The poster was letting us know there were more then two records, you think?

Don?t take such a narrow view, open you eyes and mind. Try to see beyond your own inflated ego.

Still can?t find the keys?
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Sat Jan 06, 2007 10:28 am    Post subject: Re: Reading last 2 records from ESDS
Reply with quote

William,

After an hour drive home, a stop for dinner, and time to think about my post, I feel I need to add this addendum. If you EVER send me another PM as you did before, I WILL post it. Please keep you conceited egotistical comments to yourself.

Now, I do think you have a wonderful, broad knowledge base. I envy you in that; some of your posts are very informative. However, I cannot imagine what you are to work with if you are like this in a forum. I fear you would not be working for me for very long.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Jan 07, 2007 11:22 pm    Post subject:
Reply with quote

Hi Virat,

As stated by others here there are many ways to skin this cat. But they may not be adviseable if the file volume is high.

Assembler Language (there may be others) offers the best solution since it has a read back function. Works for KSDS files; not sure if it's avail to ESDS, but I can't see why not.

Second to that, FileAid uses Assembler to copy files. If you use FileAid in your shop you can create a file containing the last 3 recs of your ESDS file in a separate jobstep and access that in you cobol pgm. I've got the JCL if you want it.

Doing it this way eliminates the need to pass the entire file, which could be a consideration in some cases.
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 Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm


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