Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Summary report of data group
Message
From
03/03/2005 09:35:08
 
 
To
02/03/2005 20:29:38
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00991871
Message ID:
00992383
Views:
22
I'm sure there is a much better way but below is a simple example:

*************************************************************************
Create a report named 'test' with the following fields in the detail band:

cproduct (printwhen condition ltotal = .f. and remove line if blank)
nqty (printwhen condition ltotal = .f. and remove line if blank)

arrange them next to each other in column format like so:

cproduct nqty

Overlap the next field ON TOP of the cproduct field:

Totals:

and set its printwhen condition to lheading = .T. and remove line if blank

Add the next two fields directly below the cproduct and nqty fields you already added:

cproduct ntotal

Set both of the above two fields printwhen condition to: ltotal = .T.
and check remove line if blank

Run the code below.
*--Sample only
SET EXACT ON
SET SAFETY OFF
RELEASE tarray
*--Create the table to store the product quantities
*--This similates your select statement
CREATE TABLE test (cproduct c(15), nqty N(3,0))
nval = 1
FOR i = 1 TO 10
   m.cproduct = "PRODUCT_"+ALLTRIM(STR(nval))
   m.nqty = nval
   nval = nval + 1
   SELE test
   APPEND BLANK
   GATHER MEMVAR
ENDFOR
nval = 1
nqty = 2
FOR i = 1 TO 10
   m.cproduct = "PRODUCT_"+ALLTRIM(STR(nval))
   m.nqty = nqty
   nval = nval + 1
   nqty = nqty + 1
   SELE test
   APPEND BLANK
   GATHER MEMVAR
ENDFOR
*--Add the fields to store the totals for each product 
ALTER TABLE test ADD COLUMN ltotal L
ALTER TABLE test ADD COLUMN ntotal N(10,0)
ALTER TABLE test ADD COLUMN lheading L

*--Store the totals to a temporary array
DIMENSION tarray(1,2)
GO TOP
SCAN
   IF TYPE('tarray(1,1)')="L"
      tarray(1,1) = ALLTRIM(UPPER(test.cproduct))
      tarray(1,2) = test.nqty
   ELSE
      lpos = ASCAN(tarray,ALLTRIM(UPPER(test.cproduct)))
      IF lpos = 0
         DIMENSION tarray(ALEN(tarray,1)+1,2)
         tarray(ALEN(tarray,1),1) = ALLTRIM(UPPER(test.cproduct))
         tarray(ALEN(tarray,1),2) = test.nqty
      ELSE
         tarray(lpos+1) = tarray(lpos+1)+test.nqty
      ENDIF
   ENDIF
ENDSCAN
*--Add the totals as records at the end of the table
FOR i = 1 TO ALEN(tarray,1)
   SELE test
   APPEND BLANK
   IF i = 1
      *--This is the first total, need to print heading TOTALS:
      REPLACE lheading WITH .T.
   ENDIF
   REPLACE ltotal WITH .T.
   REPLACE test.cproduct WITH tarray(i,1)
   REPLACE test.ntotal WITH tarray(i,2)
ENDFOR
GO top
REPORT FORM test preview
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform