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
 

 

compare records with in a file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: compare records with in a file
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 Moderator


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

PostPosted: Thu Dec 07, 2006 11:03 pm    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Sat Dec 09, 2006 3:45 am    Post subject:
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    Post subject:
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    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 SSH - known_hosts file configuration vasanthz All Other Mainframe Topics 2 Wed Jul 26, 2017 2:10 am
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts How to generate a new unique Input fi... for1ranjith CLIST & REXX 11 Sat Jul 01, 2017 12:09 pm


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