View previous topic :: View next topic
|
Author |
Message |
ranjith Kandimalla
New User
Joined: 14 Jan 2009 Posts: 5 Location: Trivandrum
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
ranjith Kandimalla
New User
Joined: 14 Jan 2009 Posts: 5 Location: Trivandrum
|
|
|
|
thahk you Dick,
but links are not opening here,
i want that logic on internal sort |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
What do you mean that the links are not opening, I have just tried them and they work OK |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
If you can open and post in this thread, you should be able to open the link posted in first post of this thread... |
|
Back to top |
|
|
bijal.awhad
New User
Joined: 19 Mar 2008 Posts: 51 Location: Pune
|
|
|
|
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 |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
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... |
Was to OP referring to the IBM Manuals link or the actual ENTERPRISE COBOL Language Reference link? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
bijal.awhad
New User
Joined: 19 Mar 2008 Posts: 51 Location: Pune
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
bijal.awhad
New User
Joined: 19 Mar 2008 Posts: 51 Location: Pune
|
|
|
|
Thanks Dick for the detailed explanation.
Regards
Bijal |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
You're welcome - good luck
d |
|
Back to top |
|
|
jctgf Currently Banned Active User
Joined: 04 Nov 2006 Posts: 109
|
|
|
|
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 |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
Hi jctgf.
These are some of the posts which have been already discussed in the forums...
Topic1
Topic2 |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 ):
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 |
|
|
|