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

compare records with in a file


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

New User


Joined: 26 Oct 2006
Posts: 50
Location: Chennai

PostPosted: Thu Dec 07, 2006 8:26 pm
Reply with quote

Hi ,

Could any one help me to achieve the following requirement thru SORT?

I have a flat file (Recfm=FB,LrecL=80) with the following data.

1001010
1002010
1002999

1004333
1004666
1005010
1005999

1023754

The output file should have the following data

1002010
1002999
1005010
1005999

i.e, If the first 4 bytes (Ex:1002) is having the same value with its next record (The 5 to 7th byte should have ?010? and ?999? for these 2 same records) then I need to extract these records into the output file.

Bharathiraj
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 07, 2006 11:03 pm
Reply with quote

Assuming you won't have duplicate records which both have '010' or both have '999', you can use this DFSORT job to do what you asked for:

Code:

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=...  input file
//OUT DD DSN=...  output file
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(1,4,CH) ALLDUPS USING(CTL1)
/*
//CTL1CNTL DD *
  INCLUDE COND=(5,3,SS,EQ,C'010,999')
/*
Back to top
View user's profile Send private message
bbharathiraj
Warnings : 1

New User


Joined: 26 Oct 2006
Posts: 50
Location: Chennai

PostPosted: Fri Dec 08, 2006 1:22 pm
Reply with quote

Thanks Frank. Am I right If I consider the operator ?SS? as ?String Search? ?
I have one more question here.

Lets have a input file (Recfm=FB,Lrecl=80) and the input file having the following records.

1002010
1002999
1002010

1004333
1004666
1005010
1005999
1005010

1023754
1007010
1007999



And I have to create the below output file.

1002999
1002010
1005999
1005010


(i.e) If the input records having the duplicate records on position 1 to 4, then I need to extract only the 2 records (same value on 1 to 4th byte) were the second record should have the value ?010? in 5 to 7th byte and it should be followed by ?999? on its previous record.
For example, in the given input file the first 3 records having the same value on first 4 bytes. But I need to extract only the second and third record since the third record having the value ?010? on position 5 to 7 and also it?s followed by ?999?.

Note: Red one should be eliminated.
Shall we do this kind of compare in DFSORT? If so, could you help me out?
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: Sat Dec 09, 2006 3:45 am
Reply with quote

Yes, SS is substring search.

Your new requirement is rather tricky, but I believe this DFSORT/ICETOOL job will work:

Code:

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//CON DD DSN=*.T2,VOL=REF=*.T2,DISP=(OLD,PASS)
//    DD DSN=*.T1,VOL=REF=*.T1,DISP=(OLD,PASS)
//OUT DD DSN=...     output file (FB/80)
//TOOLIN DD *
COPY FROM(IN) USING(CTL1)
SPLICE FROM(T1) TO(T2) ON(1,4,CH) ON(84,8,ZD) -
  WITHEACH WITH(81,3) USING(CTL2)
SPLICE FROM(CON) TO(OUT) ON(1,4,CH) ON(84,8,ZD) -
  WITHALL WITH(1,80) WITH(108,1) USING(CTL3)
/*
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:5,3,84:SEQNUM,8,ZD,
         100:SEQNUM,8,ZD,RESTART=(5,3),108:C'VV')),
        IFTHEN=(WHEN=(5,3,CH,EQ,C'999'),
                OVERLAY=(84:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=NONE,
                OVERLAY=(92:SEQNUM,8,ZD,
                         84:84,8,ZD,SUB,92,8,ZD,M11,LENGTH=8))
  OUTFIL FNAMES=T1,OMIT=(5,3,CH,EQ,C'010',AND,100,8,ZD,GT,+1)
/*
//CTL2CNTL DD *
  OUTFIL FNAMES=T2,
    INCLUDE=(5,3,CH,EQ,C'999',AND,81,3,CH,EQ,C'010'),
    OVERLAY=(108:C'BB')
/*
//CTL3CNTL DD *
  INCLUDE COND=(5,3,SS,EQ,C'999,010')
  OUTFIL FNAMES=OUT,INCLUDE=(108,2,CH,EQ,C'VB'),
    BUILD=(1,80)
/*


For a thorough test, I used this input data:

Code:

1002010 R01   
1002999 R02   
1002010 R03   
1003999 R04   
1003999 R05   
1003010 R06   
1004333 R07   
1004666 R08   
1005010 R09   
1005999 R10   
1005010 R11   
1023754 R12   
1007010 R13   
1007999 R14   
1008010 R15   
1008010 R16   
1009999 R17   
1010999 R18   
1010010 R19   
1010010 R20   
1010010 R21   
1012999 R22   
1012555 R23   
1012010 R24   


and the job produced this output data:

Code:

1002999 R02   
1002010 R03   
1003999 R05   
1003010 R06   
1005999 R10   
1005010 R11   
1010999 R18   
1010010 R19   
Back to top
View user's profile Send private message
bbharathiraj
Warnings : 1

New User


Joined: 26 Oct 2006
Posts: 50
Location: Chennai

PostPosted: Mon Dec 11, 2006 3:50 pm
Reply with quote

Thanks Frank. You have given a wondeful solution. Thanks a lot
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 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top