Split input file into multiple files using USER EXIT ROUTINE



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

Split input file into multiple files using USER EXIT ROUTINE

Postby vikasgarg85 » Tue Nov 08, 2011 7:41 pm

Hi All,

This is my first post to this board.

I am looking out for the steps which can be used to created multiple output files from a single input file using a COBOL USER EXIT routine.

My input file is having n records. I want to split this input file into multiple files based on matching/non-matching records from a control file.

In a normal SORT exit routine we define SORTIN/SORTOUT as input/output datasets. I need to know how can we use/override filenames specified in the OUTFIL statement in our COBOL program. Or if there is any other way of achieving using USER EXIT COBOL routine.

My input file looks like
FIELD1 FIELD2
===========
A1 B1
A2 B2
A3 B2
A3 B1
A4 B2


CONTROL FILE
=========
A1
A3

OUTFILE 01
=======
A1 B1
A3 B2
A3 B1


OUTFILE 02
=======
A2 B2
A4 B2

I know how to perform the task above by simply joining the files on the keys mentioned. However since i am trying to develop a standard rountine specific for my project i would be needing it do using USER EXIT COBOL routine.

Thanks for your help in advance..
vikasgarg85
 
Posts: 2
Joined: Tue Nov 08, 2011 7:39 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Split input file into multiple files using USER EXIT ROUTINE

 

Re: Split input file into multiple files using USER EXIT ROU

Postby BillyBoyo » Tue Nov 08, 2011 8:28 pm

From your description so far, I'm wondering if you are talking about a Cobol program with an internal sort (using the installed sort product and Cobol verbs) rather than a "sort exit".

A sort exit need have no files. It can have files, if it is necessary to insert records into the sort process, but wouldn't need them unless they have a particulare use in the program. You would not use SORTIN/SORTOUT or any files which DFSORT/ICETOOL is using. The point of the "exit" is to do additional processing which the Sort does not directly support.

If you can already know how to do your task with SORT itself, what is the specific need of a Cobol program of some type? I don't get that bit yet.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Split input file into multiple files using USER EXIT ROU

Postby Frank Yaeger » Wed Nov 09, 2011 12:08 am

I'd suggest that the easiest way is to have your COBOL user exit set an indicator in each output record that tells DFSORT which OUTFIL data set to use. Then your OUTFIL statements can process the output records records according to the indicators. For example, if your COBOL exit routine sets an indicator in position 81 of '1' for OUT1, '2' for OUT2 or '3' for OUT3, you might use OUTFIL statements like this:

    OUTFIL FNAMES=OUT1,INCLUDE=(81,1,CH,EQ,C'1'),BUILD=(1,80)
    OUTFIL FNAMES=OUT2,INCLUDE=(81,1,CH,EQ,C'2'),BUILD=(1,80)
    OUTFIL FNAMES=OUT3,INCLUDE=(81,1,CH,EQ,C'3'),BUILD=(1,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: 1080
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 14 times

Re: Split input file into multiple files using USER EXIT ROU

Postby vikasgarg85 » Sun Nov 13, 2011 9:04 am

Hi,

First of all, thank you for your replies.

@BillyBoy,
Atually i was looking out something that Frank has replied

@Frank,
I already had a thought in my mind for this approach.

However i was more interested in knowing if by anyway can we overwrite the file definition for OUT1, OUT2, OUT3 as mentioned by you in my SORT exit routine?


Thanks again for your response!!

Keep collborating...
vikasgarg85
 
Posts: 2
Joined: Tue Nov 08, 2011 7:39 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Split input file into multiple files using USER EXIT ROU

Postby BillyBoyo » Sun Nov 13, 2011 1:52 pm

I can less follow now what you want than previously.

How about describing for me what it is that you want to do, in as plain and simple a way as possible. Maybe even make it non-technical. Why do you feel you need to develop a standard thing. Try to describe the whole thing, without just resting on the decision you have already made as to how to implement it.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Split input file into multiple files using USER EXIT ROU

Postby Frank Yaeger » Tue Nov 15, 2011 12:39 am

A COBOL exit can write records to data sets it OPENs, processes and CLOSEs without DFSORT having any knowledge of those data sets. As far as DFSORT is concerned, the COBOL exit tells it that it is "deleting" each record so DFSORT does not write them to any output data sets.
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: 1080
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 14 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post