Le forum (ô combien francophone) des utilisateurs de Powerbuilder.
bonjour,
j'ai une datawindows de la sort
N° cpt debit credit
group(1) N°cpt sum_debit sum_credit
je voudrai parcourir seulement les sommes pour les récupérer (c'est une datastore)
Dernière modification par disneb (07-09-2008 22:02:22)
Hors ligne
Hors ligne
Hors ligne
je mets le post pour info :
Dawn T Brown Eyes - TeamSybase a écrit:
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:Code: pb
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()
Hors ligne