Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
how to juxtapose/concatenate records

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
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    Post subject: how to juxtapose/concatenate records
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10327
Location: italy

PostPosted: Mon May 25, 2009 2:39 pm    Post subject: Reply to: How to set End of file in rexx
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10327
Location: italy

PostPosted: Mon May 25, 2009 3:31 pm    Post subject: Reply to: how to juxtapose/concatenate records
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: 6968
Location: porcelain throne

PostPosted: Mon May 25, 2009 3:38 pm    Post subject:
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    Post subject:
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: 6968
Location: porcelain throne

PostPosted: Mon May 25, 2009 4:07 pm    Post subject:
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    Post subject: Reply to: how to juxtapose/concatenate records
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10327
Location: italy

PostPosted: Mon May 25, 2009 4:31 pm    Post subject: Reply to: how to juxtapose/concatenate records
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    Post subject: Reply to: how to juxtapose/concatenate records
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: 6968
Location: porcelain throne

PostPosted: Mon May 25, 2009 6:16 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Addition of two records on 2 fields amar143 SYNCSORT 8 Tue Oct 03, 2017 11:14 am
No new posts Join records from 2 files with No Dup... Poha Eater DFSORT/ICETOOL 22 Sun Aug 27, 2017 10:35 pm
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us