Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Internal Sort work files

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Internal Sort work files
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: 8120
Location: East Dubuque, Illinois, USA

PostPosted: Tue Feb 15, 2011 5:55 pm    Post subject:
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

Site Director


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

PostPosted: Tue Feb 15, 2011 9:47 pm    Post subject:
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    Post subject: Reply to: Internal Sort work files
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: 8120
Location: East Dubuque, Illinois, USA

PostPosted: Wed Feb 16, 2011 12:07 am    Post subject:
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

Site Director


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

PostPosted: Wed Feb 16, 2011 1:55 am    Post subject:
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: 1771
Location: Bloomington, IL

PostPosted: Wed Feb 16, 2011 2:13 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SORT to unpack a feild shr_amar DFSORT/ICETOOL 7 Fri Jul 07, 2017 4:32 am
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts Optimize sort inrec parse vishwakotin DFSORT/ICETOOL 6 Mon Jun 26, 2017 11:15 pm
No new posts Reduce CPU Times for Join Sort santoshn SYNCSORT 12 Sat Jun 10, 2017 1:40 pm
No new posts getting three output files out of JOI... migusd SYNCSORT 7 Mon Jun 05, 2017 11:30 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us