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

how to juxtapose/concatenate records


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

New User


Joined: 10 Sep 2008
Posts: 11
Location: Chennai - India

PostPosted: Mon May 25, 2009 2:19 pm
Reply with quote

While cascading 4 PS files, i have to set the EOF status whenever a file read is completed. Can you help me for the below condition how to attain the same?

DO I = 1 TO LIST1.0
OUTPUT.I = LIST1.I'/'LIST2.I'/'LIST3.I'/'LIST4.I
END
OUTPUT.0 = LIST1.0

How can i verify the EOF status with the above Rexx Code?

Input data

LIST1
A
B
C
D

LIST2
A
B
C

LIST3
A
B

LIST4
A

For the provided input my output should be as
A/A/A/A
B/B/B
C/C
D

But Im getting the o/p as

A/A/A/A
B/B/B/LIST4.2
C/C/LIST3.3/LIST4.3
D/LIST2.4/LIST3.4/LIST4.4
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon May 25, 2009 2:39 pm
Reply with quote

not really REXX related,
it is just an issue of devising a logic to juxtapose records from files with a different number of records.

what has to be inserted for a missing record
Code:
file 1
a
b
c

file 2
x
y

file 3
1

output
a/x/1
b/y/?
c/?/?


proper answer will give the solution for the general case of n files
where the shorter files will be in any position

Code:
file 1
a

file 2
x
y

file 3
1
2
3

output
a/x/1
?/y/2
?/?/3


for large files a sort ( any make ) will certainly give better performance
Back to top
View user's profile Send private message
leninmathangi

New User


Joined: 10 Sep 2008
Posts: 11
Location: Chennai - India

PostPosted: Mon May 25, 2009 3:20 pm
Reply with quote

The space should be empty. The position is not a problem. For the example given by you, my expected output should be

a/x/1
y/2
3

The reason is because, in my requirement the first record will contain all the records. The second record will have less number of records comparing to the first one. The third will be less than the second, as it goes on.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon May 25, 2009 3:31 pm
Reply with quote

Your logic/<business requirements> makes me uncomfortable
different inputs might give the same output icon_question.gif

what makes You so sure that the files will be in the proper sequence
k1 >= k2 >= k3 >= k4 >= .... >= kn

before proceeding You would need to do some checking...
and... what if ??
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon May 25, 2009 3:38 pm
Reply with quote

how did you decide that LIST1 stem was the largest?
if you know the order of size of the 4 stems,
it would seem logical to concatenate to LIST1. repeatedly, based on the count of the next smaller LIST? stem.
Back to top
View user's profile Send private message
leninmathangi

New User


Joined: 10 Sep 2008
Posts: 11
Location: Chennai - India

PostPosted: Mon May 25, 2009 3:58 pm
Reply with quote

Hi enrico,

Im extracting records from DB2 based on certain conditions.
For all the transaction i do through online/batch table1 will be updated. only for certain transactions the other tables will get loaded.
I have selecetd the order of tables in such a fashion, and the extracted output is stored in PS files as file1,file2 and as it goes. So the business requirement is correct here, and im trying to achieve that.

Thanks
Lenin
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon May 25, 2009 4:07 pm
Reply with quote

Lenin,

your concatenation logic is backwards.

if you know that one file is larger than the other, why use the count of the larger to perform the concatenation?.
Back to top
View user's profile Send private message
leninmathangi

New User


Joined: 10 Sep 2008
Posts: 11
Location: Chennai - India

PostPosted: Mon May 25, 2009 4:18 pm
Reply with quote

When i tried trial & error method i found the below solution.

Code:
DO I = 1 TO LIST1.0 
  IF I < LIST2.0 THEN
  DO                 
    B = LIST2.I     
  END               
  ELSE               
  DO                 
    B = '/////'     
  END               
  IF I < LIST3.0 THEN
  DO                 
    C = LIST3.I     
  END               
  ELSE               
  DO                 
    C = '/'         
  END                                                   
IF I < LIST4.0 THEN                                   
 DO                                                   
  D = LIST4.I                                         
END                                                   
ELSE                                                 
DO                                                   
  D = '/////'                                         
END                                                   
OUTPUT.I = LIST1.I || '/' || B || '/' || C || '/' || D

Let me try out in the other way mentioned. Thanks

Lenin
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon May 25, 2009 4:31 pm
Reply with quote

more compact coding would be
Code:
do   i = 1 to l1.0
   out.i = l1.i
   if  i > l2.0 then iterate
   out.i = out.i || "/" || l2.i
   if  i > l3.0 then iterate
   out.i = out.i || "/" || l3.i
   if  i > l4.0 then iterate
   out.i = out.i || "/" || l4.i
end


tested
Back to top
View user's profile Send private message
leninmathangi

New User


Joined: 10 Sep 2008
Posts: 11
Location: Chennai - India

PostPosted: Mon May 25, 2009 4:42 pm
Reply with quote

Superb. Thanks Enrico and Dino. Will reach you if i need any clrifications - Lenin
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon May 25, 2009 6:16 pm
Reply with quote

if you find you run out of storage, this may help:
Code:

do   i = 1 to list1.0
select
  when list4.0 >= i then
         out.i = list1.i || list2.i || list3.i || list4.i
  when list3.0 >= i then
         out.i = list1.i || list2.i || list3.i
  when list2.0 >= i then
         out.i = list1.i || list2.i
  otherwise
         out.i = list1.i
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 Compare 2 files(F1 & F2) and writ... JCL & VSAM 4
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Join multiple records using splice DFSORT/ICETOOL 5
No new posts EZT program to build a flat file with... All Other Mainframe Topics 9
Search our Forums:

Back to Top