Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Compare and Outrec with sort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Hima1985

New User


Joined: 17 Apr 2009
Posts: 70
Location: India

PostPosted: Thu Jul 16, 2009 5:31 pm    Post subject: Compare and Outrec with sort
Reply with quote

Hi Frank/skolusu

Can you please tell me how can i achieve this

Both files are 80 lenth FB, Key position is 12 to 10 bytes

File A:
123456789X 1234567890
123456789Y 1234567891
123456789Z 1234567892

File B:
123456789A 1234567890
123456789B 1234567891
123456789C 1234567892

output shoud be

123456789X 1234567890 123456789A
123456789Y 1234567891 123456789B
123456789Z 1234567892 123456789C


can you please tell me if i can achieve this with sort.
Back to top
View user's profile Send private message

cpuhawg

Active User


Joined: 14 Jun 2006
Posts: 331
Location: Jacksonville, FL

PostPosted: Thu Jul 16, 2009 5:56 pm    Post subject: Reply to: compare and outrec
Reply with quote

Here is one solution.


Code:

//ICETOOL  EXEC PGM=ICETOOL               
//TOOLMSG  DD  SYSOUT=*                                 
//DFSMSG   DD  SYSOUT=*                                 
//DFSPARM  DD  *                                         
  OPTION EQUALS                                         
//TOOLIN   DD  *                                         
SORT FROM(FILEA) TO(TEMP1) USING(CTL1)                   
SORT FROM(FILEB) TO(TEMP1) USING(CTL2)                   
SPLICE FROM(TEMP1) TO(OUTFILE) ON(12,10,CH) WITH(23,10) 
//SYSOUT   DD  SYSOUT=*                                 
//SYSUDUMP DD  SYSOUT=*                                 
//FILEA    DD  *                                         
123456789X 1234567890                                   
123456789Y 1234567891                                   
123456789Z 1234567892                                   
//FILEB    DD  *                                         
123456789A 1234567890                                   
123456789B 1234567891                                   
123456789C 1234567892                                             
//TEMP1    DD  DSN=&&TEMP1,UNIT=SYSDA,DISP=(MOD,PASS),             
//             SPACE=(TRK,(15,5),RLSE),                           
//             RECFM=FB,LRECL=80,BLKSIZE=27920                     
//OUTFILE  DD  DSN=HLQ.OUTPUT.FILE,                               
//             SPACE=(TRK,(15,5),RLSE),UNIT=SYSDA,DISP=(NEW,CATLG),
//             RECFM=FB,LRECL=80,BLKSIZE=27920                     
//CTL1CNTL DD  *                                                   
 SORT FIELDS=COPY                                                 
 OUTFIL FNAMES=TEMP1,OUTREC=(1:1,80)                               
/*                                                                 
//CTL2CNTL DD  *                                                   
 SORT FIELDS=COPY                                                 
 OUTFIL FNAMES=TEMP1,OUTREC=(1:11C' ',12:12,11,23:1,10,33:48C' ') 
/*                                                                 
Back to top
View user's profile Send private message
Hima1985

New User


Joined: 17 Apr 2009
Posts: 70
Location: India

PostPosted: Thu Jul 16, 2009 6:39 pm    Post subject:
Reply with quote

cpuhawg,

Sorry, My fileB key position is 15 and fileA key position is 12, these needs to be compared

File A:
Code:
123456789X 1234567890
123456789Y 1234567891
123456789Z 1234567892


File B:
Code:
123456789AAAA 1234567890
123456789BBBB 1234567891
123456789CCCC 1234567892


output shoud be

Code:
123456789X 1234567890 123456789AAAA
123456789Y 1234567891 123456789BBBB
123456789Z 1234567892 123456789CCCC
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Jul 16, 2009 9:11 pm    Post subject: Reply to: compare and outrec
Reply with quote

Hima1985,

Wouldn't it be courteous to post the right information in your first post itself? You change the requirements so often and in that process you are just wasting your time as well as the posters who try to help you.

The following DFSORT JCL will give you the desired results. Since both files are of same LRECL and 80 bytes in length. we concatenate a single record "hdr" before each file so that the group function can use that record as an identifier as to which file the record belongs


Code:

//STEP0100 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                       
HDR                                                                   
//         DD DSN=Your file with key at pos 15,DISP=SHR
//         DD *                                                       
HDR                                                                   
//         DD DSN=Your file with key at pos 12,DISP=SHR
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *           
  OPTION EQUALS                                           
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'),PUSH=(81:ID=1)),   
  IFTHEN=(WHEN=(81,1,ZD,EQ,1),OVERLAY=(82:15,10)),                     
  IFTHEN=(WHEN=(81,1,ZD,EQ,2),OVERLAY=(82:12,10))                     
  SORT FIELDS=(82,10,CH,A)                                             
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(82:X,SEQNUM,8,ZD,RESTART=(82,10))),
  IFTHEN=(WHEN=GROUP,BEGIN=(83,8,ZD,EQ,1),PUSH=(23:1,14,82:81,1))     
  OUTFIL INCLUDE=(81,2,ZD,EQ,21,AND,1,3,CH,NE,C'HDR'),BUILD=(1,35)     
/*
Back to top
View user's profile Send private message
Hima1985

New User


Joined: 17 Apr 2009
Posts: 70
Location: India

PostPosted: Fri Jul 17, 2009 3:20 pm    Post subject:
Reply with quote

Skolusu,

Sorry about that, and thanks for the solution.

Is there any limitation of the records? I have 1000 records in each file when i stirp out 10 bytes from 12th pos in fist file and generate a file, and 10 bytes from 15th postion from second file and generate a file, then compare them i am seeing 960 matchings....but when i use this job i am seeing only 460 matchings...what could be the reason? can you please explain me below ones....that may clear my problem...

Code:

INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'),PUSH=(81:ID=1)),   
  IFTHEN=(WHEN=(81,1,ZD,EQ,1),OVERLAY=(82:15,10)),                     
  IFTHEN=(WHEN=(81,1,ZD,EQ,2),OVERLAY=(82:12,10))                     
  SORT FIELDS=(82,10,CH,A)                                             
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(82:X,SEQNUM,8,ZD,RESTART=(82,10))),
  IFTHEN=(WHEN=GROUP,BEGIN=(83,8,ZD,EQ,1),PUSH=(23:1,14,82:81,1))     
  OUTFIL INCLUDE=(81,2,ZD,EQ,21,AND,1,3,CH,NE,C'HDR'),BUILD=(1,35) 
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Jul 17, 2009 9:53 pm    Post subject: Reply to: compare and outrec
Reply with quote

Hima,

The volume of records does NOT matter. If you had copied the job AS IS you wouldn't have any problem. Pay attention to how I am concatenating the datasets. If you say it is NOT working then you need to show me the sysout messages. Please don't give me excuses that you can't copy the sysout. I cant read your mind or see your input or sysout.

Anyway I am explaining the control cards now. Don't expect me to do this with every job.

HDR followed by file with key at pos 15 and again HDR followed by file with key at pos 12.

Code:

INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'),PUSH=(81:ID=1)), 


This will put a 1 byte identifier at position 81 based on the HDR val

This is how the input will look like after the execuetion of the statement

Code:

 RECORD (1-80)            | 81
------------------------------
HDR                       |  1
FILE WITH KEY AT POS 15   |  1
.....ALL POS 15 KEY RECS  |  1
HDR                       |  2
FILE WITH KEY AT POS 12   |  2
.....ALL POS 12 KEY RECS  |  2


The next 2 ifthen statements are checking that identifier and copying the key on to pos 82 either from pos 15 or pos 12

Code:

  IFTHEN=(WHEN=(81,1,ZD,EQ,1),OVERLAY=(82:15,10)), 
  IFTHEN=(WHEN=(81,1,ZD,EQ,2),OVERLAY=(82:12,10))   


The input will look like this after these statements

Code:

 RECORD (1-80)            | 81|82-91         
-------------------------------------------- 
HDR                       |  1|               
123456789AAAA 1234567890  |  1|1234567890     
123456789BBBB 1234567891  |  1|1234567891     
123456789CCCC 1234567892  |  1|1234567892     
.....ALL POS 15 KEY RECS  |  1|KEY FROM 15   
HDR                       |  2|               
123456789X 1234567890     |  2|1234567890     
123456789Y 1234567891     |  2|1234567891     
123456789Z 1234567892     |  2|1234567892     
.....ALL POS 12 KEY RECS  |  2|KEY FROM 12   


Now we have the key in common position , so we sort on it with equals option so as to retain the order of the duplicate records

Code:

SORT FIELDS=(82,10,CH,A)


After the sort is completed you have equal key records from both files together.
Code:

 RECORD (1-80)            | 81|82-91       
--------------------------------------------
HDR                       |  1|             
HDR                       |  2|             
123456789AAAA 1234567890  |  1|1234567890   
123456789X 1234567890     |  2|1234567890   
123456789BBBB 1234567891  |  1|1234567891   
123456789Y 1234567891     |  2|1234567891   
123456789CCCC 1234567892  |  1|1234567892   
123456789Z 1234567892     |  2|1234567892   
.....ALL POS 15 KEY RECS  |  1|KEY FROM 15 
.....ALL POS 12 KEY RECS  |  2|KEY FROM 12 



Now using an OUTREC OUTREC IFTHEN=(WHEN=INIT puts a space and a restart sequence number at pos 82 looking at the input keys which we sorted.

Code:

OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(82:X,SEQNUM,8,ZD,RESTART=(82,10))),


After this statement the output will be as follows

Code:

 RECORD (1-80)            | 81|82|83-90     
--------------------------------------------
HDR                       |  1|  |000000001
HDR                       |  2|  |000000002
123456789AAAA 1234567890  |  1|  |000000001
123456789X 1234567890     |  2|  |000000002
123456789BBBB 1234567891  |  1|  |000000001
123456789Y 1234567891     |  2|  |000000002
123456789CCCC 1234567892  |  1|  |000000001
123456789Z 1234567892     |  2|  |000000002


Using a ifthen when=group we propagate the pos 23 with the value from pos1 and propagate pos 82 using the seqnum at pos 83. if it is 1 then we push the value at 1 on to pos 23 and pos 81 on to the byte 82
Code:

IFTHEN=(WHEN=GROUP,BEGIN=(83,8,ZD,EQ,1),PUSH=(23:1,14,82:81,1))

this is how it would look like after the above statement


Code:

 RECORD (1-22)        |23-35        | 81|82|83-90     
---------------------------------------------------- 
HDR                                 |  1|1 |000000001
HDR                                 |  2|1 |000000002
123456789AAAA 12345678|123456789AAAA|  1|1 |000000001
123456789X 1234567890 |123456789AAAA|  2|1 |000000002
123456789BBBB 12345678|123456789BBBB|  1|1 |000000001
123456789Y 1234567891 |123456789BBBB|  2|1 |000000002
123456789CCCC 12345678|123456789CCCC|  1|1 |000000001
123456789Z 1234567892 |123456789CCCC|  2|1 |000000002


Now we have all the data we wanted and we just an include statement to get the matching records. All matching records have 21 at pos 81 and we eliminate the 2 records we added and build the first 35 bytes
Code:

OUTFIL INCLUDE=(81,2,ZD,EQ,21,AND,1,3,CH,NE,C'HDR'),BUILD=(1,35)


This is how the final output will look like

Code:

 RECORD (1-22)        |23-35        |
-------------------------------------
123456789X 1234567890 |123456789AAAA|
123456789Y 1234567891 |123456789BBBB|
123456789Z 1234567892 |123456789CCCC|
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 sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts JOINKEYS Paired and Unpaired Sort MFwhiz DFSORT/ICETOOL 4 Fri Sep 29, 2017 1:48 am
No new posts File Aid tool to compare numeric data balaji81_k Compuware & Other Tools 2 Tue Sep 26, 2017 3:35 am
No new posts Compare yesterday's date to the one o... migusd SYNCSORT 11 Fri Sep 22, 2017 11:35 pm
No new posts Difference in SORT & ICETOOL Mohan Kothakota DFSORT/ICETOOL 5 Fri Sep 22, 2017 4:56 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us