oBrw:report() still need help..

oBrw:report() still need help..

Postby hag » Wed Sep 17, 2008 5:26 pm

The oBrw:report() needs to end the printing at the point where the filter ends the display of data.

The record count is governing the number of pages to print when it should be the filter. Therefore I get 5 extra pages of print. They each have headers but no data.
Ive had help from James, Rao and others and we all seem to agree that the report() should respect the filter.

Can't get the class to respect the filter only works with the record count.

Help.
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Postby Antonio Linares » Wed Sep 17, 2008 8:03 pm

Harvey,

Are you using a filter or OrdSetScope() ?

For a large database, OrdSetScope() should be used. Filters are slow.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby hag » Wed Sep 17, 2008 8:58 pm

Antonio:
You said:
Are you using a filter or OrdSetScope() ?

For a large database, OrdSetScope() should be used. Filters are slow[code


using a filter and the data base is 540 records, small. The filter stops about halfway down the data base. But printing keeps going.

Why the comment regarding speed? Its the printing of extra pages is the problem. Have no speed issue.
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Postby Antonio Linares » Wed Sep 17, 2008 9:45 pm

Harvey,

You have no problems with the speed because you are managing a small amount of records, but if you use a DBF with thousands records, then you will see what I mean :-)

Is the browse accessing the same workarea where the filter is set ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby James Bott » Wed Sep 17, 2008 9:45 pm

Harvey,

>Why the comment regarding speed? Its the printing of extra pages is the problem. Have no speed issue.

He is saying that scopes are much faster than filters and xBrowse:Report works with scopes.

I asked before if you knew about scopes? If not, perhaps you can use scopes instead of filters. Exactly how are you filtering the database? Can we see the code that sets the filter?

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby hag » Wed Sep 17, 2008 9:51 pm

Thanks James:
I now understand. I'm not familiar with scopes. Here are the filters under separate conditions.



Code: Select all  Expand view  RUN
if mquick == 1    
      gl->(dbseek("3599"))
      gl->ty13 := 1



      // SCHEDULES

      * set filter to .Not. Ty13 = 0  .And. .NOT. Account = "3601";
      * .And. .Not. Account   = "0100" .And. .Not. Account  = "0125" ;
      * .And. .Not. Account   = "0150" .And. .Not. Account  = "0175" ;
      * .And. .Not. (Account >= "2055" .And.  Account <= "2495") ;
      * .And. .Not. (Account >= "2510" .And.  Account <= "3352") ;
      * .And. .Not. (Account >= "3354" .And.  Account <= "3478") ;
      * .And. .Not. (Account >= "3482" .And.  Account <= "3543") ;
      * .And. .Not.  Account  = "3800"                                         ;
      * .And. .Not.  Account >  "5999"
      * skip
      * skip -1

      // ADD NEW 5 DEPTS.

      set filter to .Not. Ty13 = 0  .And. .NOT. Account = "3601";
      .And. .Not. Account   = "0100" .And. .Not. Account  = "0125" ;
      .And. .Not. Account   = "0150" .And. .Not. Account  = "0175" ;
      .And. .Not. (Account >= "2055" .And.  Account <= "2495") ;
      .And. .Not. (Account >= "2510" .And.  Account <= "2620") ;
      .And. .Not. (Account >= "2630" .And.  Account <= "2710") ;
      .And. .Not. (Account >= "2730" .And.  Account <= "2810") ;
      .And. .Not. (Account >= "2830" .And.  Account <= "2910") ;       
      .And. .Not. (Account >= "2930" .And.  Account <= "2995") ;       
      .And. .Not.  Account  = "3800"                                         ;
      .And. .Not. (Account >= "2997" .And.  Account <= "3352") ;       
      .And. .Not. (Account >= "3354" .And.  Account <= "3478") ;
      .And. .Not. (Account >= "3482" .And.  Account <= "3543") ;
      .And. .Not.  Account  = "3800"                                         ;
      .And. .Not.  Account >  "5999"
      skip
      skip -1

   endif

   if mquick == 2

      gl->(dbseek("3599"))
      gl->ty13 := 1

      // PUT LINES AT THE BOTTOM OF EACH DEPT TOTAL
      gl->(dbseek("3353"))
      if gl->ty13 <> 0
         gl->(dbseek("3352"))
         gl->ty13 := 1
         gl->(dbseek("3354"))
         gl->ty13 := 1
      endif

      gl->(dbseek("3544"))
      if gl->ty13 <> 0
         gl->(dbseek("3543"))
         gl->ty13 := 1
         gl->(dbseek("3545"))
         gl->ty13 := 1
      endif

      gl->(dbseek("3480"))
      if gl->ty13 <> 0
         gl->(dbseek("3478"))
         gl->ty13 := 1
         gl->(dbseek("3482"))
         gl->ty13 := 1
      endif

      gl->(dbseek("2500"))
      if gl->ty13 <> 0
         gl->(dbseek("2495"))
         gl->ty13 := 1
         gl->(dbseek("2510"))
         gl->ty13 := 1
      endif


      set filter to .Not. Ty13 = 0   .And. .NOT.  Account = "3601" ;
      .And. .Not. Account   = "0100" .And. .Not. Account = "0125"   ;
      .And. .Not. Account   = "0150" .And. .Not. Account = "0175"   ;
      .And. .Not. (Account >= "1000" .And.  Account <= "2050") ;
      .And. .Not. (Account >= "3600" .And.  Account <= "5999")
      skip
      skip -1
   endif         

   if mquick == 3   

      // 8/30/99
      // GET RID OF LINE TOTAL EXPENSES IF ONLY DEFAULT DEP BEING USED   

      mTest := 0   

      gl->(dbseek("2500"))
      mtest :=   gl->ty13 + mtest

      gl->(dbseek("3480"))
      mtest :=   gl->ty13 + mtest

      gl->(dbseek("3544"))
      mtest :=   gl->ty13 + mtest

      // FILTER 3600 AND EXTRA LINE

      if mtest == 0       

         expcf->(dbseek("z              Total"))
         if expcf->usepercomp == .T.    // FLAGS USING PERCENT COMPLETE

            gl->(dbseek("2040"))
            gl->title := "Job costs"   

            gl->(dbgotop())
            select gl
            set filter to .Not. Ty13 = 0 .And. .NOT.  Account = "3601"   ;
            .And. .Not. Account      = "0100" .And. .Not. Account = "0125"    ;
            .And. .Not. Account      = "0150" .And. .Not. Account = "0175"    ;
            .And. .Not. (Account    >= "2010".and. Account <= "2038") ;
            .And. .Not. Account = "3600"  ;
            .And. .Not. Account = "3602"  ;
            .And. .Not. Account > "5999"

            skip
            skip -1

         else
            set filter to .Not. Ty13 = 0 .And. .NOT.  Account = "3601";
            .And. .Not. Account = "0100" .And. .Not. Account = "0125" ;
            .And. .Not. Account = "0150" .And. .Not. Account = "0175" ;
            .And. .Not. (Account >= "2004".and. Account <= "2008") ;
            .And. .Not. Account = "3600"  ;
            .And. .Not. Account = "3602"  ;
            .And. .Not. Account > "5999"
            skip
            skip -1
         endif
      else

         expcf->(dbseek("z              Total"))
         if expcf->usepercomp == .T.    // FLAGS USING PERCENT COMPLETE

            gl->(dbseek("2040"))
            gl->title := "Job costs"   

            gl->(dbgotop())
            select gl
            set filter to .Not. Ty13 = 0 .And. .NOT.  Account = "3601"   ;
            .And. .Not. Account      = "0100" .And. .Not. Account = "0125"    ;
            .And. .Not. Account      = "0150" .And. .Not. Account = "0175"    ;
            .And. .Not. (Account    >= "2010".and. Account <= "2038") ;
            .And. .Not. Account     >  "5999"

            skip
            skip -1
         else
            set filter to .Not. Ty13 = 0 .And. .NOT.  Account = "3601";
            .And. .Not. Account = "0100" .And. .Not. Account = "0125" ;
            .And. .Not. Account = "0150" .And. .Not. Account = "0175" ;
            .And. .Not. (Account >= "2004".and. Account <= "2008") ;
            .And. .Not. Account > "5999"
            skip
            skip -1
         endif
      endif
   endif
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Postby James Bott » Wed Sep 17, 2008 9:59 pm

Harvey,

OK, scopes are not going to work for you--you have some of the most complex filters I have ever seen.

The fastest solution for you is to just write your own report using TReport. You can probably do this in 15 mintues or so.

Granted, it would be nice to modify TXBrwose so it supports filters, but if you need a quick solution, I suggest your own report. It also gives you more flexibility to design the report anyway you wish.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby hag » Wed Sep 17, 2008 10:06 pm

James:

Can't write anything in 15 min. Can you give me a little bit more on what your suggesting. Writing my own function and using TReport as a starting point?
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Postby Antonio Linares » Wed Sep 17, 2008 10:27 pm

Harvey, James,

If the filter is set on the same workarea as the used by the browse, then the report should respect the filter.

Harvey, please try this:

MsgInfo( Alias() )

MsgInfo( oBrowse:cAlias )

Please check that you are working in the same workarea.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby James Bott » Wed Sep 17, 2008 10:34 pm

Harvey,

Just call your report from the same menu or button you are now using for xbrowse:Report(). Here is an example:

Regards,
James

Code: Select all  Expand view  RUN
// Sample FW Report
function myReport()
local oReport
local cTitle:="Sample Report"
local oCust:= tdata():new(,"arcust")
oCust:use()

REPORT oReport;
  TITLE cTitle," ";
  HEADER dtoc(date()),time(),;
    "Page "+ltrim(str(oReport:nPage)) RIGHT;
  CAPTION cTitle;
  PREVIEW

   COLUMN TITLE "St"    DATA oCust:state
   COLUMN TITLE "First Name" DATA oCust:first
   COLUMN TITLE "   Salary"  DATA oCust:salary total

   oReport:bSkip:= { | nRecs | oCust:skip( nRecs ) }
   oReport:lJoin:=.t.

ENDREPORT

activate report oReport while ! oCust:eof()

oCust:end()

return nil
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby James Bott » Wed Sep 17, 2008 10:37 pm

Antonio,

>If the filter is set on the same workarea as the used by the browse, then the report should respect the filter.

Sorry, it does not handle filters. It is relying on ordkeycount() to tell it when it has printed all the records and ordKeyCount() doesn't respect filters.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby hag » Wed Sep 17, 2008 11:18 pm

James I'll give it a shot. Email later this evening and let you know. Thanks for all the help.
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Postby James Bott » Wed Sep 17, 2008 11:57 pm

Harvey,

I noticed in my sample report function that it is not saving and restoring the database state--and it should. Whenever you manipulate an open database in a function you should save and restore it's state as a matter of good programming practice. This will eliminate a lot of bugs.

At the top of the function save the workarea and recno, then at the end of the function restore them. If you change anything else like an index order, you should also save and restore that.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby James Bott » Thu Sep 18, 2008 12:05 am

Harvey,

I also noticed that my sample is for my own TData so it won't work for you. Here is one that works without a database object.

Later we should discuss the merits of database objects. You can read about them on my website here:

http://ourworld.compuserve.com/homepage ... rogram.htm

Regards,
James


Code: Select all  Expand view  RUN
// Sample FW Report
function myReport(cAlias)
   local oReport
   local cTitle:="Sample Report"
   local nArea: select()
   local nRecno:= 0
   
   select (cAlias)
   nRecno:= recno()
   
   go top
   
   REPORT oReport;
     TITLE cTitle," ";
     HEADER dtoc(date()),time(),;
       "Page "+ltrim(str(oReport:nPage)) RIGHT;
     CAPTION cTitle;
     PREVIEW
   
      COLUMN TITLE "St"    DATA state
      COLUMN TITLE "First Name" DATA first
      COLUMN TITLE "   Salary"  DATA salary total
   
      oReport:bSkip:= { | nRecs | dbskip( nRecs ) }
      oReport:lJoin:=.t.
   
   ENDREPORT
   
   activate report oReport while ! eof()
   
   select( nArea )
   go to nRecno
   
return nil
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Antonio Linares » Thu Sep 18, 2008 12:06 am

James,

> It is relying on ordkeycount() to tell it when it has printed all the records and ordKeyCount() doesn't respect filters.

yes, you are right.

It looks as he should use OrdSetScope() instead of filters.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 42 guests