To Mr. Rao, XBrowse totals (SOLVED)

To Mr. Rao, XBrowse totals (SOLVED)

Postby Armando » Wed Nov 11, 2020 7:24 pm

Hi Mr. Rao:

Would you help us?

This is my code

Code: Select all  Expand view  RUN

   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  Expand view  RUN

         :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
User avatar
Armando
 
Posts: 3242
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: To Mr. Rao, XBrowse totals

Postby Marco Augusto » Thu Nov 12, 2020 1:35 pm

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

PERZO SOFT
Sistemas Personalizados
User avatar
Marco Augusto
 
Posts: 144
Joined: Wed Oct 12, 2005 1:03 pm
Location: Cuernacava, Morelos Mexico

Re: To Mr. Rao, XBrowse totals

Postby Armando » Thu Nov 12, 2020 1:43 pm

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
Armando
 
Posts: 3242
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: To Mr. Rao, XBrowse totals

Postby FranciscoA » Thu Nov 12, 2020 2:21 pm

Armando, intentalo asi: (cols 4,5)
Code: Select all  Expand view  RUN
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.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2159
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: To Mr. Rao, XBrowse totals

Postby Armando » Thu Nov 12, 2020 2:42 pm

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
Armando
 
Posts: 3242
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: To Mr. Rao, XBrowse totals

Postby FranciscoA » Thu Nov 12, 2020 2:55 pm

Code: Select all  Expand view  RUN
: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.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2159
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: To Mr. Rao, XBrowse totals

Postby Armando » Thu Nov 12, 2020 2:59 pm

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
Armando
 
Posts: 3242
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

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

Postby nageswaragunupudi » Sun Nov 15, 2020 4:02 pm

COLUMNS clause accepts both field names and also expressions.
Please try:
Code: Select all  Expand view  RUN

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  Expand view  RUN

/*
      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  Expand view  RUN

: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
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

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

Postby Armando » Sun Nov 15, 2020 4:27 pm

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
User avatar
Armando
 
Posts: 3242
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 93 guests

cron