View previous topic :: View next topic
|
Author |
Message |
nileshyp
New User
Joined: 22 Jun 2005 Posts: 65 Location: Mumbai
|
|
|
|
Hi,
I have a requirement which states something like this:
Read File A
Read file B
take matchig records
then if ABC variable of A file is positive then sort on one field and create report A
If ABC is negative then sort on another filed and create report B
If XYZ filed has particular value then sort on another filed and Create report C
I am confused with internal sort and have below question
1: Do we need 3 different work files and 3 different sort?
2: We can use same work file and have 3 sort?
Please advise |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
You confused me with your questions! Are you talking about 3 different SORTWK work files -- the normal reference to "work files" in soritng -- or something else (and if so, what)?
You need one SD (and hence one SELECT statement) and the 01 under that SD needs to list all the possible sort fields. You will have three SORT statements in your program, referencing the different fields under the 01 for the SD for the different SORT verbs. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
What you want is not simply an internal sort. . .
Your post indicates 2 unrelated processes.
1. match/merge the 2 files to get the "matchig records".
2. process these matched records generating multiple reports. unless all 3 reports have the same content, one bit of code with an internal sort will probably not be sufficient.
The less you provide, the less we can help.
Possibly i misunderstand. . . |
|
Back to top |
|
|
nileshyp
New User
Joined: 22 Jun 2005 Posts: 65 Location: Mumbai
|
|
|
|
Hi,
I explained the entire part. However I need help only sort part as I have already done with the records matching part.
However there is a concept of temp. Work file in CBOBOL where in the file need not be defined in PROC/JCL but still we can use it for using verb in SORT.
But still im confuse on how to segregate the SORT logic that will create 3 reports.
Regards,
Nil |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
However there is a concept of temp. Work file in CBOBOL where in the file need not be defined in PROC/JCL but still we can use it for using verb in SORT. |
What is confusing me is that there is no such thing in COBOL as you are describing. Something like this should work (although I have not tested it):
Code: |
SELECT SORT-FILE ASSIGN TO SORTFILE.
.
.
.
SD SORT-FILE.
01 SORT-RECORD.
05 SORT-KEY-1 PIC X(??).
05 SORT-KEY-2 PIC X(??).
05 SORT-KEY-3 PIC X(??).
05 SORT-REST-OF-DATA ....
.
.
.
IF <LOGIC YOU WRITE TO DETERMINE FIRST SORT NEEDED>
SORT SORT-FILE
ASCENDING KEY SORT-KEY-1
...
ELSE IF <LOGIC YOU WRITE TO DETERMINE SECOND SORT NEEDED>
SORT SORT-FILE
ASCENDING KEY SORT-KEY-2
...
ELSE SORT SORT-FILE
ASCENDING KEY SORT-KEY-3
...
END-IF
END-IF.
|
Note that SORTFILE must be a DD statement in your execution JCL -- typically pointing to a work file -- and the SPACE parameter for it will depend upon how many records you expect to sort (worst case). |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
I explained the entire part. |
Not really. . .
Just because you believe you have provided enough info does not mean that you have actually done so . . . You know exactly what you want, but no one here knows this. And you did not post sample outputs for the 3 reports.
To continue with Robert's approach (which will work for one report at a time - not all 3 in the same run), you will need similar code to determine which report to generate when the data is sorted.
There is more than the "internal sort" you need to deal with.
Are you using an IBM mainframe compiler? I have no idea what this CBOBOL references. . . |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
dick scherrer wrote: |
I have no idea what this CBOBOL references. . . |
A COBOL programmer with a Boboli pizza crust? |
|
Back to top |
|
|
|