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
 

 

input file to sort based on 3 fields

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: input file to sort based on 3 fields
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

Site Director


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

PostPosted: Wed Feb 17, 2010 10:55 am    Post subject:
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    Post subject: Reply to: input file to sort based on 3 fields
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: 8593
Location: Back in jolly old England

PostPosted: Wed Feb 17, 2010 4:06 pm    Post subject:
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

Senior Member


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

PostPosted: Wed Feb 17, 2010 4:28 pm    Post subject:
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    Post subject: Reply to: input file to sort based on 3 fields
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: 2150
Location: At my coffee table

PostPosted: Wed Feb 17, 2010 8:22 pm    Post subject:
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

Site Director


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

PostPosted: Wed Feb 17, 2010 9:11 pm    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Wed Feb 17, 2010 10:13 pm    Post subject:
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    Post subject: Reply to: input file to sort based on 3 fields
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

Site Director


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

PostPosted: Thu Feb 18, 2010 8:39 pm    Post subject: Reply to: input file to sort based on 3 fields
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    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Wed Feb 24, 2010 8:47 pm    Post subject:
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    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 High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm


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