To Mr. Rao, XBrowse totals (SOLVED)

Post Reply
User avatar
Armando
Posts: 2479
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Contact:

To Mr. Rao, XBrowse totals (SOLVED)

Post by Armando »

Hi Mr. Rao:

Would you help us?

This is my code

Code: Select all

   REDEFINE XBROWSE oBrw ID 200 OF oDlg;
      DATASOURCE oRsDsl ;
      COLUMNS "DIE_FOL", "DIE_FDM", "DIE_REF", "", "","DIE_IMP","UNI_DES","OPE_NOM","DIE_DES", "DIE_CAN";
      HEADERS "Folio", "Fecha", "Referencia", "Compras", "Consumos","Importe","Unidad","Operador", "Destino(s)", "Can";
      COLSIZES 60, 75, 90, 65, 65, 80, 200, 220,230, 40, 40;
      PICTURES "@Z 9999999","dd/mmm/yyyy", NIL, "@Z 999,999", "@Z 999,999","@Z 9,999,999.99", NIL, NIL,NIL, NIL;
      JUSTIFY { AL_RIGHT, AL_RIGHT, AL_LEFT, AL_RIGHT, AL_RIGHT,AL_RIGHT, AL_LEFT, AL_LEFT, AL_LEFT, AL_CENTER };
      FOOTERS AUTOSORT BACKGROUND "Lineas"

   WITH OBJECT oBrw
      :l2007            := ( .F. )
      :lHScroll         := ( .F. )
      :lVScroll         := ( .F. )
      :nMarqueeStyle    := MARQSTYLE_HIGHLROW
      :nColDividerStyle := LINESTYLE_LIGHTGRAY
      :nRowDividerStyle := LINESTYLE_LIGHTGRAY
      :nStretchCol      := STRETCHCOL_LAST
      :SetGroupHeader( "L I T R O S", 04, 05 )
      :nHeaderHeight    := 25
      :nRowHeight       := 22
      :nFooterHeight    := 25
      :bClrHeader       := {|| { CLR_WHITE,CLR_BLACK } }
      :bClrFooter       := {|| { CLR_WHITE,CLR_BLACK } }
      :bClrSel          := {|| IF( oBrw:KeyNo % oApp:nRowsInt == 0,{ CLR_BLACK, oApp:nRowParClr }, { CLR_BLACK, oApp:nRowNonClr } ) }
      :bClrSelFocus     := {|| { oApp:nFClrFocus,oApp:nBClrFocus } }
      :bClrStd          := {|| IF( oBrw:KeyNo % oApp:nRowsInt == 0,{ CLR_BLACK, oApp:nRowParClr }, { CLR_BLACK, oApp:nRowNonClr } ) }
      :nRecSelColor     := oApp:nRowParClr
      :lDisplayZeros    := ( .F. )  // zero values are not displayed. Added by GNRao. No need to use @Z

      // Por fuerza debe ir dentro del WITH OBJECT oBrw
      WITH OBJECT :aCols[ 01 ]
         :cOrder := "A"
      END

      WITH OBJECT :aCols[ 04 ]
         :bStrData         := {|| IF( oRsDsl:RecordCount() > 0 .AND. ;
         oRsDsl:Fields( "DIE_EOS" ):Value == "E", ;
         Transform( oRsDsl:Fields( "DIE_LTS" ):Value, "@Z 9,999,999" ), Space( 01 ) ) }
         :nHeadStrAlign    := AL_RIGHT
      END

      WITH OBJECT :aCols[ 05 ]
         :bStrData         := {|| IF( oRsDsl:RecordCount() > 0 .AND. ;
         oRsDsl:Fields( "DIE_EOS" ):Value == "S", ;
         Transform( oRsDsl:Fields( "DIE_LTS" ):Value, "@Z 9,999,999" ), Space( 01 ) ) }
         :nHeadStrAlign    := AL_RIGHT
      END

      WITH OBJECT :aCols[ 06 ]
         :nFooterType      := AGGR_SUM
         :bSumCondition    := { || ! oRsDsl:Fields("DIE_CAN"):Value }
         :cFooterPicture   := "@Z 99,999,999.99"
         :nFootStrAlign    := AL_RIGHT
      END

      WITH OBJECT :aCols[07]
         :nFootStrAlign  := AL_LEFT
         :bFooter        := { || "<= no se incluyen los vales cancelados" }
      END

      :MakeTotals()

      WITH OBJECT :aCols[ 10 ]
         :SetCheck( { "SI16", "NO16" } )
      END
   END
 
As you can see there is one FIELD (oRsDsl:Fields( "DIE_LTS" ):Value) for two columns (4 and 5)
it depends on the field oRsDsl:Fields( "DIE_EOS" ):Value.
how can I get totals for each column (4 and 5)

I've tried with

Code: Select all

         :nFooterType      := AGGR_SUM
         :bSumCondition    := { || ! oRsDsl:Fields("DIE_CAN"):Value}
         :cFooterPicture   := "@Z 99,999,999.99"
         :nFootStrAlign    := AL_RIGHT
 
There is no error, but it does not work.

Best regards
Last edited by Armando on Fri Nov 13, 2020 12:57 am, edited 1 time in total.
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
Marco Augusto
Posts: 122
Joined: Wed Oct 12, 2005 1:03 pm
Location: Cuernacava, Morelos Mexico

Re: To Mr. Rao, XBrowse totals

Post by Marco Augusto »

no hará falta el
:lfooter := .T.
Marco Augusto Rodriguez Manzo
fwh 2020 Xharbour 1.2.3
MySQL 5.0.19 Fastreport

PERZO SOFT
Sistemas Personalizados
User avatar
Armando
Posts: 2479
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Contact:

Re: To Mr. Rao, XBrowse totals

Post by Armando »

Hola Marco:

Que gusto saber de ti !

No, creo que no hace falta, tengo otra columna con totales y esos los pinta bien.

Ante el beneficio de la duda agregue esa línea y sigue sin funcionar.

Saludos
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
FranciscoA
Posts: 1964
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: To Mr. Rao, XBrowse totals

Post by FranciscoA »

Armando, intentalo asi: (cols 4,5)

Code: Select all

WITH OBJECT :aCols[ 05 ]
         :bEditValue := {|| IF( oRsDsl:RecordCount() > 0 .AND.   oRsDsl:Fields( "DIE_EOS" ):Value == "E",   oRsDsl:Fields( "DIE_LTS" ):Value, Space( 01 ) ) }
         :nFooterType      := AGGR_SUM
      END
Saludos.
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh1204-MySql-TMySql
User avatar
Armando
Posts: 2479
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Contact:

Re: To Mr. Rao, XBrowse totals

Post by Armando »

Francisco:

Excelente, ya me da los totales pero... no me respeta el picture del footer, solo para esa columna,
son enteros y le agrega dos decimales y no separa los cientos.

:cFooterPicture := "@Z 99,999"

Saludos y muy agradecido
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
FranciscoA
Posts: 1964
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: To Mr. Rao, XBrowse totals

Post by FranciscoA »

Code: Select all

:bEditValue := {|| IF( oRsDsl:RecordCount() > 0 .AND.   oRsDsl:Fields( "DIE_EOS" ):Value == "E",   oRsDsl:Fields( "DIE_LTS" ):Value, 0 ) }
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh1204-MySql-TMySql
User avatar
Armando
Posts: 2479
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Contact:

Re: To Mr. Rao, XBrowse totals

Post by Armando »

Francisco:

Excelente, Ahora todo va bien.

Saludos
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: To Mr. Rao, XBrowse totals (SOLVED)

Post by nageswaragunupudi »

COLUMNS clause accepts both field names and also expressions.
Please try:

Code: Select all

COLUMNS "DIE_FOL", "DIE_FDM", "DIE_REF", ;
        "IF(DIE_EOS=='E',DIE_LTS,0)", "IF(DIE_EOS=='S',DIE_LTS,0)",;
        "DIE_IMP","UNI_DES","OPE_NOM","DIE_DES", "DIE_CAN";
 
and remove completely:

Code: Select all

/*
      WITH OBJECT :aCols[ 04 ]
         :bStrData         := {|| IF( oRsDsl:RecordCount() > 0 .AND. ;
         oRsDsl:Fields( "DIE_EOS" ):Value == "E", ;
         Transform( oRsDsl:Fields( "DIE_LTS" ):Value, "@Z 9,999,999" ), Space( 01 ) ) }
         :nHeadStrAlign    := AL_RIGHT
      END

      WITH OBJECT :aCols[ 05 ]
         :bStrData         := {|| IF( oRsDsl:RecordCount() > 0 .AND. ;
         oRsDsl:Fields( "DIE_EOS" ):Value == "S", ;
         Transform( oRsDsl:Fields( "DIE_LTS" ):Value, "@Z 9,999,999" ), Space( 01 ) ) }
         :nHeadStrAlign    := AL_RIGHT
      END
*/
 
You may now add:

Code: Select all

:aCols[ 4 ]:nFooterType := AGGR_SUM
:aCols[ 5 ]:nFooterType := AGGR_SUM
 
Notes:
bStrData: Please never use bStrData. This data is deprecated years back. Instead use bEditValue and cEditPicture.
bStrData returns a character value. We can not expect XBrowse to total character values.

Alignment: XBrowse automatically aligns numeric and date values to right and other values to left. We need not specify alignment unless when we want a different alignment.
Regards

G. N. Rao.
Hyderabad, India
User avatar
Armando
Posts: 2479
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Contact:

Re: To Mr. Rao, XBrowse totals (SOLVED)

Post by Armando »

Mr. Rao:

Thank you very much.

Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
Post Reply