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
 

 

Question regarding internal sort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Question regarding internal sort
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: 6968
Location: porcelain throne

PostPosted: Mon Dec 20, 2010 3:53 pm    Post subject:
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: 8119
Location: East Dubuque, Illinois, USA

PostPosted: Mon Dec 20, 2010 5:17 pm    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Mon Dec 20, 2010 11:14 pm    Post subject:
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    Post subject:
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: 2435
Location: Netherlands, Amstelveen

PostPosted: Tue Dec 21, 2010 4:30 pm    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Tue Dec 21, 2010 9:50 pm    Post subject:
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    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 Db2 load job abending in SORT mistah kurtz DB2 4 Mon Jun 05, 2017 3:58 pm


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