Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

sorting files using splice

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: sorting files using splice
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: 8593
Location: Back in jolly old England

PostPosted: Thu Jun 04, 2009 6:43 pm    Post subject:
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 Moderator


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

PostPosted: Thu Jun 04, 2009 9:20 pm    Post subject:
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    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Thu Jun 04, 2009 10:21 pm    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Thu Jun 04, 2009 11:22 pm    Post subject:
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: 2239
Location: @my desk

PostPosted: Thu Jun 04, 2009 11:45 pm    Post subject:
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 Moderator


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

PostPosted: Thu Jun 04, 2009 11:47 pm    Post subject:
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: 2239
Location: @my desk

PostPosted: Thu Jun 04, 2009 11:59 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Append data from two files into a sin... Praveen04 DFSORT/ICETOOL 5 Thu Mar 16, 2017 7:29 pm
No new posts Sorting group data rajella DFSORT/ICETOOL 4 Sun Jan 22, 2017 11:32 pm
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 15 Thu Dec 01, 2016 8:28 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts Efficient sorting chandracdac DFSORT/ICETOOL 5 Sat Oct 22, 2016 3:23 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us