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

compare 2 files and how to extract the records.


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ssprabhu

New User


Joined: 25 Apr 2005
Posts: 67
Location: pune

PostPosted: Fri Sep 26, 2008 8:21 pm
Reply with quote

Hi ,

I have 2 files say X and Y. both contains customer numbers.

If a customer number in file X matches in file Y and with a specific indicator embedded wtih the record, like cust no details from 1 to 4 th coloumn and 5 th coloumn an indicator N is associated with the customer in file Y so only in that case i need to cut(remove the details ) the whole cutomer details from file X and report in to a new file.

Please could you advise me how to do using JCL stmts.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Sep 26, 2008 8:31 pm
Reply with quote

Quote:
Please could you advise me how to do using JCL stmts

JCL as such does nothing. you can achieve this using any of the sort products installed at your shop(DFSORT or SYNCSORT). Can you post some sample input/output records
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Sat Sep 27, 2008 3:04 am
Reply with quote

If I understood your requirements correctly, here is a sample SyncSort for z/OS job that will do what you asked:
Code:
//SORT1 EXEC PGM=SORT                   
//SORTJNF1 DD *                         
1111 DETAILS DETAILS DETAILS             
2222 DETAILS DETAILS DETAILS             
3333 DETAILS DETAILS DETAILS             
4444 DETAILS DETAILS DETAILS             
5555 DETAILS DETAILS DETAILS             
6666 DETAILS DETAILS DETAILS             
7777 DETAILS DETAILS DETAILS         
//SORTJNF2 DD *                                             
1111N
2222                                                     
3333                                                       
4444N                                                       
6666N                                                       
8888N                                                       
//SORTOUT DD SYSOUT=*                                       
//SYSOUT DD SYSOUT=*                                       
//SYSIN DD *                                               
   JOINKEYS FILES=F1,FIELDS=(1,4,A)                         
   JOINKEYS FILES=F2,FIELDS=(1,4,A)                         
   REFORMAT FIELDS=(F1:1,80,F2:5,1)                         
   SORT FIELDS=COPY                                         
   OUTFIL FILES=OUT,INCLUDE=(81,1,CH,EQ,C'N'),OUTREC=(1,80)   
/*

The following output is produced:
Code:
1111 DETAILS DETAILS DETAILS
4444 DETAILS DETAILS DETAILS
6666 DETAILS DETAILS DETAILS
Back to top
View user's profile Send private message
ssprabhu

New User


Joined: 25 Apr 2005
Posts: 67
Location: pune

PostPosted: Mon Sep 29, 2008 12:29 pm
Reply with quote

Miss Alissa,

Many many thanks. Really much apreciated ..
thanks for understanding my requirements clearly... :-)
i never expect such reply..
Back to top
View user's profile Send private message
ssprabhu

New User


Joined: 25 Apr 2005
Posts: 67
Location: pune

PostPosted: Mon Sep 29, 2008 1:08 pm
Reply with quote

But Alissa, i have to delete the matched entries from SORTJNF1 file.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Mon Sep 29, 2008 4:38 pm
Reply with quote

Quote:
i need to cut(remove the details ) the whole cutomer details from file X and report in to a new file.

The job posted by Alissa does exactly what you asked for in your initial post given above. You just need to route your SORTOUT dd to a new file. If you want to replace your SORTJNF1 file with the current output, you can always one more step to do a copy.
Back to top
View user's profile Send private message
ssprabhu

New User


Joined: 25 Apr 2005
Posts: 67
Location: pune

PostPosted: Mon Sep 29, 2008 6:48 pm
Reply with quote

Arun yes it works ...but the one more thing is have to delete the matched entries from SORTJNF1 file. that is the below entries should be removed from SORTJNF1 file.

1111 DETAILS DETAILS DETAILS
4444 DETAILS DETAILS DETAILS
6666 DETAILS DETAILS DETAILS

How we can do that...
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Mon Sep 29, 2008 7:19 pm
Reply with quote

ssprabhu,

You can use the below Syncsort job to write two output files like this.

MATCH - matched records from both the files.
NOMATCH1 - unmatched records from file-1.
Code:
//STEP1    EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//NOMATCH1 DD SYSOUT=*                                   
//MATCH    DD SYSOUT=*                                   
//SORTJNF1 DD *                                           
1111 DETAILS DETAILS DETAILS                             
2222 DETAILS DETAILS DETAILS                             
3333 DETAILS DETAILS DETAILS                             
4444 DETAILS DETAILS DETAILS                             
5555 DETAILS DETAILS DETAILS                             
6666 DETAILS DETAILS DETAILS                             
7777 DETAILS DETAILS DETAILS                             
//SORTJNF2 DD *                                           
1111N                                                     
2222                                                     
3333                                                     
4444N                                                     
6666N                                                     
8888N                                                     
//SYSIN    DD *                                           
  JOINKEYS FILE=F1,FIELDS=(1,4,A)                         
  JOINKEYS FILE=F2,FIELDS=(1,4,A),INCLUDE=(5,1,CH,EQ,C'N')
  JOIN UNPAIRED,F1                                             
  REFORMAT FIELDS=(F1:1,80,F2:5,1),FILL=X'FF'                   
  SORT FIELDS=COPY                                             
  OUTFIL FNAMES=NOMATCH1,INCLUDE=(81,1,BI,EQ,X'FF'),BUILD=(1,80)
  OUTFIL FNAMES=MATCH,SAVE,BUILD=(1,80)                         

MATCH
Code:
1111 DETAILS DETAILS DETAILS
4444 DETAILS DETAILS DETAILS
6666 DETAILS DETAILS DETAILS

NOMATCH1
Code:
2222 DETAILS DETAILS DETAILS
3333 DETAILS DETAILS DETAILS
5555 DETAILS DETAILS DETAILS
7777 DETAILS DETAILS DETAILS
Back to top
View user's profile Send private message
ssprabhu

New User


Joined: 25 Apr 2005
Posts: 67
Location: pune

PostPosted: Mon Sep 29, 2008 8:08 pm
Reply with quote

Many Many Many thanks Arun...

Please could you send me the documents having basic details about
JOINKEYS ,REFORMAT FIELDS , JOIN UNPAIRED

i have searched in google but i didn't get anything...
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Mon Sep 29, 2008 8:26 pm
Reply with quote

ssprabhu,

You can contact me offline at alissa.margulies@syncsort.com and I would be happy to assist you with acquiring the manuals.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Tue Sep 30, 2008 9:15 am
Reply with quote

ssprabhu,

You're welcome. icon_smile.gif
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
No new posts Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top