Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Access to computed fiels in a grouped dw

396 views
Skip to first unread message

Frank

unread,
Jun 13, 2006, 4:08:55 PM6/13/06
to
I have a group dw with a computed field in the group, I need obtain the
values of this computed field for each group (N values). How can I do it
from within the own dw (for example to add to partial group resuls) and out
of the dw, in the code script..
Thanks in avance
Frank


Paul Horan[TeamSybase]

unread,
Jun 13, 2006, 5:57:06 PM6/13/06
to
"Frank" <fco...@ono.com> wrote in message news:448f1b57$1@forums-1-dub...

You do a getItemNumber( <row>, <computed column> ) where:
<row> is one row (usually the first row) in that group, and <computed
column> is your column.

So, if rows 1-10 are in the first group, then getItemNumber( n,
'myCompCol' ) will work for any value of "n" between 1 and 10. You can use
FindGroupChange() to find the first row of the "next" group.

Paul Horan[TeamSybase]


Frank

unread,
Jun 13, 2006, 6:32:08 PM6/13/06
to
Thank you Paul,
This may solve the second part of my question (access by code with
GetItemNumber() and FindGroupChange() functions)
but how can I access these values inside the dw to make operations with
them?

Thank you

"Paul Horan[TeamSybase]" <paul....@teamsybase.net> escribió en el mensaje
news:448f33d6$1@forums-2-dub...

dawntbrowneyes

unread,
Jun 13, 2006, 7:16:26 PM6/13/06
to
Paul,

You really can't refer to groups directly within the
datawindow like you can in script. You can't even refer to
previous, next.. computed fields only columns. You will
have to do some coding.

In the datawindow using [] notation you can get the
previous, current value and the next row's value. But you
can only get the previous, current, next for COLUMNS not
computed fields. So you will have to create dummy fields in
the sql and scroll through the datawindow setting the
dummyfields to the computed fields. Then issue a groupcalc
to reset everything and then the datawindow will recalculate
the values.

in the datawindow you must create dummy fields because []
notation can not be used with computed fields:
Select .... 0 as dummy1, 0 as dummy2

This is an example of a computed field in a trailer:
'this: ' +dummy1 [0] + ' next: ' + if (isnull(dummy1
[1]),0,dummy1[1])

it will print out the current dummy1 ([0]) and the next
dummy1 [1]. Note this will be set to the value of the
computed fields using powerscript.

Note: if it is the last row (isnull) then it will display 0
for the value

In script you can scroll thru the datawindow and set the
dummyfields:
long ll_cnt, ll_max, ll_group, ll_value1, ll_value2
long ll_first, ll_last

ll_max = dw_1.rowcount()
for ll_cnt = 1 to ll_max
//get the first row in the group
ll_first = long(dw_1.Describe("evaluate('first( getrow()
for group 1 )',"+string(ll_cnt)+")") )
//get the last row in the group
ll_last = long(dw_1.Describe("evaluate('last( getrow()
for group 1 )',"+string(ll_cnt)+")"))

//header computed fields are in the last row of the group
ll_value1 = dw_1.object.compute_1[ll_first]

//trailer computed fields are in the last row of the group
ll_value2 = dw_1.object.compute_2[ll_last]

if ll_cnt = ll_first then
ll_group = ll_group + 1
//first row processing
end if
if ll_cnt = ll_last then
//last row processing
end if

//set the dummy values in every row to the computed field
values in the 1st..last
dw_1.setitem(ll_cnt, 'dummy1', ll_value1)
dw_1.setitem(ll_cnt, 'dummy2', ll_value2)
next

//now recalculate the datawindow
dw_1.groupcalc()

Paul Horan[TeamSybase]

unread,
Jun 13, 2006, 10:14:12 PM6/13/06
to
I thought he was asking how to do it in script - not in dw expressions...
maybe I read it wrong.

--
Paul Horan[TeamSybase]
Cynergy Systems
www.cynergysystems.com

<Dawn T Brown Eyes[TeamSybase]> wrote in message
news:448f474a.49...@sybase.com...

dawntbrowneyes

unread,
Jun 14, 2006, 1:12:13 PM6/14/06
to
Hi Paul,

I think he was asking for both. ;-)

Frank

unread,
Jun 14, 2006, 2:02:25 PM6/14/06
to
Yes, for both... it is OK
Thank you

<Dawn T Brown Eyes[TeamSybase]> escribió en el mensaje
news:4490428d.30...@sybase.com...

0 new messages