To Mr Rao HELP FOR DBEVAL function

Post Reply
User avatar
Eoeo
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm

To Mr Rao HELP FOR DBEVAL function

Post by Eoeo »

I wish add on array the total of categories for month to show them into a xbrowser

I made before :

Function Test
Local aEntrate :={}
Local aEnt :={}
Local aData :={}
Local aCanE :={ { "Gen", 0 }, { "Feb", 0 }, { "Mar", 0 }, { "Apr", 0 }, ;
{ "Mag", 0 }, { "Giu", 0 }, { "Lug", 0 }, { "Ago", 0 }, ;
{ "Set", 0 }, { "Oct", 0 }, { "Nov", 0 }, { "Dic", 0 } }

USE ENTRATE ALIAS EN
EN->(DbGoTop())


//Save all names all categories if empty add a new category noname

DO WHILE ! EN->(Eof())
Aadd(aEntrate, IIF (EMPTY(EN->DESCR),"Noname",EN->DESCR) )
EN->(DbSkip())
ENDDO


// add on array for mounth the imptotal if Apcatingr is = aEntrate

USE MOVIMENTI ALIAS MV

MV->( DBEVAL( { || aCanE[ Month( FIELD->APFECHA ) ][ 2 ]+= IIF( FIELD->APCATINGR=aEntrate, MV->APIMPTOTAL,0) } ) )



How I can make to found FIELD->APCATINGR= for each aEntrate description and insert it on dbeval ?




I tried with

Code: Select all

#include "fivewin.ch"
#include "xbrowse.ch"



Function Test

        Local aEntrate :={}
        Local aEnt :={}
        Local aData :={}

        Local aCanE :={ { "Gen", 0 }, { "Feb", 0 }, { "Mar", 0 }, { "Apr", 0 }, ;
                 { "Mag", 0 }, { "Giu", 0 }, { "Lug", 0 }, { "Ago", 0 }, ;
                 { "Set", 0 }, { "Oct", 0 }, { "Nov", 0 }, { "Dic", 0 }  }


USE ENTRATE ALIAS EN
EN->(DbGoTop())


//Save all names all categories  if empty add a new category noname

 DO WHILE ! EN->(Eof())
       Aadd(aEntrate, IIF (EMPTY(EN->DESCR),"Categoria senza nome",EN->DESCR) )
       EN->(DbSkip())
     ENDDO


 // add on array   for mounth   the imptotal if Apcatingr is  = aEntrate

     USE MOVIMENTI ALIAS MV

          For n=1 to len( aEntrate)

   MV->( DBEVAL( { || aCanE[ Month( FIELD->APFECHA ) ][ 2 ]+= IIF( FIELD->APCATINGR=aEntrate[n], MV->APIMPTOTAL,0) } ) )
         next



       For n=1 to len( aEntrate)


          AAdd( aData, {aEntrate[n], aCanE[1][2],aCanE[2][2],aCanE[3][2],aCanE[4][2] ,aCanE[5][2] ,aCanE[6][2] ,aCanE[7][2],aCanE[8][2],;
       aCanE[9][2] ,aCanE[10][2] ,aCanE[11][2] ,aCanE[12][2],"D"  } )


      next



          DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
          DEFINE DIALOG oDlg SIZE 700,300 PIXEL FONT oFont

            @ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
            HEADERS  'Voci', 'Gen','Feb','Mar','Apr','Mag','Giu','Lug','Ago','Set','Ott','Nov','Dic','Grafico';
            ARRAY aData  AUTOCOLS

        WITH OBJECT oBrw
      //
      :CreateFromCode()
   END



   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont



return nil

the dialog is good but perhaps the dbeval is wrong because I not have the totals I show on xbrowse

Image


Making a total with the hand I have ( on my archive) another totals :

Ingresos extraordinarios on mounth of May only 266,80
Nómina on mouth of May only 1000,00 and on mounth of Nov only 1000,00
Venta no totals
User avatar
Eoeo
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm

Re: To Mr Rao HELP FOR DBEVAL function

Post by Eoeo »

I understood I need a multiple array and Ihave only aEntrate[n] where I can see the list of categories

and for each aEntrate[n]] I have this array

aCanE :={ { "Gen", 0 }, { "Feb", 0 }, { "Mar", 0 }, { "Apr", 0 }, { "Mag", 0 }, { "Giu", 0 }, { "Lug", 0 }, { "Ago", 0 }, { "Set", 0 }, { "Oct", 0 }, { "Nov", 0 }, { "Dic", 0 } }

but it is for one record

and on xbrowse this array is copied for each aEntrate[n]

How I can create an array have this aCanE multiple ?
User avatar
Eoeo
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm

Re: To Mr Rao HELP FOR DBEVAL function

Post by Eoeo »

Help Help Help any solution ?
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: To Mr Rao HELP FOR DBEVAL function

Post by nageswaragunupudi »

Code: Select all

USE ENTRATE ALIAS EN

aData    := {}

do while ! MV->( eof() )
   nAt   := AScan( aData, { |a| a[ 1 ] == MV->APCATINGR } )
   if nAt == 0
      AAdd( aData, { MV->APCATINGR, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'D' } )
      nAt   := Len( aData )
   endif
   aData[ nAt, Month( MV->APFECHA ) ]  += MV->APIMPTOTAL 
   MV->( DbSkip( 1 ) )
enddo

EN->( DBCLOSEAREA() )

XBROWSER aData ;
SETUP oBrw:cHeaders := { "Voci", "Gen", "Feb", "Mar", "Apr", "Mag", "Giu", "Lug", "Ago", "Set", "Ott", "Nov", "Dic", "Grafico" }

 
Regards

G. N. Rao.
Hyderabad, India
User avatar
Eoeo
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm

Re: To Mr Rao HELP FOR DBEVAL function

Post by Eoeo »

THANKS Rao but I have the problem it show when not found the name of a category with emty record

and I'll wish insert a description as "noname category"

the name of category is on entrate.dbf while your code search the category on MV


I made an array with names of categories aEntrate

and I made a new record on this aEntrate call noname

nTot:=0
nCan:=0
I := 1
nSum := 0
nSumN:=0

nNext:=len(aUscite)+1
nNextE:=len(aEnt)+1
asize(aUscite,nNext)
asize(aEnt,nNextE)

aUscite[nNext]:="NoName"
aEnt[nNextE]:= nSumN








modified AAdd( aData, { IIF(EMPTY(MV->APCATINGR),"Noname",MV->APCATINGR), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'D' } )


Image


it show for many records noname and I wish show one record noname
Post Reply