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

Combining values from records in 2 files


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

New User


Joined: 14 Apr 2009
Posts: 14
Location: India

PostPosted: Wed Sep 22, 2010 10:40 pm
Reply with quote

Hi,

I have two files. One (File1) having around 1k records. Another (File2) having only 5 records.

File1 structure:
0001EBCD123456
0001MBCD123457
0001DBCD123458
0001BBCD123459
0001MBCD123450
0001FBCD123451
0001EBCD123452
0001MBCD123453
0001BBCD123453
0001DBCD123453

File2 structure:
E B
M B
D N
B N
F B

I need to compare the bold values from File1 with file2 and if match, append the rest of the record from file2 to file1.

O/P file will look like this -

0001EBCD123456 B
0001MBCD123457 B
0001DBCD123458 N
0001BBCD123459 N
0001MBCD123450 B
0001FBCD123451 B
0001EBCD123452 B
0001MBCD123453 B
0001BBCD123453 N
0001DBCD123453 N

Could someone please help with this?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Wed Sep 22, 2010 10:53 pm
Reply with quote

Hello,

When you have a question, you should start a new topic for your question rather than posting a reply to some existing unrelated topic.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Wed Sep 22, 2010 10:55 pm
Reply with quote

Give the RECFM and LRECL of each input file.

Give the starting position, length and format of each relevant field.

Your example does NOT show any non-matching records. Can you have a record in file1 without a match in file2? Can you have a record in file2 without a match in file1? If so, show a better example of input and output with these variations.
Back to top
View user's profile Send private message
NandanPhalak

New User


Joined: 14 Apr 2009
Posts: 14
Location: India

PostPosted: Wed Sep 22, 2010 11:12 pm
Reply with quote

Hi Frank,

Sorry for not providing sufficient data.
File1 LRECL - 14 bytes, RECFM - FB
File2 LRECL - 3 bytes, RECFM - FB

File1 field starts at position 5, length 1 byte. This field need to be compared with position 1 of File2. If this matches, append the last 2 bytes (or remaining bytes) of file2 to file 1.

I can have a record in file2 without a match in file1 but not vice-versa.

Thanks for your time and support!
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Wed Sep 22, 2010 11:25 pm
Reply with quote

Here's a DFSORT job that will do what you asked for:

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//IN1 DD DSN=...  input file1 (FB/14)
//IN2 DD DSN=...  input file2 (FB/3)
//SORTOUT DD DSN=...  output file (FB/16)
//SYSIN DD *
  JOINKEYS F1=IN1,FIELDS=(5,1,A)
  JOINKEYS F2=IN2,FIELDS=(1,1,A)
  REFORMAT FIELDS=(F1:1,14,F2:2,2,F1:15,8)
  SORT FIELDS=(17,8,ZD,A)
  OUTREC BUILD=(1,16)
/*
//JNF1CNTL DD *
  INREC OVERLAY=(15:SEQNUM,8,ZD)
/*
Back to top
View user's profile Send private message
NandanPhalak

New User


Joined: 14 Apr 2009
Posts: 14
Location: India

PostPosted: Thu Sep 23, 2010 12:07 am
Reply with quote

Thanks much Frank!

Couple of questions:
1. I am getting a syntax error on this code saying "BLANK NEEDED IN COLUMN 1 OR OPERATION NOT DEFINED CORRECTLY".. how to resolve this?
I tried giving space in 1st position and also in 1st and 2nd position.

2. Could you please explain how this works, espcially the CNTL part? How the CNTL part is getting used in the SORT, I am not able to see any connection? Am I missing here something?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Thu Sep 23, 2010 1:03 am
Reply with quote

1. That probably means you don't have the Nov, 2009 PTF which supports JOINKEYS installed. Ask your System Programmer to install it (it's free).

2. JNF1CNTL supplies control statements for the F1=IN1 task. It adds a sequence number at the end of the file1 input records so we can sort them back into their original order after the join.

For complete details on the PTF and JOINKEYS, see:

www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000174
Back to top
View user's profile Send private message
NandanPhalak

New User


Joined: 14 Apr 2009
Posts: 14
Location: India

PostPosted: Thu Sep 23, 2010 5:42 am
Reply with quote

Thank you so much!!

Appreciate your help!
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
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
Search our Forums:

Back to Top