Call the sort utility from program COBOL



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Call the sort utility from program COBOL

Postby IARRUDA » Fri Jun 19, 2009 9:42 pm

Hi,

Is it possible to call the utility SORT in a program Cobol? If it is possible, Is there some example?

Thank a lot.
IARRUDA
 
Posts: 4
Joined: Fri Jun 19, 2009 9:13 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Call the sort utility from program COBOL

Postby Frank Yaeger » Fri Jun 19, 2009 10:55 pm

COBOL has built-in features for calling DFSORT. How exactly you would call DFSORT from COBOL depends on exactly what you want to do.
It's best to consult your COBOL manual for details, but you can also find relevant information in "z/OS DFSORT Tuning Guide" at:

http://publibz.boulder.ibm.com/cgi-bin/ ... 0528173317
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Re: Call the sort utility from program COBOL

Postby dick scherrer » Sat Jun 20, 2009 1:49 am

Hello and welcome to the forum,

To incorporate an "internal sort" into your code, you code a SELECT/ASSIGN, an SD (rather than an FD), and a SORT statement in the procedure division.

As Frank mentioned, the COBOL manual has full details.

If performance is an issue on your system, do not specify both USING and GIVING in the SORT statement. Quite often a process will require neither USING nor GIVING but lazy coders over-use these.

If there are questions about the code, post back here and we will be able to help. We can move your topic to COBOL if that becomes desirable.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Call the sort utility from program COBOL

Postby IARRUDA » Mon Jun 22, 2009 10:02 pm

Hi

I can´t use the internal sort, I am trying use call DFSORT because I need extract records under conditions using search fields, moreover I won't know how many files will be processed.

I have looked at the link that Frank sent me and I think there are something to help me. I will let you know if I get the way or not.

Thank you a lot Frank and Dick for the precious help that both provided me.
IARRUDA
 
Posts: 4
Joined: Fri Jun 19, 2009 9:13 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Call the sort utility from program COBOL

Postby Frank Yaeger » Tue Jun 23, 2009 12:58 am

can´t use the internal sort,


I think you're confused about what "internal sort" means.

An internal sort is just another way of saying that you are calling DFSORT from a COBOL program using the built-in mechanisms that COBOL provides for that purpose.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Re: Call the sort utility from program COBOL

Postby dick scherrer » Wed Jun 24, 2009 3:15 am

Hello,

Are you making progress?

I can´t use the internal sort
I suspect that if you can find a way to what you need "invoking DFSORT" you could also use the SORT statement. . .

I am trying use call DFSORT because I need extract records under conditions using search fields, moreover I won't know how many files will be processed.
This is more of a COBOL challange than a sorting challange. Keep in mind that you would not implement using/giving in your code, but rather iniput/output procedure. When input/output procedure are used any number of files can be read and "search fields" can be evalueated and only needed data would be RELEASEd to the sort. Similarly, when sorted records are RETURNed from the sort, you have complete control over the processing.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Call the sort utility from program COBOL

Postby IARRUDA » Thu Jun 25, 2009 10:29 pm

I understood wath you tell me, but I can´t follow this way, the proccess is allocating the input and output files dynamically, I don´t know the atributes of those input files, RECFM, LRECL, the program obtain it directly from catalog, there is an input file where are the parameters as file name, disc unit that is inputed by user. So, when I run the program I no have idea how many or what files will be processed, the program access the catalog to get those informations, I can´t define SD or FD because I don´t know the record length, when we run the sort by JCL we can use "DCB=*.SORTIN" in this case. Probably I will look for other way.

I Have the same problem with another proccess but It works with DB2, I will look for the way to unload and load Db2 tables into program cobol without include de DCLGEN, I need generate the syspunch on proccess time. If I can´t solve it I will post it to DB2.
IARRUDA
 
Posts: 4
Joined: Fri Jun 19, 2009 9:13 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Call the sort utility from program COBOL

Postby dick scherrer » Fri Jun 26, 2009 2:45 am

Hello,

If you don't know the attributes, you probably don't know where the fields are either - or the field attributes. . . What business rules might be applied when the data is not known/constant?

What you describe does not sound like a job for a cobol program - with or without invoking the sort. . . :?

If you explain what you are really trying to do (rather than how you've chosen to try to solve it), someone may have a suggestion.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Call the sort utility from program COBOL

Postby IARRUDA » Sat Jun 27, 2009 12:33 am

Helo

What I am saying is that I am developing a program able to any file types, record lenght and record type, for this the attributes are looked for at moment of processing.

The steps of the proccess are:

On line
-The input files are selected by an user (may be diferent layouts and diferents file types, no limit for quantity of file)
-The selection criteria for the records is inputed for each file
-A sequential file is generated containing records with file name, file type and selection criteria for position (sort include or omit cond syntax). This file will be input parameters for my program.

Batch
-Read the input file generated above.
-For each record get the atribute for the file in the catalog
-Allocate the data set dinamicaly because I couldn´t define the I-O section in the program
-Open it
-Here is the problem, if I read all records without need use selection criteria, no problem, it already set, but when needs select records I had figured out that was possible by calling DFSORT into cobol program.

Thank you so much
IARRUDA
 
Posts: 4
Joined: Fri Jun 19, 2009 9:13 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Call the sort utility from program COBOL

Postby Frank Yaeger » Sat Jun 27, 2009 1:12 am

Not sure if this will help, but ...

COBOL's SORT-CONTROL Special Register can be used to pass a different INCLUDE statement to DFSORT for each COBOL SORT verb used.

For more information on this technique, see the "Multiple COBOL Sorts - SORT-CONTROL Special Register" section in the following DFSORT Year2000 paper at:

http://www.ibm.com/systems/support/stor ... index.html

You can put your INCLUDE statements in the CTLxCNTL data sets. You could build the SRTxDD and CTLxCNTL data sets dynamically. Just make sure they have RECFM=FB and LRECL=80.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Next

Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post