View previous topic :: View next topic
|
Author |
Message |
leninmathangi
New User
Joined: 10 Sep 2008 Posts: 11 Location: Chennai - India
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
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 |
|
|
leninmathangi
New User
Joined: 10 Sep 2008 Posts: 11 Location: Chennai - India
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Your logic/<business requirements> makes me uncomfortable
different inputs might give the same output
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
leninmathangi
New User
Joined: 10 Sep 2008 Posts: 11 Location: Chennai - India
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
leninmathangi
New User
Joined: 10 Sep 2008 Posts: 11 Location: Chennai - India
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
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 |
|
|
leninmathangi
New User
Joined: 10 Sep 2008 Posts: 11 Location: Chennai - India
|
|
|
|
Superb. Thanks Enrico and Dino. Will reach you if i need any clrifications - Lenin |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
|