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

JOINKEYS to match two input files on the basis of different


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

New User


Joined: 20 Sep 2006
Posts: 63
Location: pune

PostPosted: Fri Nov 27, 2020 12:38 pm
Reply with quote

Hi All,

Good Afternoon !

I am using DFSORT tool to compare two input files.
I want to match records using different conditions and output should be written in three output files.

I used three different steps to get results but I think it is not wise solution. I am not looking for matching records but interested in non matching records.

NOTE: Records should be compared on
RECORD-TYP1 PIC X(04) Starting position is 01. (1111, 2222, 3333, 4444, 5555 and so on)


Code:
//SORTJNF1 DD *            (Data is not in sorted order and contains duplicate records for both FILE1 and FILE2)
3333 ROUTE PUNE TO MUMBAI 
4444 EMPLOYEE STRENGTH IS 200
1111 21100 SANDIP
1111 33000 AKASH
2222 PUNE    FINANCE
2222 MUMBAI  FINANCE
2222 KOLKATA SALES

       
//SORTJNF1 DD *
2222 CHENNAI FINANCE
2222 NAGPUR  PRODUCTION
1111 21000 SANDIP
1111 22000 MAHESH
3333 ROUTE HYDERBAD TO SHIMLA
3333 ROUTE PUNE TO MUMBAI 
5555 SOME RANDOM DATA 
4444 EMPLOYEE STRENGTH IS 200
//SYSIN DD *
   JOINKEYS FILE=F1,FIELDS=(06,05,A) IF RECORD-TYPE='1111'
                                           (14,10,A) IF RECORD-TYPE='2222'
                                           (01,80,A) IF RECORD-TYPE NOT = ('1111' OR '2222')
   JOINKEYS FILE=F2,FIELDS=(06,05,A) IF RECORD-TYPE='1111'
                                           (12,10,A) IF RECORD-TYPE='2222'
                                           (01,80,A) IF RECORD-TYPE NOT = ('1111' OR '2222')

(I am not sure how to give above three different condition is JNF1CNTL and JNF2CNTL, I just know to provide one condition like INCLUDE COND=(01,04,CH,EQ,C'1111') )

Code:
   JOIN UNPAIRED,F1,F2
   REFORMAT FIELDS=(F1:01,80,F2:01,80,?)

   SORT FIELDS=COPY
   OUTFIL FNAMES=MATCH,
   INCLUDE COND=(161,001,CH,EQ,C'B'),
   BUILD=(01,80)

   OUTFIL FNAMES=NOMCH1,
   INCLUDE COND=(161,001,CH,EQ,C'1'),
   BUILD=(01,80)

   OUTFIL FNAMES=NOMCH2,
   INCLUDE COND=(161,001,CH,EQ,C'2'),
   BUILD=(01,80)
//*

FILE1 LRECL=80,RECFM=FB
FILE2 LRECL=80,RECFM=FB
MATCH LRECL=80,RECFM=FB (Matching Records)
NOMCH1 LRECL=80,RECFM=FB (Non Matching records from FILE1)
NOMCH2 LRECL=80,RECFM=FB (Non Matching records from FILE2)

OUTPUT Should look as below:
Code:
MATCH:
1111 21100 SANDIP
2222 PUNE    FINANCE
2222 MUMBAI  FINANCE
4444 EMPLOYEE STRENGTH IS 200

NOMCH1:
1111 33000 AKASH
2222 KOLKATA SALES

NOMCH2:
2222 NAGPUR  PRODUCTION
1111 22000 MAHESH
3333 ROUTE HYDERBAD TO SHIMLA
5555 SOME RANDOM DATA   



Thanks & Regards,
Sandip Walsinge
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2567
Location: NYC,USA

PostPosted: Fri Nov 27, 2020 8:17 pm
Reply with quote

This should work.

Code:
   JOINKEYS FILE=F1,FIELDS=(06,05,A) IF RECORD-TYPE='1111'
                                           (14,10,A) IF RECORD-TYPE='2222'
                                           (01,80,A) IF RECORD-TYPE NOT = ('1111' OR '2222')

You can do this in JNF1CNTL and JNF2CNTL by using
Code:
INREC IFTHEN ( Cond1) , Overlay=(81:1,4),
      IFTHEN ( Cond2) , Overlay=(81:1,80)


and then use below in the actual JOINKEYS operation in the main task.
Code:
JOINKEYS FILE=F1,FIELDS=(81,80,A)
Back to top
View user's profile Send private message
sandip_mainframe
Warnings : 2

New User


Joined: 20 Sep 2006
Posts: 63
Location: pune

PostPosted: Tue Dec 01, 2020 10:53 am
Reply with quote

Hi Rohit,

Good Morning !

The solution provided by you is working successfully. :-) Thank you very much. Sorry for the delay in reply.

Thanks,
Sandip Walsinge
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2567
Location: NYC,USA

PostPosted: Wed Dec 02, 2020 4:01 am
Reply with quote

Welcome Sandip!
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 can we simulate JOINKEYS in ICETOOL DFSORT/ICETOOL 8
No new posts Using sort on VB records based on off... DFSORT/ICETOOL 6
This topic is locked: you cannot edit posts or make replies. Copy list of files from PS to another... CLIST & REXX 11
No new posts Group comparison/update between two f... DFSORT/ICETOOL 10
No new posts Need assistance formatting when joini... SYNCSORT 8
Search our Forums:

Back to Top