Home      Mainframe Forum      Mainfarme Tutorials      IBM Manuals      Mainframe Interview Questions      Mainframe Books      IT News     SiteMap     Downloads


     
 
MAINFRAME - TIP OF THE DAY : When you specified V for RECFM parameter, LRECL value is largest record in the file plus 4 bytes. These four bytes contain the actual length of each variable length record in the file

Google
 
Web mainframegurukul.com

How to compare two fields used in dataset and check for dup

 
Post new topic   Reply to topic    mainframegurukul.com Forum Index -> JCL
  View previous topic :: View next topic  
Author Message
balaryan
Member


Joined: 14 Aug 2014
Posts: 7
Location: Chennai

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Thu Aug 14, 2014 9:48 am    Post subject: How to compare two fields used in dataset and check for dup Reply with quote

Hi All,

Good day. I am having an input file whose records are listed below.

811886,831910
811885,831911
811888,831913
811887,831914
811896,811896 -> both same
811895,811895 -> both same
811894,811894 -> both same
811893,811893 -> both same

Is there any way in JCL sort to compare two fields used in the data set and if both matches, we can treat that as duplicate and remove from the file or exclude in new SORTED file.

Kindly advice and need expert opinion on this.[/b]
_________________
B@L@
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.

William Collins
Active Member


Joined: 24 May 2012
Posts: 732

Answer was approved by Question owner.
Useful Post
1 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Thu Aug 14, 2014 11:23 am    Post subject: Reply with quote

Not exactly expert advice, but have you looked at INCLUDE/OMIT COND=?

Last edited by William Collins on Sat Aug 23, 2014 2:13 pm; edited 1 time in total
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Vamsi99
Active Member


Joined: 05 Nov 2008
Posts: 183

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Sat Aug 23, 2014 1:40 pm    Post subject: Sort matching two files - slice or joinkeys Reply with quote

This was discussed multiple times in the forum (Check DFSORT forum).
you may need to use slice or joinkeys.

Sample Requirement
------------------------
If any of the records from the input1 dataset (start pos 14 for 20) match ANY of the records from the input2 dataset (start pos 61 for 20) then I want to output from start pos 1 for 33 from the input1 dataset record and start pos 82 for 80 from the input2 dataset record to an output dataset called 'matched' (a single output record, not two output records).

Any unmatched/unpaired records from the input1 dataset (start pos 14 for 20) need to be output from start pos 1 for 33 from the input1 dataset record to an output dataset called 'nomatch1'

Any unmatched/unpaired records from the input2 dataset (start pos 61 for 20) need to be output from start pos 82 for 80 from the input2 dataset record to an output dataset called 'nomatch2'


Code:

//S1  EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//IN1 DD DSN=...  input file1 (FB/266)
//IN2 DD DSN=...  input file2 (FB/266)
//MATCHED DD DSN=...  output file1 (FB/266)
//NOMATCH1 DD DSN=...  output file2 (FB/266)
//NOMATCH2 DD DSN=...  output file3 (FB/266)
//SYSIN    DD    *
  JOINKEYS F1=IN1,FIELDS=(14,20,A)
  JOINKEYS F2=IN2,FIELDS=(61,20,A)
  JOIN UNPAIRED,F1,F2
  REFORMAT FIELDS=(F1:1,33,F2:82,80,?)
  OPTION COPY
  OUTFIL FNAMES=MATCHED,INCLUDE=(114,1,CH,EQ,C'B'),
    BUILD=(1,114,266:X)
  OUTFIL FNAMES=NOMATCH1,INCLUDE=(114,1,CH,EQ,C'1'),
    BUILD=(1,33,266:X)
  OUTFIL FNAMES=NOMATCH2,INCLUDE=(114,1,CH,EQ,C'2'),
    BUILD=(34,80,266:X)
/*





other discussion topics in this forum....

http://www.mainframegurukul.com/ibmmainframeforums/Join-on-keys-and-replace-when-matched-post6020.html


Regards,
Vamsi

p.s --> if you like my answer , please vote for my post.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
William Collins
Active Member


Joined: 24 May 2012
Posts: 732

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Sat Aug 23, 2014 2:29 pm    Post subject: Reply with quote

I think you've misunderstood the question (or I have). There is only one file involved, with two different fields which may contain the same value.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Vamsi99
Active Member


Joined: 05 Nov 2008
Posts: 183

Answer was approved by Question owner.
Useful Post
1 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Sat Aug 23, 2014 2:50 pm    Post subject: INCLUDE OMIT COND Reply with quote

Thanks William. It was my bad.

INCLUDE/OMIT COND might be the right way to go.

Still, he can use above solution (provided in my post) by providing same file as input file1 and input file2.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
William Collins
Active Member


Joined: 24 May 2012
Posts: 732

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Sat Aug 23, 2014 3:46 pm    Post subject: Reply with quote

Yes, but it would use many more resources, so should be avoided for this example.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Gouti
Member


Joined: 15 Nov 2016
Posts: 1

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Tue Nov 15, 2016 8:15 am    Post subject: Reply with quote

Hi balaryan , Though the post is too old as 4years Razz thought of replying for others who seek the same answer,, Wink I hope below logic can work for you Smile

//SYSIN DD *
OPTION COPY
INCLUDE COND=(1,6,CH,NE,8,6,CH)
/*
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Display posts from previous:   
Post new topic   Reply to topic    mainframegurukul.com Forum Index -> JCL All times are GMT + 5 Hours
Page 1 of 1



 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Cobol Tutorial
This cobol tutorial covers most of the important topics like STRING, UNSTRING, COMP, COMP-3.....
DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. Explains in simple language. Some Chapters are locked, Forum members have free access to these chapters
CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming...
JCL Tutorial
This is most popular JCL tutorial from mainframegurukul. It does contain important jcl ....
SORT Tutorial
This Tutorial covers all important aspects of DFSORT. Has more SORT examples
INTERVIEW Questions
This page covers important interview questions
Mainframe Jobs
Mainframe Jobs posted by members of mainframegurukul forum
FaceBook Page
MainframeGurukul FaceBook Page
LinkedIn Page
MainframeGurkul Linkedin Page

This widget requires Flash Player 9 or better







Go to top of the page
 

Online ABEND Reference ||  JCL References ||  COBOL References ||  VSAM References ||  Tutorials by Drona Series ||  SQL tutorial ||  BOOKS  ||  DB2 INTERVIEW QUESTIONS ||  COBOL INTERVIEW QUESTIONS  ||  JCL INTERVIEW QUESTIONS ||  JCL2 INTERVIEW QUESTIONS ||  VSAM INTERVIEW QUESTIONS ||  CICS INTERVIEW QUESTIONS  ||  Online tutorials ||  Online ABEND Reference ||  JCL References ||  COBOL References ||  VSAM References ||  Tutorials by Drona Series ||  SQL tutorial ||  BOOKS  ||  SiteMap  ||  Expeditor Tutorial  ||  FILE-AID Tutorial  ||  Changeman Tutorial  ||  COBOL   ||  DB2   ||  JCL  ||  CICS  ||  VSAM  ||  DB2 Interview Questions ( 110 )   || Simple JCL Tutorials  || JCL Tutorial from MainframeGurukul.com   || Simple JCL Tutorial - Chapter1 ;|| Mainframe Forum - Tutorials  || Mainframe Tutorials || Mainframe CICS tutorial|| Mainframe COBOL Tutorial

Drona Educational Forums - Mainframe Cobol DB2 CICS Board
Powered by phpBB

mainframetopic-7695.html