IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Internal Sort work files


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
nileshyp

New User


Joined: 22 Jun 2005
Posts: 65
Location: Mumbai

PostPosted: Tue Feb 15, 2011 5:26 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Feb 15, 2011 5:55 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Feb 15, 2011 9:47 pm
Reply with quote

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
View user's profile Send private message
nileshyp

New User


Joined: 22 Jun 2005
Posts: 65
Location: Mumbai

PostPosted: Tue Feb 15, 2011 11:21 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Feb 16, 2011 12:07 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Feb 16, 2011 1:55 am
Reply with quote

Hello,

Quote:
I explained the entire part.
Not really. . . icon_sad.gif

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
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Wed Feb 16, 2011 2:13 am
Reply with quote

dick scherrer wrote:
I have no idea what this CBOBOL references. . .

A COBOL programmer with a Boboli pizza crust? icon_lol.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts JCL sort card - get first day and las... JCL & VSAM 9
Search our Forums:

Back to Top