View previous topic :: View next topic
|
Author |
Message |
Kumail Fazal
New User
Joined: 29 May 2007 Posts: 12 Location: Mysore
|
|
|
|
Hi,
Could somebody please assist me in writing a small EZT + pgm, where in i need to count the number of records in the input PS(sequential) file,
I dont want to read the entire file for getting the number of records in it as the file contains more than a billion records
Thanks |
|
Back to top |
|
|
ksk
Active User
Joined: 08 Jun 2006 Posts: 355 Location: New York
|
|
|
|
Hi,
If my undersatnding is correct, following solution may solve ur problem. Otherwise please post ur requirment with example.
READ the file and set the COUNTER. Do this until u get required number of records. SET a FLAG with the number of records u want to read in READ statement.
If this won't resolve ur problem please give the detaild informaion on ur query.
KSK |
|
Back to top |
|
|
acevedo
Active User
Joined: 11 May 2005 Posts: 344 Location: Spain
|
|
|
|
I'm afraid that solution won't solve the problem as the OP doesn't want to read the entire file
Kumail Fazal wrote: |
I dont want to read the entire file for getting the number of records in it as the file contains more than a billion records
|
|
|
Back to top |
|
|
Kumail Fazal
New User
Joined: 29 May 2007 Posts: 12 Location: Mysore
|
|
|
|
Hi,
See the the file details are LRECL(record length)=80,RECFM=FB.
The file is a flat file.
Please let me know if u need other details |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Kumail,
Quote: |
Could somebody please assist me in writing a small EZT/COBOL + pgm |
You could use ezt's RECORD-COUNT for your req.
Also what is that EZT/COBOL + pgm? |
|
Back to top |
|
|
Kumail Fazal
New User
Joined: 29 May 2007 Posts: 12 Location: Mysore
|
|
|
|
Hi,
EZT/COBOL means writing the code in either Easytrive or COBOL would solve the purpose.
Also could please elaborate a bit more on your solution?
Thanks |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Kumail,
Quote: |
CA-Easytrieve automatically provides the special data fields for each of your files. These fields are stored as part of working
storage but can be qualified by file-name. As working storage fields,
they are not subject to invalid file reference errors.
RECORD-COUNT
RECORD-COUNT is a read-only field that contains the number of logical
input operations performed to the file.
For CA-IDMS and IMS/DLI files, only automatic input increments
RECORD-COUNT. |
For more info, search the net.
Quote: |
EZT/COBOL means writing the code in either Easytrive or COBOL would solve the purpose.
|
I got this. But what COBOL + stand for? |
|
Back to top |
|
|
ksk
Active User
Joined: 08 Jun 2006 Posts: 355 Location: New York
|
|
|
|
Acevedo,
I am not asking him to read bellion of records. If he knows number of records he wants to read, he can provide that value in his procedure division statements.
E.g.,
Main-Para.
PERFORM Read-Para UNTIL FLAG1='Y'.
Main-Para-Exit.
Exit.
Read-Para.
MOVE 0 TO COUNTER1.
READ FILE1.
IF EOF (another flag need to be declared)
Perform Main-para-exit.
END-IF.
ADD 1 TO COUNTER1.
IF COUNTER1 = 10000 (If he watns to read Ten Thousand Records)
MOVE 'Y' TO FLAG1
ELSE
PERFORM READ-PARA
END-IF.
Please note that I have consider only counting the number of records in the above logic.
KSK |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
KSK,
Quote: |
If he knows number of records he wants to read, he can provide that value in his procedure division statements. |
Kumail wants know how many records present in the file. He doesn't have prior info.
Kumail,
You could use UTILITIES for getting the # of records (if you want it thru JCL). |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
I am always puzzled by this kind of questions...
I cannot think of them as "IT real world examples"
counting the number of records in a sequential file is usually one of the first programming samples/exercises given in a programming course ( for any language )
- no structured I/O area needed,
- a simple counter,
- basic end of file handling,
- at the end a display of the counter
there should not be any problem writing it.
As far as the other issue raised by the OP on the unwillingness to read all the file, he is out of luck, for the exact count he needs to read ALL the records.
So, why these questions?
It would be more confortable for the responders to see in the question
something like :
- I am learning
- it' s a programming test
- any lame excuse you like
- ...
And the replies would be more appropriate and helpful
regards
e.s |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
enrico-sorichetti,
Quote: |
I cannot think of them as "IT real world examples" |
I would not say that. We do use RECORD-COUNT option a lot before generating a report in my shop. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
Quote: |
I would not say that. We do use RECORD-COUNT option a lot before generating a report in my shop. |
My comment was on the way the question was posed,
if a shop has the need/the habit of counting records it would be a standard
well documented procedure and should not be reinvented every time
regards
e.s |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Hi Kumail Fazal,
REXX will suit better to your need. (Not sure though whether would you like to do it that way or not) |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
What I would like to point out is the POOR organization of the shops many posters work for.
most of the shops I was consulting for usually had for the newcomers a printed/online document
( even be a simple text file produced using the ISPF editor )
containing a short description of the home grown small tools and standards being used like..
- user data set allocation ( naming, dcb, space )
- use of the most common utilities
- security issues
- TSO short primer
- JCL standards
- how to solve the most common abends ( SB37, SE37, -805, ... )
- THE TELEPHONE NUMBER OF THE TECHNICAL SUPPORT STAFF
- ... add as many as You want
and they usually had a library ( sample name )
"xxxxxx.sample.jcllib"
with jcl samples of the most common utilities customized for their
standards
I did not take an exact count but the forum traffic is about 50% due to the lack of this very simple items available.
I wonder how these IT shops got their ISO900x ( or equivalent ) certification
I firmly believe that the objective of these forums is to help the individuals,
but also to teach IT shops how to run their business.
But alas... if their organizations do not change their BAD habits
we will continue to give free training/consultancy to those IDtenS
( not the posters, but the organizations they work for and their managers )
regards
e.s |
|
Back to top |
|
|
acevedo
Active User
Joined: 11 May 2005 Posts: 344 Location: Spain
|
|
|
|
how could Rexx, Cobol or DFSORT know the total records of a flat file without reading the whole file? |
|
Back to top |
|
|
Kumail Fazal
New User
Joined: 29 May 2007 Posts: 12 Location: Mysore
|
|
|
|
Hi,
Thanks everyone for all your inputs.
I cannot do it using a JCL(though i know it can be done) as my requirements does not allows me to do so.
I also cannot write a rexx code again due to my requirement issues and code delivery deadline
I'll try using murmohk1 solution of using Record-count.
If anyone has some other way of dealing with this problem, please share your thoughts |
|
Back to top |
|
|
acevedo
Active User
Joined: 11 May 2005 Posts: 344 Location: Spain
|
|
|
|
BUT what about your original requirement?
I dont want to read the entire file for getting the number of records
that's the KEY of this thread...do you think that using murmohk1 solution will avoid reading the whole file? |
|
Back to top |
|
|
Kumail Fazal
New User
Joined: 29 May 2007 Posts: 12 Location: Mysore
|
|
|
|
Hi,
I am trying the solution given by murmohk1, but i see a very less possibility of that working out as even RECORD-COUNT defination says that
"RECORD-COUNT is a read-only four-byte binary field with zero decimal places that contains the number of logical I/O operations performed on a file".
and i am also not sure of the syntax. But at this moment i have only this solution so pinning all my hopes on it. |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Kumail,
Quote: |
i am also not sure of the syntax. |
Its kind of KEYWORD..... doesn't have syntax. Search the net, you will get tonnes of info. |
|
Back to top |
|
|
Kumail Fazal
New User
Joined: 29 May 2007 Posts: 12 Location: Mysore
|
|
|
|
Hi murmohk1,
iI have got the syntax and i am browsing the net for more information.
Hope to get the slotion using the keyword "Record Count"
Thanks once again for sharing this. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
Quote: |
I cannot do it using a JCL(though i know it can be done) as my requirements does not allows me to do so. |
If it is not "homework" You should explain to Your manager/coordinator/...
that for simple tasks it much more productive and safe to use standard utilities
rather than write a program (which has to be documented, mantained, and so on)
regards
e.s |
|
Back to top |
|
|
richa gupta
New User
Joined: 29 Jul 2007 Posts: 8 Location: noida
|
|
|
|
if appropriate, you can sort the file and get the count . |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Rich,
Quote: |
you can sort the file |
I hope you are suggesting to use SORT utility and not really sorting the file. |
|
Back to top |
|
|
richa gupta
New User
Joined: 29 Jul 2007 Posts: 8 Location: noida
|
|
|
|
Yes Murali,
I was referring to SORT utility. SORT=COPY, will give the exact number of records sorted in the spool. |
|
Back to top |
|
|
|