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

sorting files using splice


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

New User


Joined: 15 Sep 2008
Posts: 17
Location: Chennai

PostPosted: Thu Jun 04, 2009 6:29 pm
Reply with quote

I need to compare two fields from two different files and write into a third file. The first field should match and the second field should not match. The output file should contain records from file 1 which match the above criteria.

For eg:

Code:

file 1 has,       file 2 has,

100 Merlin      100 Babs
200 Black       200 Black
300 White       300 Yellow


the output file should be,

Code:

100 Merlin
300 White


Bhuvana
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Thu Jun 04, 2009 6:43 pm
Reply with quote

The usual questions ..................

What are the file characteristics for both files. i.e. RECFM & LRECL
What are the locations and lengths of the keys to match between the files.
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 Jun 04, 2009 9:20 pm
Reply with quote

Bhuvana,

Can you have the situation where the first field does not match and the second field does match and if so, would you want that record in the output file? For example, could you have something like this:

File1
400 Green

File2
500 Green

If so, what would you want in the output file?

Can file1 have duplicates on either field or both fields within it?
Can file2 have duplicates on either field or both fields within it?
For example:

100 Green
100 Green
100 Blue
200 Blue

If so, please show a more complete example of input records and expected output covering all possible variations.
Back to top
View user's profile Send private message
Bhuvaneswari K

New User


Joined: 15 Sep 2008
Posts: 17
Location: Chennai

PostPosted: Thu Jun 04, 2009 9:54 pm
Reply with quote

The file has just two of these fields. The first field is of length 5 and numeric and the second field is of length 4 alphanumeric.

No duplicates occurs within the files.

Also the first field in file 1 must have a matching record in file 2 and the second field must not be matching. Only such records are needed in the output file. hope am clear in my explanation.

thanks
Bhuvana
Back to top
View user's profile Send private message
Bhuvaneswari K

New User


Joined: 15 Sep 2008
Posts: 17
Location: Chennai

PostPosted: Thu Jun 04, 2009 9:56 pm
Reply with quote

One additional info..the record format is FD and the file length is 80

Bhuvana
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 Jun 04, 2009 10:21 pm
Reply with quote

Quote:
The first field is of length 5 and numeric and the second field is of length 4 alphanumeric


That doesn't match your example. 100 is not 5 characters and Merlin is not 4 characters. But given your description of your data and assuming your fields really are in 1-5 and 6-9, you can use a DFSORT job like the following to do what you asked for:

Code:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN01 DD *     input file1
  100Merl
  200Blac
  300Whit
  400Gree
/*
//SORTIN02 DD *     input file2
  100Babs
  200Blac
  300Yell
  500Gree
/*
//SORTOUT DD SYSOUT=*   output file
//SYSIN    DD    *
  OPTION EQUALS
  MERGE FIELDS=(1,5,CH,A)
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,1,ZD,RESTART=(1,5))),
    IFTHEN=(WHEN=GROUP,BEGIN=(81,1,ZD,EQ,1),PUSH=(82:6,4))
  OUTFIL INCLUDE=(81,1,ZD,EQ,2,AND,6,4,CH,NE,82,4,CH),
    BUILD=(1,5,6:82,4,80:X)
/*
Back to top
View user's profile Send private message
Bhuvaneswari K

New User


Joined: 15 Sep 2008
Posts: 17
Location: Chennai

PostPosted: Thu Jun 04, 2009 11:09 pm
Reply with quote

This seems fine but please tell me if i can proceed in this way:

File1:
12345 AAAA
56789 BBBB

File2:
12345 CCCC
56789 BBBB

Step1: splicing the two files into a temporary file which will be of this format -
12345 AAAA CCCC
56789 BBBB BBBB

Step2: by comparing the two character values (AAAA CCCC) if they are not equl then writing into the output dataset with the first value ie
12345 AAAA

can you suggest how step 2 can be accomplished?

Regards
Bhuvana
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 Jun 04, 2009 11:22 pm
Reply with quote

What you want to do with SPLICE is similar to what I did with WHEN=GROUP, but you will need more than one pass to do it with SPLICE, whereas you only need one pass to do it with WHEN=GROUP.

Why would you want to use a multipass solution when I gave you a one pass solution?
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Jun 04, 2009 11:45 pm
Reply with quote

Code:
//SORTIN01 DD *     input file2
Should n't that be a SORTIN02?
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 Jun 04, 2009 11:47 pm
Reply with quote

Yes - copy and paste error. Fixed. Thanks. (Guess I'm trying to do too many things at once.)
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Jun 04, 2009 11:59 pm
Reply with quote

You're welcome. icon_smile.gif
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 Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
This topic is locked: you cannot edit posts or make replies. Automation need help in sorting the data DFSORT/ICETOOL 38
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
No new posts Joinkeys - 5 output files DFSORT/ICETOOL 7
Search our Forums:

Back to Top