Pas de problème (pb), que du PowerBuilder (PB) ^^

Le forum (ô combien francophone) des utilisateurs de Powerbuilder.

Recherche rapide

Annonce

Certaines rubriques, dont des cours, sont uniquement visibles par les membres du forum ^^.
Dans la rubrique Liens & Références, vous avez accès à un sommaire de téléchargement, profitez-en !
Il existe maintenant un nouveau TOPIC "Votre CV en Ligne" accessible uniquement par demande.

#1 07-09-2008 10:18:53

disneb  
Membre completement Geek
Lieu: Bejaia
Date d'inscription: 16-01-2008
Messages: 118
Pépites: 1,622
Banque: 0

[RESOLU] Parcourir les lignes d'un group

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

 

#2 07-09-2008 13:45:58

erasorz  
Admin
Lieu: Babylone
Date d'inscription: 23-11-2006
Messages: 5121
Pépites: 97,197
Banque: 2,147,483,647

Re: [RESOLU] Parcourir les lignes d'un group


N'envoyez jamais un humain faire le travail d'un programme.

Hors ligne

 

#3 07-09-2008 22:01:34

disneb  
Membre completement Geek
Lieu: Bejaia
Date d'inscription: 16-01-2008
Messages: 118
Pépites: 1,622
Banque: 0

Re: [RESOLU] Parcourir les lignes d'un group

Hors ligne

 

#4 08-09-2008 06:34:52

erasorz  
Admin
Lieu: Babylone
Date d'inscription: 23-11-2006
Messages: 5121
Pépites: 97,197
Banque: 2,147,483,647

Re: [RESOLU] Parcourir les lignes d'un group

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()

N'envoyez jamais un humain faire le travail d'un programme.

Hors ligne

 

Pied de page des forums

Propulsé par FluxBB 1.2.22