Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Split a file using DFSORT

Status
Not open for further replies.

ashykhanna

Programmer
May 27, 2002
14
IN
Hi,
I have a huge file and i want that to be split into two.
I want the first file to contain all the records till a given condition. Suppose i have

100name Lowerlevel
101a1111programer
102a2222engineer
103a2323analyst
104a3434managers
105a2343smanager
106a4322Dmanager
i want the first file to have all records till i find a managers record and the second file should contain the rest. How can i achieve this using dfsort (no icetool).

file1

100name Lowerlevel
101a1111programer
102a2222engineer
103a2323analyst

file2

104a3434managers
105a2343smanager
106a4322Dmanager


Thanks,
Ashok
 
I don't know that you can do this with one execution of SORT since there is only one output DD in the JCL (SORTOUT). But you could get it done with 2 SORTs. In the first, you could use the OMIT control statement to omit all records that have "manager" in a certain column. In the second execution you could use the INCLUDE control statement to include only the records that have "manager" in a certain column.
 
Kenny -

I don't think that's what the poster had in mind. I think is was basically "copy to file 1 until this value shows up" and copy all following records to file 2. If one knew the record counter of the split point, one could do this easily.

I suppose there's a way to get the record count with SORT using the COUNT field and INCLUDE. One could then process that record/records with REXX to create a MERGE FIELDS=COPY job that produced two outputs; one using ENDREC and the other using STARTREC. Interesting exercise; ugly, but interesting.

Regards.

Glenn
 
It sounds to me that you are looking for the

OUTFILE

operation. See:


which says (among other things),

"Creation of multiple output data sets containing different ranges or subsets of records from a single pass over one or more input data sets. In addition, records that are not selected for any subset can be saved in a separate output data set."

The very first example at:


seems to me to be what you are asking for.

Bill Klein
 
P.S. to my last post.

Of course, cince you asked this in a COBOL forum, it would be a "piece of cake" to do this in a COBOL program with an internal SORT - with an Output Procedure <G>.

Bill Klein
 
Let me be more clear..

100name Lowerlevel
101a1111programer
102a2222engineer
103a2323analyst
104a3434managers
105a2343fdfdf
106a4322gfgfhh

File 1

100name Lowerlevel
101a1111programer
102a2222engineer
103a2323analyst

File 2

104a3434managers
105a2343fdfdf
106a4322gfgfhh

WMK,
I guess the link you sent is not the solution.

can anyone explain me with the code (only JCL - DFSORT, No cobol pls)

Thanks in advance.
Ashok

 
Bill -

As I pointed out in my prior post, one has to know a priori what the record number is for the split point. I think the poster wants sort to figure that out somehow.

Glenn
 
So you want file 1 to contain from 1st record up to the manager record and all the rest goes to file2? If this is the case use a switch and read the file sequentially. Sample below in COBOL.

Move 0 to Switch1.

PERFORM until (end-of-file)
read TheFile.

if Record contain "Manager"
move 1 to Switch1


if Switch1 = 0
add record to File1
else
add record to File2
end-if

end-perform.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top