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

Question regarding internal sort


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

New User


Joined: 12 Mar 2010
Posts: 64
Location: India

PostPosted: Mon Dec 20, 2010 3:21 pm
Reply with quote

Hi Guys,

I have got a doubt regarding Internal Sort in COBOL.

Input file is of Length 80 and has 10 fields.
I need to sort the input file on the first 3 fields.
After sorting the input file I need to move all the sorted data to the output file. Output file is of Length 80.

My question is
- How do I define the SD section?

option 1: (Here the SD file has 3 fields and remaining as FILLER which sums up the length to 80)

SD SORT-FILE
DATA RECORD IS SORT-RECORD.

01 SORT-RECORD.
05 Field-1 PIC X(10).
05 Field-2 PIC X(10).
05 Field-3 PIC X(10).
05 FILLER PIC X(50).

option 2: (Here the SD file has only the 3 sort fields)

SD SORT-FILE
DATA RECORD IS SORT-RECORD.

01 SORT-RECORD.
05 Field-1 PIC X(10).
05 Field-2 PIC X(10).
05 Field-3 PIC X(10).

I am basically confused as in what should be the length of the SD file.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Dec 20, 2010 3:53 pm
Reply with quote

AMBy,

why do you think a 'Record' definition of 30 would generate a record length of 80?

FD's, SD's are all the same. SD is a special FD for SORT.

but, all that is in the Ref and Programming Guide,
in case you want to change your standard operating procedure
and actually read the manuals to learn about COBOL.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Mon Dec 20, 2010 5:17 pm
Reply with quote

Based upon your statement
Quote:
After sorting the input file I need to move all the sorted data to the output file.
it appears you do not care whether any of the 50 bytes after the three sort fields are in the output file. Hence you can sort only the 30 bytes and only the 30 bytes will be in the output file.

If, of course, you wanted something else then perhaps you need to clarify exactly what you are wanting to do....
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Mon Dec 20, 2010 7:47 pm
Reply with quote

Does your requirements actually make it neccessary to use an internal sort routine in your application module?

Instead of building the sort into the application program, would you consider structuring your jobflow:

Application job step A -> Sort job step -> Application job step B

This would relieve you of coding around the internal sort, but instead develop JCL for the run of the sort utility. I assume that many shops have standardised proc steps in JCL for implementing external sort utilities, making the task a lot simpler.
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: Mon Dec 20, 2010 11:14 pm
Reply with quote

Hello,

Quote:
This would relieve you of coding around the internal sort, but instead develop JCL for the run of the sort utility. I assume that many shops have standardised proc steps in JCL for implementing external sort utilities, making the task a lot simpler.
Most of the places i've supported encourage using the internal sort for small/medium tasks.

Very large sorting requirements are done with an external sort.

All of the timing tests they've run show that the internal sort (properly used) will perform better than the 3 separate steps.
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Tue Dec 21, 2010 4:18 pm
Reply with quote

Most times when a small or medium ordered set has been required, the origin has been a DB2 query for which we want to establish a lookup cache in storage, and in these cases the query establishes the sort order.

I do not doubt at all that using internal sort are more efficient for smaller sets, but I think the complexity of the programs increases, because application behavior changes at least twice during program execution.
(Input procedures->Sort->Output procedures). In the organisations I have worked with, program complexity has never been encouraged or rewarded if simpler solutions exists.

But I think it will be a discussion worth bringing up in our internal mainframe forum!
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Tue Dec 21, 2010 4:30 pm
Reply with quote

Telling what? I just found out that calling external sort with low quantities
of data, external sort will do an internal sort. Now isnt that nice?
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Tue Dec 21, 2010 5:18 pm
Reply with quote

Peter,

I think the terms external/internal in your case refers to storage use, where external means using DASD space, and internal will sort the data in memory space.
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 Dec 21, 2010 9:50 pm
Reply with quote

Hello,

Quote:
Most times when a small or medium ordered set has been required, the origin has been a DB2 query for which we want to establish a lookup cache in storage, and in these cases the query establishes the sort order.
This may be true for some organizations, but most of the sorting i see comes from data pulled from qsam and vsam files. . .

Typically (when talking about a programming language such as COBOL) an "internal sort" is one that is invoked by the SORT statement within the code.

An external sort is invoked by a separate step and invokes "SORT" or whatever it is named on the system.
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 Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top