View previous topic :: View next topic
|
Author |
Message |
Arch
New User
Joined: 30 Apr 2010 Posts: 11 Location: USA
|
|
|
|
Hi,
I have a similar requirement like the one Ambili has mentioned.. but i need to get this in cobol. is it possible to get the max value present in a file thru cobol? the data is not in sorted order.
I think I need to post my question under cobol and not here, but since the i have the same requirement, I m just putting the question here.
Thanks |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
ibmmainframes.com/viewtopic.php?t=41259
Quote: |
I think I need to post my question under cobol and not here, but since the i have the same requirement, I m just putting the question here. |
Yes, your topic has been split/moved.
Quote: |
is it possible to get the max value present in a file thru cobol? the data is not in sorted order. |
Sure. You can make 2 passes of the data (one to idenfity the max and one to get all of the records of the same bank). |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Arch wrote: |
Hi,
I have a similar requirement like the one Ambili has mentioned.. but i need to get this in cobol. is it possible to get the max value present in a file thru cobol? the data is not in sorted order.
I think I need to post my question under cobol and not here, but since the i have the same requirement, I m just putting the question here.
Thanks |
You don't expect us to write the COBOL program do you? |
|
Back to top |
|
|
Arch
New User
Joined: 30 Apr 2010 Posts: 11 Location: USA
|
|
|
|
of course, I am not expecting any one to write cobol program for me. I know I need to write my program. I was just expecting to know whether it is possible to use max function in cobol or not. |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Arch wrote: |
of course, I am not expecting any one to write cobol program for me. I know I need to write my program. I was just expecting to know whether it is possible to use max function in cobol or not. |
The question is WHY do you need the max function in COBOL? It is a simple check as you read the records one by one.
1. Define a Working storage variable for WS-TSTAMP and initialize it with spaces.
2. Read the record and now compare the file Timestamp to WS-TSTAMP
3. If file timestamp is Greater than just move the file-timestamp to WS-TSTAMP
4. Repeat steps 2 and 3 till the end of the file.
btw just for the record, if you still want to use the max function , then you can , all you need to do is load up the entire file records into a working storage table and then use the MAX function. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Is this hopeful thinking?
Occupation: software engineer
Mainframe Skills: cobol,jcl,db2,vsam |
|
Back to top |
|
|
Arch
New User
Joined: 30 Apr 2010 Posts: 11 Location: USA
|
|
|
|
sorry, forgot to mention that there will be atleast 80-100 million records in my file. So this comparison might take real long time. |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Arch wrote: |
sorry, forgot to mention that there will be atleast 80-100 million records in my file. So this comparison might take real long time. |
huh? It is a simple IF clause to compare the timestamp and you think it takes a real long time? The only time you would be wasting is the mount time of the tape ( Assuming that your input is on multi volume tape) and it wouldn't considered as CPU time.
And a cobol program in this case is much more efficient than a sort solution where you have to pass thru the data twice to get the desired results |
|
Back to top |
|
|
Arch
New User
Joined: 30 Apr 2010 Posts: 11 Location: USA
|
|
|
|
ok.. I will try to implement this comparison logic. Thanks for the answers.. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
I have a similar requirement like the one Ambili has mentioned.. |
I believe you need to explain exactly what this requirement is.
Among us, we have different perceptions of what is really needed.
The topic from which this was split is considerably more than finding a "max".
Show some sample input and the output you want from your program. |
|
Back to top |
|
|
|