View previous topic :: View next topic
|
Author |
Message |
virat_garg
New User
Joined: 25 Aug 2006 Posts: 3
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
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 |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
Bill,
virat is looking to read/rewrite the last two records in a ESDS file.
How does you post answer his question |
|
Back to top |
|
|
h.dinesh
New User
Joined: 06 Dec 2006 Posts: 46 Location: Chennai
|
|
|
|
Virat,
Yes, you can rewrite last two records of an ESDS.
Dinesh |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
DavidatK wrote: |
virat is looking to read/rewrite the last two records in a ESDS file.
How does you post answer his question |
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 |
|
|
prav_06 Warnings : 1 Active User
Joined: 13 Dec 2005 Posts: 154 Location: The Netherlands
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
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 |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
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 |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
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 |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
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 |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
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 |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
|