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

Comapre two files and create a new record.


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
faizm

New User


Joined: 13 Apr 2012
Posts: 59
Location: India

PostPosted: Wed Feb 05, 2014 9:20 pm
Reply with quote

Hi All,

I have two input files (file1 and file2) of same LRECL but number of records could be different in both files i.e file2 may have more records than file1 . First field in both files is an that reflects whether it is changed record (C) or new added record (A) indicator field.
My requirement is basically

1. If any of the field is mismatched in both files then write the record in new output file and insert an indicator C(change) in first field.
2. If it is totally a new record (additional records in file 2) then write these new records from file 2 and insert an indicator A(add) in first field.
3. If record matches then don't write in output file.

Ex: I in below records is indicator field.
input file1 has 3 records
IABCD
IEFGH
IIJKL

input file 2 has 4 records
IABCD
IEFGK
IIJKL
IMNOP

Result should be:
CEFGK
AMNOP

Please reply how we can implement it using SORT. Thanks.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed Feb 05, 2014 9:34 pm
Reply with quote

Could you please confirm the product you use?
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2454
Location: Hampshire, UK

PostPosted: Wed Feb 05, 2014 9:37 pm
Reply with quote

Do none of the other JOINKEY examples in the forum help you on this?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Wed Feb 05, 2014 9:56 pm
Reply with quote

are You telling that the key is from column 2 for three bytes ?
Back to top
View user's profile Send private message
faizm

New User


Joined: 13 Apr 2012
Posts: 59
Location: India

PostPosted: Thu Feb 06, 2014 8:45 pm
Reply with quote

Just to give some more information. LRECL of both the files are 200 and the key in both the files start at 11 and end at 20 that is key length is 10 char. Now if there is a way I can compare the two files and write the records in a new file. I am trying JOINKEYS.
Can anybody provide me the psuedo code and help me with the tutorial location as well so that I can go and read the syntax etc.

Also, how much it will be feasible (taking CPU time in consideration) to compare the files using JCL when the number of records are 10 lakhs around. Or should I go and write a program to read both the files and compare each values present in them.


Thanks for reply.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2454
Location: Hampshire, UK

PostPosted: Thu Feb 06, 2014 9:29 pm
Reply with quote

Quote:
compare the files using JCL

JCL cannot do this - it only tells the system what programs you want to run and what resources are required by those programs.

Syncsort documentation is only available to licensed sites so you should ask around your shop for copies. a good place for examples is within this section of the forum - do a search on JOINKEYS.

To compare files why not use the facilities available to you - sepcifically SUPERC which can be run in both background (batch) or foreground. Your site may have another compare tool e.g. Comparex but you will have to ask around your colloeagues.
Back to top
View user's profile Send private message
sureshpathi10

Active User


Joined: 03 May 2010
Posts: 158
Location: Kuala Lumpur

PostPosted: Fri Feb 07, 2014 10:38 am
Reply with quote

Faizm,

As per the example given,I assumed your LRECL=5 and RECFM=FB.
Key field = 1,4 . Data=5th column.

Code:
//SORT      EXEC  PGM=SORT                                     
//SORTOUT   DD SYSOUT=*                                       
//SYSIN     DD *                                               
  JOINKEYS F1=IN1,FIELDS=(1,4,A)                               
  JOINKEYS F2=IN2,FIELDS=(1,4,A)                               
  JOIN UNPAIRED,F2                                             
  REFORMAT FIELDS=(F1:1,5,F2:1,5)                             
  OPTION COPY                                                 
  OUTREC IFTHEN=(WHEN=(1,4,CH,EQ,6,4,CH,AND,5,1,CH,NE,10,1,CH),
                 BUILD=(1:C'C',7,4)),                         
         IFTHEN=(WHEN=(1,4,CH,NE,6,4,CH),                     
                 BUILD=(1:C'A',7,4))                           
  OUTFIL OMIT=(1,5,CH,EQ,6,5,CH)                               
//SYSOUT    DD  SYSOUT=*                                       
//IN1       DD *
IABCD           
IEFGH           
IIJKL           
//IN2       DD *
IABCD           
IEFGK           
IIJKL           
IMNOP           



Output is:
Code:
CEFGK
AMNOP


There might be simplest way to achieve this. But I just tried to get the desire output. May be Bill/Kolusu will clear your clarification if you have any.

Note: I feel this Topic should be moved to DFSORT.
Back to top
View user's profile Send private message
faizm

New User


Joined: 13 Apr 2012
Posts: 59
Location: India

PostPosted: Fri Feb 07, 2014 11:36 am
Reply with quote

Thanks Suresh and everyone to help me out icon_smile.gif
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2454
Location: Hampshire, UK

PostPosted: Fri Feb 07, 2014 2:43 pm
Reply with quote

Quote:
Note: I feel this Topic should be moved to DFSORT.

Why? Nowhere has OP stated, or inferred, that they are using DFSort and, in fact, refused to say which product was being used despite multiple requests. Syncsort lives in JCL (for some strange reason) so it has to be assumed, unless otherwise stated, that the product in question is Syncsort
Back to top
View user's profile Send private message
faizm

New User


Joined: 13 Apr 2012
Posts: 59
Location: India

PostPosted: Fri Feb 07, 2014 3:16 pm
Reply with quote

Nic,

We are using SYNCSORT. I just mention that if we can solve the problem through JCL (and need not to write any cobol pgm) that was just to check if we can use any utility programs like SORT. Thanks.
Regards
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2454
Location: Hampshire, UK

PostPosted: Sat Feb 08, 2014 2:55 pm
Reply with quote

Please note that you are not solving the problem "through jcl". When running in batch JCL will be used whether you you use a utility program or a program written in the language of your choice.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Mon Feb 10, 2014 10:23 pm
Reply with quote

Hello,

Quote:
I just mention that if we can solve the problem through JCL
Just curious, just why does someone believe you can do this "with JCL"?

Most of your contrymen understand they are running a utility with JCL (i.e. batch) and use the correct terminology when talking about it.

Somewhere there, clueless trainers and/or managers have taught this. . .

People who use this terminology just demonstrate that they do not have the slightest grasp of their working environment.
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 -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts 3 files concatenated to 1 DFSORT/ICETOOL 2
No new posts Copy only TEXT or String from a record SYNCSORT 4
No new posts JCL sort to compare dates in two file... DFSORT/ICETOOL 2
No new posts combine multiple unique records into ... DFSORT/ICETOOL 2
No new posts SORT on detail record, then repeat he... DFSORT/ICETOOL 3
Search our Forums:

Back to Top