A problem xBrowse Total and Index UNIQUE

A problem xBrowse Total and Index UNIQUE

Postby ukoenig » Fri Sep 18, 2015 6:21 pm

Hello,

is it possible to use xbrowse total with a index UNIQUE ?

sample :
A customer can have many bills the same time
each bill can have many positions
each position includes the invoice total
using index UNIQUE I display each bill with the invoice total only once

the problem
xbrowse total is counting ALL positions. UNIQUE is ignored.

Image

another section shows the details of a bill ( positions )

Image

maybe a different solution needed ?
I could calculate each column and display the result using the footer

My working test

Image

counting the column-values

Code: Select all  Expand view


The used and created index

NET_USE ( c_Pfad3 + cRMonat + ".DBF", cRMonat, 3,.F. ) = .T.
     ORDCREATE( ,"STAT", "UPPER(PAT_NNAME + PAT_VNAME) + STR(RECHNG_ZAE)", ;
     {|| STR(RECHNG_ZAE) } , .T. )  // .T. = UNIQUE

TOTAL defined in xBrowse

WITH OBJECT oBrw1
     FOR I := 5 TO 13
          :aCols[ I ]:nWidth := 75
          :aCols[ I ]:nDataStrAlign   := AL_RIGHT
          :aCols[ I ]:nHeadStrAlign   := AL_CENTER
          :MakeTotals() // not working
          :aCols[ I ]:lTotal := .T.
          :aCols[ I ]:nTotal := 0
     NEXT
END

Footer values REPLACED WITH :

(cRMonat)->(DBGOTOP())

nReNr := (cRMonat)->RECHNG_ZAE
DO WHILE !EOF()
        IF (cRMonat)->KENNER = "KrK"  // different bill-types
            nValue[1] += (cRMonat)->K1_SUMME
        ELSEIF (cRMonat)->KENNER = "KrX"
            nValue[2] += (cRMonat)->K2_SUMME
        ELSEIF (cRMonat)->KENNER = "PrX"
            nValue[3] += (cRMonat)->PR_SUMME
        ELSEIF (cRMonat)->KENNER = "PfK"
            nValue[4] += (cRMonat)->P0_SUMME
        ELSEIF (cRMonat)->KENNER = "PfB"
            nValue[5] += (cRMonat)->P1_SUMME
        ELSEIF (cRMonat)->KENNER = "B1K"
            nValue[6] += (cRMonat)->PB1_SUMME
        ELSEIF (cRMonat)->KENNER = "B1P"
            nValue[7] += (cRMonat)->PB2_SUMME
        ELSEIF (cRMonat)->KENNER = "B2K"
            nValue[8] += (cRMonat)->P2_SUMME
        ELSEIF (cRMonat)->KENNER = "B2P"
            nValue[9] += (cRMonat)->P3_SUMME
        ENDIF

        (cRMonat)->(DBSKIP(+1))

        IF nReNr = (cRMonat)->RECHNG_ZAE
            (cRMonat)->(DBSKIP(+1))
            nReNr := (cRMonat)->RECHNG_ZAE
        ENDIF
ENDDO

 


best regards
Uwe :?:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: A problem xBrowse Total and Index UNIQUE

Postby ukoenig » Mon Sep 21, 2015 7:05 pm

Same result using a original FWH-sample

Image

Not possible to refresh footers with total
calculated footers are working fine

Image

I created a CUSTOMER.dbf with some equal names !!! for testing UNIQUE

Code: Select all  Expand view

#include 'fivewin.ch'
#include 'ord.ch'
#include 'xbrowse.ch'

REQUEST DBFCDX

//---------------------------------

FUNCTION MAIN()
local oDlg, oBrw1, oBrw2, oFont
local nMaxSal  := 0, nValue := 0
local nProgClr := RGB( 161, 224, 255 )

XBrNumFormat( 'E', .t. )

USE customer NEW SHARED ALIAS CUST VIA 'DBFCDX'
ORDCREATE( ,"CUST1", "UPPER(LAST)", ;
        {|| UPPER(LAST) } , .F. )  // .T. = UNIQUE
ORDCREATE( ,"CUST2", "UPPER(LAST)", ;
        {|| UPPER(LAST) } , .T. )  // .T. = UNIQUE

DBSETORDER("CUST1")

DBEval( { || nMaxSal := Max( nMaxSal, FIELD->Salary ) } )
GO TOP

DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12

DEFINE DIALOG oDlg SIZE 500, 520 PIXEL ;
TITLE "Progress Bars in XBrowse" ;
FONT oFont

@ 10,10 XBROWSE oBrw1 ;
      COLUMNS 'Last', 'Age', 'Salary' ;
      OF oDlg ;
      SIZE 220, 100 PIXEL ;
      PICTURES nil, '999.99 %' ;
      ALIAS 'CUST' ;
      CELL LINES AUTOSORT NOBORDER FOOTERS

WITH OBJECT oBrw1:Salary
      :SetProgBar( { || nMaxSal },, { || { nProgClr, CLR_WHITE } } )
      :nDataStrAlign := AL_RIGHT
END

WITH OBJECT oBrw1:Age
      :cHeader    := 'Percent'
      :SetProgBar( 100, 104, { || { nProgClr, CLR_WHITE } } )
      :nDataStrAlign := AL_RIGHT
END

WITH OBJECT oBrw1
      :nStretchCol   := 1
      :CreateFromCode()
END

nValue := FOOTER_UPD(nValue)
oBrw1:aCols[3]:cFooter := nValue
('CUST')->(DBGOTOP())
oBrw1:Refresh()

// -----------------

@ 150,10 XBROWSE oBrw2 ;
      COLUMNS 'Last', 'Age', 'Salary' ;
      OF oDlg ;
      SIZE 220, 100 PIXEL ;
      PICTURES nil, '999.99 %' ;
      ALIAS 'CUST' ;
      CELL LINES AUTOSORT NOBORDER FOOTERS

WITH OBJECT oBrw2:Salary
      :nTotal     := 0
      :lTotal     := .t.
      :SetProgBar( { || nMaxSal },, { || { nProgClr, CLR_WHITE } } )
      :nDataStrAlign := AL_RIGHT
END

WITH OBJECT oBrw2:Age
      :cHeader    := 'Percent'
      :SetProgBar( 100, 104, { || { nProgClr, CLR_WHITE } } )
      :nDataStrAlign := AL_RIGHT
END

WITH OBJECT oBrw2
      :nStretchCol   := 1
      :MakeTotals()
      :CreateFromCode()
END

@ 120,70 BUTTON "Normal" size 40,20  OF oDlg PIXEL ;
ACTION ( DBSETORDER("CUST1"), nValue := FOOTER_UPD(nValue), ;
                  ('CUST')->(DBGOTOP()), ;
          oBrw1:aCols[3]:cFooter := nValue, ;
                  oBrw1:Refresh(), oBrw2:RefreshFooters(), oBrw2:Refresh() )

@ 120,150 BUTTON "Unique" size 40,20  OF oDlg PIXEL ;
ACTION ( DBSETORDER("CUST2"), nValue := FOOTER_UPD(nValue), ;
                  ('CUST')->(DBGOTOP()), ;
          oBrw1:aCols[3]:cFooter := nValue, ;
                  oBrw1:Refresh(), oBrw2:RefreshFooters(), oBrw2:Refresh() )

ACTIVATE DIALOG oDlg CENTERED

RELEASE FONT oFont

RETURN NIL

// ---------------

FUNCTION FOOTER_UPD(nValue)

nValue := 0
('CUST')->(DBGOTOP())
DO WHILE !EOF()
    nValue += ('CUST')->Salary
    ('CUST')->(DBSKIP(+1))
ENDDO

RETURN nValue
 


best regards
Uwe :?
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 93 guests