Problema con xBrowse (SOLUCIONADO)

Problema con xBrowse (SOLUCIONADO)

Postby Armando » Wed Apr 27, 2022 3:13 pm

Hola Mr. Rao y foreros:

Tengo el siguiente código de un xBrowse:
Code: Select all  Expand view  RUN

            REDEFINE XBROWSE oBrw ID 200 OF oDlg;
                DATASOURCE oRsHdr;
                COLUMNS "HDR_FOL","HDR_CLI","CLI_NOM","HDR_CTD","","","HDR_SDO","HDR_CAN","HDR_MOT";
                COLSIZES 50,55,250,60,90,90,90,35,200;
                HEADERS "Folio","Empleado","Nombre del empleado","Cantidad","Contado","Credito","Adeudo","Can","Motivo de la cancelación";
                PICTURES "@Z 9999999","@Z 99999",NIL,"@Z 999","@Z 99,999.99","@Z 99,999.99","@Z 99,999.99",NIL,NIL;
                JUSTIFY {AL_RIGHT,AL_RIGHT,AL_LEFT,AL_RIGHT,AL_RIGHT,AL_RIGHT,AL_RIGHT,AL_CENTER,AL_LEFT};
                FOOTERS AUTOSORT
 


Las columnas 5 y 6 (Contado y credito respectivamente) las defino posteriormente así:

Code: Select all  Expand view  RUN

               WITH OBJECT :Contado
                        :bStrData           := { || IF(oRsHdr:RecordCount() > 0 .AND.;
                                                               oRsHdr:Fields("HDR_CLI"):Value = NIL,;
                                                               TRANSFORM(oRsHdr:Fields("HDR_TOT"):Value,"@Z 999,999.99"),SPACE(01))}
                        :nHeadStrAlign  := AL_RIGHT
                        :nFooterType    := AGGR_SUM
                        :bSumCondition  := { || ! oRsHdr:Fields("HDR_CAN"):Value }
                        :cFooterPicture := "@Z 99,999,999.99"
                        :nFootStrAlign   := AL_RIGHT
               END

               WITH OBJECT :Credito
                        :bStrData           := { || IF(oRsHdr:RecordCount() > 0 .AND.;
                                                                 oRsHdr:Fields("HDR_CLI"):Value > 0,;
                                                                 TRANSFORM(oRsHdr:Fields("HDR_TOT"):Value,"@Z 999,999.99"),SPACE(01))}
                        :nHeadStrAlign  := AL_RIGHT
                        :nFooterType    := AGGR_SUM
                        :bSumCondition  := { || ! oRsHdr:Fields("HDR_CAN"):Value }
                        :cFooterPicture := "@Z 99,999,999.99"
                        :nFootStrAlign   := AL_RIGHT
               END
 


Aunque tengo definido obtener la suma en ambas columnas, no se muestra el total.

Alguna pista?

Saludos
Last edited by Armando on Tue May 03, 2022 2:00 pm, 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: Problema con xBrowse

Postby cmsoft » Wed Apr 27, 2022 4:10 pm

Armando:
Prueba con .
Code: Select all  Expand view  RUN
:Value( IF(oRsHdr:RecordCount() > 0 .AND.  oRsHdr:Fields("HDR_CLI"):Value = NIL,;
                                                               oRsHdr:Fields("HDR_TOT"):Value,0)}
User avatar
cmsoft
 
Posts: 1293
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Problema con xBrowse

Postby Armando » Wed Apr 27, 2022 4:38 pm

César:

Gracias por el consejo, pero no sigue sin pintar los totales al pie de xBrowse.
Será que no entendí?

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: Problema con xBrowse

Postby cmsoft » Wed Apr 27, 2022 7:29 pm

Armando, en algun momento haces oBrw:MakeTotals() ? No lo veo en el código que pasaste, tal vez está mas abajo en tu código
User avatar
cmsoft
 
Posts: 1293
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Problema con xBrowse

Postby Armando » Wed Apr 27, 2022 7:48 pm

César:

Sí, lo tengo más abajo, solo que no lo mostré en el trozo de código anterior

Code: Select all  Expand view  RUN

         :MakeTotals()
    END
 


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: Problema con xBrowse

Postby nageswaragunupudi » Fri Apr 29, 2022 10:53 am

Code: Select all  Expand view  RUN
  REDEFINE XBROWSE oBrw ID 200 OF oDlg;
       DATASOURCE oRsHdr;
       COLUMNS "HDR_FOL","HDR_CLI","CLI_NOM","HDR_CTD", ;
       "IF(EMPTY(HDR_CLI),HDR_TOT,0.00)", ;
       "IF(EMPTY(HDR_CLI),0.00,HDR_TOT)", ;
       "HDR_SDO","HDR_CAN","HDR_MOT";
       COLSIZES 50,55,250,60,90,90,90,35,200;
       HEADERS "Folio","Empleado","Nombre del empleado","Cantidad","Contado","Credito","Adeudo","Can","Motivo de la cancelación";
       PICTURES "9999999","99999",NIL,"999","999,999.99","999,999.99","99,999.99",NIL,NIL;
       FOOTERS AUTOSORT
   

   WITH OBJECT oBrw
      :lDsplayZeros     := .f.  // No need for "@Z " picture clause
      WITH OBJECT :Contado
         :nFooterType    := AGGR_SUM
         :bSumCondition  := { || ! oBrw:Can:Value }  // CHECK  THIS LINE
      END

      WITH OBJECT :Credito
         :nFooterType    := AGGR_SUM
         :bSumCondition  := { || ! oBrw:Can:Value }  // CHECK THIS LINE
      END
      :MakeTotals()
      //
      :CreateFromCode()            
   END                                                                
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Problema con xBrowse

Postby Armando » Fri Apr 29, 2022 4:03 pm

Mr Rao:

I'm afraid your advise does not work because don't show the values, here is my full code

Code: Select all  Expand view  RUN

            REDEFINE XBROWSE oBrw ID 200 OF oDlg;
            DATASOURCE oRsHdr;
                COLUMNS "HDR_FOL",;
                  "HDR_CLI",;
                  "CLI_NOM",;
                  "HDR_CTD",;
                  "IF(EMPTY(HDR_CLI),HDR_TOT,0.00)", ;
                  "IF(EMPTY(HDR_CLI),0.00,HDR_TOT)", ;
                  "HDR_SDO",;
                  "HDR_CAN",;
                  "HDR_MOT";
            COLSIZES 50,55,250,60,90,90,90,35,200;
                HEADERS "Folio","Empleado","Nombre del empleado","Cantidad","Contado","Credito","Adeudo","Can","Motivo de la cancelación";
            PICTURES "@Z 9999999","@Z 99999",NIL,"@Z 999","@Z 99,999.99","@Z 99,999.99","@Z 99,999.99",NIL,NIL;
            JUSTIFY {AL_RIGHT,AL_RIGHT,AL_LEFT,AL_RIGHT,AL_RIGHT,AL_RIGHT,AL_RIGHT,AL_CENTER,AL_LEFT};
                FOOTERS AUTOSORT

            oBrw:lDisplayZeros := (.F.)

                WITH OBJECT oBrw
                    :l2007            := (.F.)
                    :lHScroll         := (.F.)
                    :lVScroll         := (.F.)
                    :nMarqueeStyle    := MARQSTYLE_HIGHLROW
                    :nColDividerStyle := LINESTYLE_LIGHTGRAY
                    :nRowDividerStyle := LINESTYLE_LIGHTGRAY
                :SetGroupHeader( "I M P O R T E S",05,06 )
                    :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.)

                    WITH OBJECT :aCols[01]
                        :cOrder := "A"
                    END

               WITH OBJECT :Cantidad
                  :nFootStrAlign  := AL_RIGHT
                  :bFooter        := { || "Totales =>" }
               END

               WITH OBJECT :Contado
                        :nHeadStrAlign  := AL_RIGHT
                  :nFooterType    := AGGR_SUM
                  :bSumCondition  := { || ! oBrw:Can:Value }  // CHECK  THIS LINE
                  :nFootStrAlign  := AL_RIGHT
                  :cFooterPicture:= "@Z 99,999,999.99"
                    END


               WITH OBJECT :Credito
                        :nHeadStrAlign  := AL_RIGHT
                  :nFooterType    := AGGR_SUM
                  :bSumCondition  := { || ! oBrw:Can:Value }  // CHECK  THIS LINE
                  :cFooterPicture := "@Z 99,999,999.99"
                        :nFootStrAlign   := AL_RIGHT
                    END

               WITH OBJECT :Adeudo
                        :nHeadStrAlign   := AL_RIGHT
                  :nFooterType    := AGGR_SUM
                  :bSumCondition  := { || ! oBrw:Can:Value }  // CHECK  THIS LINE
                  :cFooterPicture := "@Z 99,999,999.99"
                        :nFootStrAlign   := AL_RIGHT
               END

               WITH OBJECT :Can
                  :SetCheck( { "SI16","NO16" } )
               END

               :MakeTotals()
//               :CreateFromCode()     // This line makes an error DUPLICATED ID 140
                END
 


BTW, the HDR_CLI field is a NULL field type, some records has a null value, some records has a number value.

Image

With best 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

Re: Problema con xBrowse

Postby nageswaragunupudi » Sat Apr 30, 2022 4:40 am

BTW, the HDR_CLI field is a NULL field type, some records has a null value, some records has a number value.

That is the reason, we used Empty()

XBrowse internally translates the expression "IF(EMPTY(HDR_CLI),HDR_TOT,0.00)" into a codeblock like this and assigns to oCol:bEditValue

Code: Select all  Expand view  RUN

:bEditValue := { |x,oCol| If( Empty( oCol:oBrw:oRs:Fields( "HDR_CLI" ):Value ) ), ;
oCol:oBrw:oRs:Fields( "HDR_TOT" ):Value, 0.00 ) }
 


Please never use bStrData. Deprecated many years ago.
The codebock evaluates to a Character Value, which XBrowse faithfully displays in the Cell.
XBrowse uses a numeric value returned by oCol:bEditValue for internal calculations and totals.

I do not have access to your tables are its contents.

I am providing a sample implementing a similar solution with 'customer' table on the FWH provided MSSQL cloud server. We can all use this server to post examples and problems.

Sample program:
Code: Select all  Expand view  RUN
#include "fivewin.ch"

function Main()

   local oCn, oRs, oDlg, oFont, oBrw

   oCn   := FW_MSSQLDB()  // FWH MSSQL Cloud server
   oRs   := FW_OpenRecordSet( oCn, "customer" )

   FWNumFormat( "A", .t. )

   DEFINE FONT oFont NAME "Segoe UI" SIZE 0,-16
   DEFINE DIALOG oDlg SIZE 600,400 PIXEL TRUEPIXEL FONT oFont

   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oRs ;
      COLUMNS "First", "Married", ;
         "IF(EMPTY(MARRIED),SALARY,0) AS M_Salary PICT '9,999,999.99'", ;
         "IF(EMPTY(MARRIED),0,SALARY) AS S_Salary PICT '9,999,999.99'", ;
         "Age" ;
      FOOTERS LINES NOBORDER

   WITH OBJECT oBrw
      :SetChecks( nil, .t.  )
      :lDisplayZeros    := .f.
      :nStretchCol      :=  STRETCHCOL_WIDEST
      :SetGroupHeader( "SALARY", 3, 4 )
      :M_Salary:nFooterType := AGGR_SUM
      :S_Salary:nFooterType := AGGR_SUM
      :MakeTotals()
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED

   oRs:Close()
   oCn:Close()

return nil
 


Image

Please copy the program to your fwh\samples folder and build and run with buildh.bat or buildx.bat without any changes and you will see it working the expected way. If this sample works, please check your table, table contents and your program. It should also work.

-------------
Please check if all values of HDR_TOT in all the above 6 rows are Empty.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Problema con xBrowse

Postby nageswaragunupudi » Sat Apr 30, 2022 8:19 am

We created a small table with the data appearing in the screen shot you provided on the demo server.
Prepared a similar program with exactly the same logic used in your program.

Sample:
Code: Select all  Expand view  RUN
#include "fivewin.ch"

function Main()

   local oCn, oRs, oDlg, oFont, oBrw

   FWNumFormat( "A", .t. )

   oCn   := FW_MSSQLDB()
   oRs   := FW_OpenRecordSet( oCn, "arm_hdr" )
   XBROWSER oRs SETUP ( oBrw:lDisplayZeros := .f. )

   DEFINE FONT oFont NAME "Segoe UI" SIZE 0,-13
   DEFINE DIALOG oDlg SIZE 920,350 PIXEL TRUEPIXEL FONT oFont

   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oRs ;
      COLUMNS "HDR_FOL","HDR_CLI","CLI_NOM","HDR_CTD", ;
       "IF(EMPTY(HDR_CLI),HDR_TOT,0.00)", ;
       "IF(EMPTY(HDR_CLI),0.00,HDR_TOT)", ;
       "HDR_SDO","HDR_CAN","HDR_MOT";
       COLSIZES 50,55,250,60,90,90,90,35,200;
       HEADERS "Folio","Empleado","Nombre del empleado","Cantidad",;
         "Contado","Credito","Adeudo","Can","Motivo de la cancelación";
       PICTURES "9999999","99999",NIL,"999","99,999.99","99,999.99","99,999.99" ;
       FOOTERS LINES AUTOSORT NOBORDER

   WITH OBJECT oBrw
      :SetChecks( nil, .t.  )
      :lDisplayZeros    := .f.
      :nStretchCol      :=  STRETCHCOL_WIDEST
      :SetGroupHeader( "I M P O R T E S",05,06  )
      WITH OBJECT :Contado
         :nFooterType := AGGR_SUM
         :bSumCondition := { || !oBrw:Can:Value }
      END
      WITH OBJECT :Credito
         :nFooterType := AGGR_SUM
         :bSumCondition := { || !oBrw:Can:Value }
      END
      :MakeTotals()
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED

   oRs:Close()
   oCn:Close()

return nil
 


Raw contents of the table:
Image

Browse the way you wanted with our code:
Image

Please build and run this program in fwh\samples folder, without any changes.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Problema con xBrowse

Postby Armando » Mon May 02, 2022 11:50 pm

Mr. Rao:

May I see the structure of your table?.

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

Re: Problema con xBrowse

Postby nageswaragunupudi » Tue May 03, 2022 6:32 am

Did you copy the program to your fwh\samples folder, build and run it?

Then you know the table is not hidden from you. This is not on my personal server here.
You are connected to the server. You have full access to this table and all other tables on this cloud server.
You can query the table yourself and find out any information you want.

Anyway, if you see the screenshot of the Raw XBrowse of the table we can see:
Code: Select all  Expand view  RUN
HDR_FOL,HDR_CLI,HDR_CTD, HDR_TOT : NUMERIC
HDR_CAN : BOOLEAN
CLI_NOM,HDR_MOT : VARCHAR
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Problema con xBrowse

Postby Armando » Tue May 03, 2022 2:00 pm

Mr. Rao and friends.

The problem is solved, thanks Mr. Rao.

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 para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 96 guests