Page 1 of 1

Split input file into multiple files using USER EXIT ROUTINE

PostPosted: Tue Nov 08, 2011 7:41 pm
by vikasgarg85
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..

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

PostPosted: Tue Nov 08, 2011 8:28 pm
by BillyBoyo
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.

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

PostPosted: Wed Nov 09, 2011 12:08 am
by Frank Yaeger
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)

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

PostPosted: Sun Nov 13, 2011 9:04 am
by vikasgarg85
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...

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

PostPosted: Sun Nov 13, 2011 1:52 pm
by BillyBoyo
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.

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

PostPosted: Tue Nov 15, 2011 12:39 am
by Frank Yaeger
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.