View previous topic :: View next topic
|
Author |
Message |
Amb
New User
Joined: 12 Mar 2010 Posts: 64 Location: India
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
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 |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
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 |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|