Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to create report like this
Message
 
À
29/04/2007 05:07:35
Mk Sharma
Shrishti Solutions
Mumbai, Inde
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de rapports & Rapports
Divers
Thread ID:
01220872
Message ID:
01220873
Vues:
15
First, product, date and free are reserved keywords in VFP, so I am using a SQL alias for clarification
ldStartMonth	= DATE(2007,04,01) && Starting date for report... April
ldFromDate	= ldStartMonth	&& default from date as that starting report
*/ Build a clause for each month you want the report to show column across..
lcSQLFields	= ""
FOR lnI = 1 TO 3
	ldFromDate	= ldStartMonth
	ldEndDate	= GOMONTH( ldFromDate, 1 ) -1  && force to last day of the month
	lcSQLFields	= lcSQLFields;
				+ "'" + CMONTH( ldFromDate ) + "' as MonthHdr" + ALLTRIM( STR( lnI )) + ", ";
				+ SUM( IIF( BETWEEN( sls.date, ldFromDate, ldEndDate ), 1, 0 ) * sls.Free )) ";
				+ " as MonthFree" + ALLTRIM( STR( lnI )) + ", ";
				+ SUM( IIF( BETWEEN( sls.date, ldFromDate, ldEndDate ), 1, 0 ) * sls.Amt )) ";
				+ " as MonthAmt" + ALLTRIM( STR( lnI )) ;
				+ IIF( lnI = 3, "", ", " )   && no trailing comma if on last loop
ENDFOR 

select;
		sls.product,;
		&lcSQLFields ;
	FROM ;
		sales.dbf sls;
	GROUP BY ;
		sls.product;
	INTO ;
		CURSOR C_ReportResults
Now, your report can refer to the
MonthHdr1, MonthHdr2, MonthHdr3 to get your "April", "May", "June",
in your repor header lines, and next month would reflect "May", "June", "July", etc...
Your columns likewise would reflect the first, second and third months
based on what your start date was, so MonthFree1, MonthFree2, MonthFree3
and MonthAmt1, MonthAmt2, MonthAmt3 would be your column display values



>how i can create report like this :
>
>
>--------------------------------------------------------------------------------------
>|Product           |        April        |        May          |        June         |
>|                  |---------------------|---------------------|---------------------|
>|                  | Qty  | Free |Amount | Qty  | Free |Amount | Qty  | Free |Amount |
>--------------------------------------------------------------------------------------
>
>my dbf (sales.dbf) is like this :
>
>product c (30)
>date    d
>qty     n (10)
>free    n (10)
>amt     n(10,2)
>
>
>
>
>warm regards,
>mk.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform