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

input file to sort based on 3 fields


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

New User


Joined: 14 Jan 2009
Posts: 5
Location: Trivandrum

PostPosted: Wed Feb 17, 2010 10:42 am
Reply with quote

Hi Friends,
As I saw in Cobol Internal sort i have one input file i want to sort that file based on dep, div, zone.
can u please give me some idea how to put that logic.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Wed Feb 17, 2010 10:55 am
Reply with quote

Hello,

If the only requirement is to sort the file, there is no need for COBOL.

If there is more to the requirement than only sorting the data, you need to describe the requirement before anyone can provide much help.

At the top of the page is a link to "IBM Manuals". The first set of manuals is for COBOL. You can learn all about the internal SORT there.
Back to top
View user's profile Send private message
ranjith Kandimalla

New User


Joined: 14 Jan 2009
Posts: 5
Location: Trivandrum

PostPosted: Wed Feb 17, 2010 4:03 pm
Reply with quote

thahk you Dick,

but links are not opening here,

i want that logic on internal sort
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Wed Feb 17, 2010 4:06 pm
Reply with quote

What do you mean that the links are not opening, I have just tried them and they work OK
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Wed Feb 17, 2010 4:28 pm
Reply with quote

If you can open and post in this thread, you should be able to open the link posted in first post of this thread... icon_biggrin.gif
Back to top
View user's profile Send private message
bijal.awhad

New User


Joined: 19 Mar 2008
Posts: 51
Location: Pune

PostPosted: Wed Feb 17, 2010 6:49 pm
Reply with quote

Hi ranjith,

For the starting the basic format for the internal sort is as below
Code:
SORT file1 ON ASCENDING/DESCENDING KEY data-name1,dataname-2,data-name3......
USING file2 GIVING file3


where file1 is the workfile.Workfile is used during the process of sorting.You need to define work file by sort description (SD) entry.input file which needs be sorted is file2 & output file is file3.

You can get the detail information by going through the IBM Manuals
http://ibmmainframes.com/manuals.php
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Wed Feb 17, 2010 8:22 pm
Reply with quote

Anuj Dhawan wrote:
If you can open and post in this thread, you should be able to open the link posted in first post of this thread... icon_biggrin.gif
Was to OP referring to the IBM Manuals link or the actual ENTERPRISE COBOL Language Reference link?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Wed Feb 17, 2010 9:11 pm
Reply with quote

Hello,

Quote:
For the starting the basic format for the internal sort is as below
Code:
SORT file1 ON ASCENDING/DESCENDING KEY data-name1,dataname-2,data-name3......
USING file2 GIVING file3

where file1 is the workfile.Workfile is used during the process of sorting.You need to define work file by sort description (SD) entry.input file which needs be sorted is file2 & output file is file3.


The worst possible way to use the "internal sort" is to specify using and giving in the same process. . . . This should not be used as it wastes system resources due to unnecessary reads/writes of the data.
Back to top
View user's profile Send private message
bijal.awhad

New User


Joined: 19 Mar 2008
Posts: 51
Location: Pune

PostPosted: Wed Feb 17, 2010 9:57 pm
Reply with quote

Quote:
The worst possible way to use the "internal sort" is to specify using and giving in the same process. . . . This should not be used as it wastes system resources due to unnecessary reads/writes of the data.

Hi Dick,
Can you please explain why the unnecessary reads/writes of the data?
Which is the best method if i want to sort all the records in input file?

Regards
Bijal
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Wed Feb 17, 2010 10:13 pm
Reply with quote

Hello,

Quote:
Which is the best method if i want to sort all the records in input file?
This would depend on the actual requirement.

If there is data that needs to be in order before a process even begins, it may be better to simply sort the data before executing the actual code.

If only part of the input data is needed for the process, the original data could be read and the needed data RELEASEd to the internal SORT using an "input procedure". The sorted data can be RETURNed to the code in an "output procedure".

If the code creates the "file" to be sorted by using/giving, the entire file has to be written, then read into the sort, written back out by the sort, and then read one more time to actually process the sorted data. Every time i've seen using/giving it has been because the coder did not know how to code properly or was just being lazy. . .
Back to top
View user's profile Send private message
bijal.awhad

New User


Joined: 19 Mar 2008
Posts: 51
Location: Pune

PostPosted: Thu Feb 18, 2010 1:13 pm
Reply with quote

Thanks Dick for the detailed explanation. icon_biggrin.gif

Regards
Bijal
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Thu Feb 18, 2010 8:39 pm
Reply with quote

You're welcome - good luck icon_smile.gif

d
Back to top
View user's profile Send private message
jctgf
Currently Banned

Active User


Joined: 04 Nov 2006
Posts: 109

PostPosted: Wed Feb 24, 2010 4:36 pm
Reply with quote

Hi,

I wonder if the Cobol internal sort has an worse performance than a sort executed on the Jcl.

Should internal sort be avoided, generally speaking?

Sometimes using an internal sort seems to be a good idea because it will save the i/o operations needed to write the file and then read it again with an external sort.

What do you think, please?
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Wed Feb 24, 2010 6:34 pm
Reply with quote

Hi jctgf.

These are some of the posts which have been already discussed in the forums... icon_smile.gif

Topic1
Topic2
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Wed Feb 24, 2010 8:47 pm
Reply with quote

Hello,

Quote:
I wonder if the Cobol internal sort has an worse performance than a sort executed on the Jcl.
Sometimes. . .

Quote:
Should internal sort be avoided, generally speaking?
No. This is often a very good way to implement.

Quote:
Sometimes using an internal sort seems to be a good idea because it will save the i/o operations needed to write the file and then read it again with an external sort.
There are many good reasons to use an internal sort. There are also reasons to not use an internal sort.

I only have 2 rules that i most strongly support (unless i've forgotten something icon_smile.gif ):
1. do not sort huge volume (if most of the volume is to be discarded before sort records are RELEASEd, an internal sort may still be proper).
2. do not code both using and giving in the same SORT statement.
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 Unable to interpret a hex value to De... COBOL Programming 4
No new posts COBOL sorting, with input GDG base COBOL Programming 7
No new posts JCL sort to compare dates in two file... DFSORT/ICETOOL 2
No new posts Is this possible via sort (in one pass)? SYNCSORT 4
No new posts GDG generation name to GDG Base name ... DFSORT/ICETOOL 3
Search our Forums:

Back to Top