IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Sorting two files and writing in to three output files


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
raak

Active User


Joined: 23 May 2006
Posts: 166
Location: chennai

PostPosted: Fri Mar 30, 2007 11:52 am
Reply with quote

Hi,

I have a requirement in which I have 2 files, let's say FileA and FileB.

Consider it like this.

FileA
key01 100
key02 200
key03 300


FileB
key01 100
key02 250
key04 400

Both the Input files will be in the sorted order of their Key(First 5 bytes).
Input files are of LRECL 80.

I want
1) The records in FileA and FileB which has same key and different amounts in one file.
2) The records which are there in only fileA(Based on key) in second output file.
3) The records which are there only in FileB(Based on key) in third output file.

All those records which has same key and amount in both the files should not come in any of these output files.
So in the above shown example, my output should be

OUTPUT1
Key02 200 (amount value taken from 1st file)

OUTPUT2
key03 300

OUTPUT3
key04 400

And since the record 'key01 100' is coming in both files, it should be skipped.

I searched for some similar requirement in the earlier posts, but coulnot lay my hands on any.. icon_sad.gif
Back to top
View user's profile Send private message
muthuvel

Active User


Joined: 29 Nov 2005
Posts: 217
Location: Canada

PostPosted: Fri Mar 30, 2007 12:25 pm
Reply with quote

Is it a must that the three files should be produced only by sort?If it is easytrieve or COBOL i believe things will be simple . icon_neutral.gif
Back to top
View user's profile Send private message
raak

Active User


Joined: 23 May 2006
Posts: 166
Location: chennai

PostPosted: Fri Mar 30, 2007 1:33 pm
Reply with quote

hey

I want it using Sort only. Using Cobol i can code a program, but my concern is if the input file contains millions of records, then it might cause perfomance degradation for Cobol.
I think Sort will be faster in that case.. ( I THINK icon_smile.gif )

anyway i need a sort step to do this part if possible..


any help ???????
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Fri Mar 30, 2007 1:36 pm
Reply with quote

Which sort product are you using ?

I have done some things remotely similar using DFSORT.
Back to top
View user's profile Send private message
raak

Active User


Joined: 23 May 2006
Posts: 166
Location: chennai

PostPosted: Fri Mar 30, 2007 1:41 pm
Reply with quote

Can u explain on that Expat... am using DFSORT ...
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Fri Mar 30, 2007 1:50 pm
Reply with quote

Hi Raak,

here's the url for the ICETOOL utility, and I will try and find an example of the code that will help you. No doubt Frank will give you something far more efficient than mine, but if it help .........

http://www-304.ibm.com/jct01004c/systems/support/storage/software/sort/mvs/icetool/index.html
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Fri Mar 30, 2007 2:03 pm
Reply with quote

Code:

//ICETOOL6 EXEC PGM=ICETOOL                                             
//TOOLMSG  DD SYSOUT=*                                                 
//DFSMSG   DD SYSOUT=*                                                 
//INFILE   DD DSN=&&SORTOUT,DISP=SHR                                   
//         DD DSN=&&MFXSSORT,DISP=SHR                                   
//         DD DSN=&&B41SSORT,DISP=SHR                                   
//OUTFILE  DD DSN=&&MERGE2X,DISP=(,PASS),                               
//            SPACE=(CYL,(100,25),RLSE)                                 
//MERGED   DD DSN=&&MERGED,                                             
//            DISP=(,CATLG,DELETE),                                     
//            SPACE=(CYL,(100,25),RLSE)                                 
//TOOLIN   DD *                                                         
*** SELECT ONLY RECORDS WITH NON MATCHING KEYS
*** THEN COPY TO INCLUDE ONLY D AND M RECORD TYPES
                                                         
  SELECT FROM(INFILE)    TO(OUTFILE)     -                             
    ON(5,44,CH)  ON(51,8,CH)  NODUPS                                   
                                                                       
  COPY FROM(OUTFILE) TO(MERGED) USING(COPY)               
/*                                                         
//COPYCNTL DD *                                           
  OPTION VLSCMP                                           
  INCLUDE COND=(64,1,CH,EQ,C'D',OR,64,1,CH,EQ,C'M')       
/*                                                         


The SELECT compares the two fields that I have specified and if they are not matched then the NODUPS statement will keep them.

The COPY after the SELECT is only used to further cut down on records that I do not require.

If you look at the JCL I am actually reading three files but only producing one, but ICETOOL is such a versatile tool which will allow you to do what you want.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Fri Mar 30, 2007 2:13 pm
Reply with quote

Sorry, I forgot to add that you can create all three output files in one job step.

I have the luxury of having specific record types to work with to make record selection easier, but if you have nothing like that in your files you may have to reformat them with "A" in a specific column for FILEA, "B" for records from FILEB, etc. etc.

I'm not the greatest user of ICETOOL and it is really great for things like this, and I'm sure that Frank will far more helpful with this utility than I ever can.

Good luck.
Back to top
View user's profile Send private message
raak

Active User


Joined: 23 May 2006
Posts: 166
Location: chennai

PostPosted: Fri Mar 30, 2007 3:12 pm
Reply with quote

Hi

Expat, thanks for ur immediate responses.....

let me ask u a doubt.

Using the code given above, the first SELECT will eliminate ALL the duplicate records from the input files.

using the COPY i can then split this file into two based on their presence in 1st file or 2nd file.
My question is, how can i identify a key which is present in both the files but with different amounts.. ( like the KEY02 in my example)
I want to write such records in to another file..
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Fri Mar 30, 2007 3:38 pm
Reply with quote

Yes, I think that the code will remove all of the duplicates which will give you your OUTPUT 1.

If there is no way of telling from which file the records have come from, you may have to reformat the records before processing them.

Some thing silly like F1 in columns 1+2 for file 1 records and F2 for file 2 records. And after you have processed them to reformat by removing the F1 & F2 inserts.

I sort of get the feeling I'm confusing you more than helping here icon_confused.gif
Back to top
View user's profile Send private message
Alain Benveniste

New User


Joined: 14 Feb 2005
Posts: 88

PostPosted: Fri Mar 30, 2007 4:25 pm
Reply with quote

raak,

Do you have duplicates in file 1 & 2 ?

Alain
Back to top
View user's profile Send private message
GlobalGyan

New User


Joined: 31 Jan 2006
Posts: 28

PostPosted: Fri Mar 30, 2007 6:05 pm
Reply with quote

I did something like this some time back...

I dont have the ICETOOL CNTL ... but then I coded a COBOL program for this, the code executed 50% faster than SORT ... maybe that time I did not ask Frank ;-).
Back to top
View user's profile Send private message
raak

Active User


Joined: 23 May 2006
Posts: 166
Location: chennai

PostPosted: Fri Mar 30, 2007 8:46 pm
Reply with quote

Hi Alain,

I don't have any duplicates in my file 1 or 2..


Any updates???
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Mar 30, 2007 9:39 pm
Reply with quote

Raak,

Here's a DFSORT/ICETOOL job that will do what you asked for. I assumed your amount field was 3 digits in positions 7-9. - if that's not the case, then the job can be changed appropriately.

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN1 DD DSN=...  input file1 (FB/80)
//IN2 DD DSN=...  input file2 (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT1 DD DSN=...  output file1 (FB/80)
//OUT2 DD DSN=...  output file2 (FB/80)
//OUT3 DD DSN=...  output file3 (FB/80)
//TOOLIN   DD    *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT1) ON(1,5,CH) KEEPNODUPS -
  WITH(81,80) USING(CTL3)
/*
//CTL1CNTL DD *
  INREC BUILD=(1,80,160:X)
/*
//CTL2CNTL DD *
  INREC BUILD=(1,5,81:1,80)
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=OUT1,
    INCLUDE=(7,3,CH,NE,C' ',AND,87,3,CH,NE,C' ',
      AND,7,3,CH,NE,87,3,CH),
    BUILD=(1,80)
  OUTFIL FNAMES=OUT2,
    INCLUDE=(87,3,CH,EQ,C' '),
    BUILD=(1,80)
  OUTFIL FNAMES=OUT3,
    INCLUDE=(7,3,CH,EQ,C' '),
    BUILD=(81,80)
/*
Back to top
View user's profile Send private message
Rahulbhutkar

New User


Joined: 30 Mar 2007
Posts: 1
Location: mumbai

PostPosted: Thu Apr 05, 2007 12:46 pm
Reply with quote

Hi Frank,

I am very new to mainframe & learning sort. If u could explain me splice and control card 1 & 2 it would be gr8 on my side.

Thanks,
Rahul
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Apr 05, 2007 8:24 pm
Reply with quote

Rahul,

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

Use [URL] BBCode for External Links

For complete details on all of the DFSORT and ICETOOL control statements, see "z/OS DFSORT Application Programming Guide".

For explanations of the various tricks you can do with DFSORT, see:

www.ibm.com/servers/storage/support/software/sort/mvs/tricks/
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 2
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
Search our Forums:

Back to Top