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

Read two files


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
TGarcia

New User


Joined: 24 Jul 2021
Posts: 3
Location: United States

PostPosted: Thu Jul 29, 2021 8:48 pm
Reply with quote

How can I read two DSN compared one variable:

Code:
FILE1:

ALBERT  DAILY 
MARK WEEKLY
PETER MONTHLY

Code:
FILE2:
ALBERT 651-222-4561
ALBERT 651-333-4562
PETER   651-444-1235

Code:

DESIRED OUTPUT:
ALBERT DAILY       651-222-4561
ALBERT DAILY       651-333-4562
PETER   MONTHLY  651-444-1235

Coded
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Thu Jul 29, 2021 8:53 pm
Reply with quote

Why REXX? Easier and faster with DFSORT/SYNCSORT.
Please use code tags.
Back to top
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1189

PostPosted: Fri Jul 30, 2021 1:11 am
Reply with quote

Quote:
How can I read two DSN compared one variable:

Please, clarify this using the commonly used terminology.
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2258
Location: Silicon Valley

PostPosted: Fri Jul 30, 2021 6:20 am
Reply with quote

Judging from the example, he wants to use the name column to join two tables.

The data is not in DB2 tables, so the join needs to be done through a program.
Back to top
View user's profile Send private message
Willy Jensen

Active User


Joined: 01 Sep 2015
Posts: 495
Location: Denmark

PostPosted: Fri Jul 30, 2021 3:25 pm
Reply with quote

You use the fact that a stem suffix is just a string. I assume that dataset 1 is the master, which will contain all names found in dataset 2.
Then this will do it:
Code:
/* populate lists */                         
 list1.1='ALBERT DAILY   '                   
 list1.2='MARK WEEKLY     '                 
 list1.3='PETER MONTHLY   '                 
 list1.0=3                                   
 list2.1='ALBERT 651-222-4561 '             
 list2.2='ALBERT 651-333-4562 '             
 list2.3='PETER  651-444-1235'               
 list2.0=3                                   
 /* split list1, make master */             
 mstr.='?'                                   
 do n=1 to list1.0                           
   parse var list1.n name text               
   mstr.name=text                           
 end                                         
 /* make result list (replace list2) */     
 do n=1 to list2.0                           
   parse var list2.n name text               
   list2.n=name mstr.name subword(list2.n,2)
 end                                         
 /* show */                                 
 do n=1 to list2.0                           
   say list2.n                               
 end                                         
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 -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts How to read IPv6 from ADDR_INFO in EZ... All Other Mainframe Topics 0
No new posts Compare 2 files replace data in 1st f... DFSORT/ICETOOL 4
No new posts Merging 2 files but ignore duplicate... DFSORT/ICETOOL 1
No new posts DB2 SQL query to read and update data... DB2 12
No new posts Read UTF-8 file in Cobol COBOL Programming 5
Search our Forums:

Back to Top