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

comparing and appending the last byte of a file using sort


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

New User


Joined: 31 Jan 2006
Posts: 8
Location: Chennai

PostPosted: Thu Dec 28, 2006 8:31 pm
Reply with quote

I have two PS files A and B.
Both are of the same length, say 80.

I want to compare A recs with that of B and write them to
two different ouput files C and D of length 81.

C will contain the records from A
which has matched with B, the last byte should be appended with M( Matched)

D will contain the records from A
which has not matched with B, the last byte should be appended with N( not matched).

Please let me know a solution using sort utility.

Thanks
Hema
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Thu Dec 28, 2006 9:46 pm
Reply with quote

HI Hema,

Code:
//STEP0100 EXEC PGM=ICETOOL                               
//*                                                       
//TOOLMSG  DD SYSOUT=*                                   
//DFSMSG   DD SYSOUT=*                                   
//IN1      DD *                                           
AAA123BBBBBB                                             
AAA222BBBBBB                                             
AAA333CCCCCCC                                             
/*                                                       
//IN2      DD *                                           
AAA111BBBBBB                                             
AAA222BBBBBB                                             
AAA333CCCCCCC                                             
/*                                                       
//T1        DD DSN=&T1,SPACE=(CYL,(5,5),RLSE),DISP=(MOD,PASS)
//FILEA     DD SYSOUT=*                                   
//OUT       DD SYSOUT=*                                   
//TOOLIN    DD   *                                         
  COPY FROM(IN1) USING(CTL1)                               
  COPY FROM(IN2) USING(CTL2)                               
  SORT FROM(T1) USING(CTL3)                               
/*                                                         
//CTL1CNTL  DD *                                           
  OUTFIL FNAMES=T1,OUTREC=(1,80,C'1')                     
/*                                                         
//CTL2CNTL  DD   *                                         
  OUTFIL FNAMES=T1,OUTREC=(1,80,C'2')                     
/*                                                         
//CTL3CNTL  DD   *                                           
  OPTION EQUALS                                               
  SORT FIELDS=(1,13,CH,A)                                     
  SUM FIELDS=(81,1,ZD)                                       
  OUTFIL FNAMES=OUT,INCLUDE=(81,1,ZD,EQ,3),OUTREC=(1,80,C'M')     
  OUTFIL FNAMES=FILEA,INCLUDE=(81,1,CH,EQ,C'1'),OUTREC=(1,80,C'N')
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 Dec 28, 2006 11:18 pm
Reply with quote

Hema,

Do you want to compare the records on all 80 bytes, or on a particular field?

Can there be duplicate records with fileA? Can there be duplicate records within fileB?

Please show an example of the records in the input files (including duplicates within each file if appropriate) and the expected output records.
Back to top
View user's profile Send private message
madhavihmk

New User


Joined: 31 Jan 2006
Posts: 8
Location: Chennai

PostPosted: Fri Dec 29, 2006 8:24 am
Reply with quote

Hi Frank,

File A and File B will contain mostly the same records.

File A will be a input file and File B is an unload from a database table.
So i will be doing a comapre on the whole record, 80 bytes and there will no duplicates.

Format for the files

ModelNoVersionNo.

Eg File- A
Model1Version1
Model2Version2
Model3Version3
Model4Version4

Eg File-B
Model1Version1
Model2Version1
Model3Version2
Model4Version4


Output
File-C
Model1Version1M
Model4Version4M

File-D
Model2Version2N
Model3Version3N

This is my expected output.

Thanks
Hema
Back to top
View user's profile Send private message
madhavihmk

New User


Joined: 31 Jan 2006
Posts: 8
Location: Chennai

PostPosted: Fri Dec 29, 2006 9:04 am
Reply with quote

Thanks Ekta , the got the output .
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 Dec 29, 2006 8:36 pm
Reply with quote

Hema,

Here's another way to do what you asked for with DFSORT/ICETOOL. I assumed your input has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.

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) - matched
//OUT2 DD DSN=...  output file2 (FB/80) - unmatched
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SELECT FROM(T1) TO(OUT1) ON(1,80,CH) ALLDUPS DISCARD(OUT2) -
  USING(CTL3)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(81:C'1')
/*
//CTL2CNTL DD *
  INREC OVERLAY=(81:C'2')
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=OUT1,INCLUDE=(81,1,CH,EQ,C'1'),
    OVERLAY=(81:C'M')
  OUTFIL FNAMES=OUT2,INCLUDE=(81,1,CH,EQ,C'1'),
    OVERLAY=(81:C'N')
/*
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
Search our Forums:

Back to Top