Report Generator

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
sudip
Posts: 1456
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Report Generator

Post by sudip »

Hello,

Sorry for my ignorance.

1) What's the unit used in Report Generator for row, col, height and width?

2) How can I print Group wise Sub Total in reports?


If these questions were already answered, it will be great helpful to me if you please show the link :)

Thanks in advance.

With best regards.

Sudip
With best regards,
Sudip
User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Report Generator

Post by Rathinagiri »

I think the unit used is mm as always.

Regarding sub-total if you can please give a sample data and report format, I think Roberto can answer this.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
sudip
Posts: 1456
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: Report Generator

Post by sudip »

rathinagiri wrote:I think the unit used is mm as always.

Regarding sub-total if you can please give a sample data and report format, I think Roberto can answer this.
A good example will be \HMG\samples\REPORT.ADVANCED\Demo4.prg, where I want to print sub total of each country.

With best regards.

Sudip
With best regards,
Sudip
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
Joined: Wed Jul 30, 2008 6:43 pm

Re: Report Generator

Post by Roberto Lopez »

sudip wrote:Hello,

Sorry for my ignorance.

1) What's the unit used in Report Generator for row, col, height and width?

2) How can I print Group wise Sub Total in reports?


If these questions were already answered, it will be great helpful to me if you please show the link :)

Thanks in advance.

With best regards.

Sudip
Units are mm (I love metric system:) ).

The sample \hmg\report.advanced.3 is a good sample on groups use. Anyway this sample do not calculate sub-totals, but if you use ITERATOR clause, you can easily do your calculations there.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
sudip
Posts: 1456
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: Report Generator

Post by sudip »

Hello Master Roberto,
Thanks a lot.
Today I created a test report as follows:
StkBal.jpg
StkBal.jpg (27.92 KiB) Viewed 4178 times
Here I use an array, aData. Rmg file is as follows:

Code: Select all

DEFINE REPORT TEMPLATE

	* Report Data Environment *************************************

	BEGIN DATA
		ITERATOR	i++
		STOPPER		i == len(aData)
	END DATA

	* Report Layout ***********************************************

	BEGIN LAYOUT 
		PAPERSIZE	PRINTER_PAPER_A4
		ORIENTATION	PRINTER_ORIENT_PORTRAIT 
	END LAYOUT

	* Header Band *************************************************

	BEGIN HEADER

		BANDHEIGHT	37

		BEGIN LINE
			FROMROW		23
			FROMCOL		10
			TOROW		23
			TOCOL		200
			PENWIDTH	0.1
			PENCOLOR	{ 0 , 0 , 0 }
		END LINE

		BEGIN LINE
			FROMROW		35
			FROMCOL		10
			TOROW		35
			TOCOL		200
			PENWIDTH	0.1
			PENCOLOR	{ 0 , 0 , 0 }
		END LINE
		
		BEGIN TEXT
			EXPRESSION	'Stock Balance '+alltrim(main.txtLoc.value)+" As on "+dtoc(mAsondt)
			ROW		13	
			COL		10	
			WIDTH		300
			HEIGHT		10	
			FONTNAME	'Helvetica'
			FONTSIZE	15	
			FONTBOLD	.F.
			FONTITALIC	.F.
			FONTUNDERLINE	.F.
			FONTSTRIKEOUT	.F.
			FONTCOLOR	{ 0 , 0 , 0 }
			ALIGNMENT	Left
		END TEXT

		BEGIN TEXT
			EXPRESSION	'Style'
			ROW		25	
			COL		20	
			WIDTH		20	
			HEIGHT		10	
			FONTNAME	'Helvetica'
			FONTSIZE	12	
			FONTBOLD	.F.
			FONTITALIC	.F.
			FONTUNDERLINE	.F.
			FONTSTRIKEOUT	.F.
			FONTCOLOR	{ 0 , 0 , 0 }
			ALIGNMENT	Left 
		END TEXT

		BEGIN TEXT
			EXPRESSION	'Size'
			ROW		25	
			COL		40	
			WIDTH		20	
			HEIGHT		10	
			FONTNAME	'Helvetica'
			FONTSIZE	12	
			FONTBOLD	.F.
			FONTITALIC	.F.
			FONTUNDERLINE	.F.
			FONTSTRIKEOUT	.F.
			FONTCOLOR	{ 0 , 0 , 0 }
			ALIGNMENT	Left 
		END TEXT

		BEGIN TEXT
			EXPRESSION	'Pairs'
			ROW		25	
			COL		55	
			WIDTH		20	
			HEIGHT		10	
			FONTNAME	'Helvetica'
			FONTSIZE	12	
			FONTBOLD	.F.
			FONTITALIC	.F.
			FONTUNDERLINE	.F.
			FONTSTRIKEOUT	.F.
			FONTCOLOR	{ 0 , 0 , 0 }
			ALIGNMENT	Right 
		END TEXT
				
		BEGIN TEXT
			EXPRESSION	'PP Value'
			ROW		25	
			COL		100	
			WIDTH		20	
			HEIGHT		10	
			FONTNAME	'Helvetica'
			FONTSIZE	12	
			FONTBOLD	.F.
			FONTITALIC	.F.
			FONTUNDERLINE	.F.
			FONTSTRIKEOUT	.F.
			FONTCOLOR	{ 0 , 0 , 0 }
			ALIGNMENT	Right 
		END TEXT

		BEGIN TEXT
			EXPRESSION	'MRP Value'
			ROW		25	
			COL		145	
			WIDTH		20	
			HEIGHT		10	
			FONTNAME	'Helvetica'
			FONTSIZE	12	
			FONTBOLD	.F.
			FONTITALIC	.F.
			FONTUNDERLINE	.F.
			FONTSTRIKEOUT	.F.
			FONTCOLOR	{ 0 , 0 , 0 }
			ALIGNMENT	Right 
		END TEXT
				

	END HEADER

	* Detail Band *************************************************

	BEGIN DETAIL

		BANDHEIGHT	6

		BEGIN TEXT
			EXPRESSION	aData [i] [1]
			ROW		2	
			COL		20	
			WIDTH		10	
			HEIGHT		10	
			FONTNAME	'Helvetica'
			FONTSIZE	9	
			FONTBOLD	.F.
			FONTITALIC	.F.
			FONTUNDERLINE	.F.
			FONTSTRIKEOUT	.F.
			FONTCOLOR	{ 0 , 0 , 0 }
			ALIGNMENT	Left 
		END TEXT

		BEGIN TEXT
			EXPRESSION	aData [i] [2]
			ROW		2	
			COL		40	
			WIDTH		10
			HEIGHT		10	
			FONTNAME	'Helvetica'
			FONTSIZE	9	
			FONTBOLD	.F.
			FONTITALIC	.F.
			FONTUNDERLINE	.F.
			FONTSTRIKEOUT	.F.
			FONTCOLOR	{ 0 , 0 , 0 }
			ALIGNMENT	Left 
		END TEXT

		BEGIN TEXT
			EXPRESSION	aData [i] [3]
			ROW		2	
			COL		55	
			WIDTH		20	
			HEIGHT		10	
			FONTNAME	'Helvetica'
			FONTSIZE	9	
			FONTBOLD	.F.
			FONTITALIC	.F.
			FONTUNDERLINE	.F.
			FONTSTRIKEOUT	.F.
			FONTCOLOR	{ 0 , 0 , 0 }
			ALIGNMENT	Right 
		END TEXT

		BEGIN TEXT
			EXPRESSION	aData [i] [4]
			ROW		2	
			COL		100	
			WIDTH		20	
			HEIGHT		10	
			FONTNAME	'Helvetica'
			FONTSIZE	9	
			FONTBOLD	.F.
			FONTITALIC	.F.
			FONTUNDERLINE	.F.
			FONTSTRIKEOUT	.F.
			FONTCOLOR	{ 0 , 0 , 0 }
			ALIGNMENT	Right 
		END TEXT
		
		BEGIN TEXT
			EXPRESSION	aData [i] [5]
			ROW		2	
			COL		145
			WIDTH		20	
			HEIGHT		10	
			FONTNAME	'Helvetica'
			FONTSIZE	9	
			FONTBOLD	.F.
			FONTITALIC	.F.
			FONTUNDERLINE	.F.
			FONTSTRIKEOUT	.F.
			FONTCOLOR	{ 0 , 0 , 0 }
			ALIGNMENT	Right 
		END TEXT
		
		
	END DETAIL

	* Footer Band *************************************************

	BEGIN FOOTER

		BANDHEIGHT	27

		BEGIN LINE
			FROMROW		4
			FROMCOL		10	
			TOROW		4	
			TOCOL		200	
			PENWIDTH	0.1	
			PENCOLOR	{ 0 , 0 , 0 }	
		END LINE

		BEGIN TEXT
			EXPRESSION	'Page. No:' + Str(_PageNo)
			ROW		7	
			COL		11	
			WIDTH		100	
			HEIGHT		10	
			FONTNAME	'Helvetica'
			FONTSIZE	12	
			FONTBOLD	.F.
			FONTITALIC	.F.
			FONTUNDERLINE	.F.
			FONTSTRIKEOUT	.F.
			FONTCOLOR	{ 0 , 0 , 0 }
			ALIGNMENT	Left 
		END TEXT

		BEGIN TEXT
			EXPRESSION	Date()
			ROW		7	
			COL		177	
			WIDTH		30	
			HEIGHT		10	
			FONTNAME	'Helvetica'
			FONTSIZE	12	
			FONTBOLD	.F.
			FONTITALIC	.F.
			FONTUNDERLINE	.F.
			FONTSTRIKEOUT	.F.
			FONTCOLOR	{ 0 , 0 , 0 }
			ALIGNMENT	Left 
		END TEXT

	END FOOTER

	* Summary Band ************************************************

	BEGIN SUMMARY

		BANDHEIGHT	7
		
		BEGIN LINE
			FROMROW		2
			FROMCOL		10	
			TOROW		2	
			TOCOL		200	
			PENWIDTH	0.1	
			PENCOLOR	{ 0 , 0 , 0 }	
		END LINE
		
		BEGIN LINE
			FROMROW		10
			FROMCOL		10	
			TOROW		10
			TOCOL		200	
			PENWIDTH	0.1	
			PENCOLOR	{ 0 , 0 , 0 }	
		END LINE
		
		

		BEGIN TEXT
			EXPRESSION	'Total:'
			ROW		4	
			COL		20	
			WIDTH		20	
			HEIGHT		10	
			FONTNAME	'Helvetica'
			FONTSIZE	10	
			FONTBOLD	.f.
			FONTITALIC	.F.
			FONTUNDERLINE	.F.
			FONTSTRIKEOUT	.F.
			FONTCOLOR	{ 0 , 0 , 0 }
			ALIGNMENT	Left 
		END TEXT
		

		BEGIN TEXT
			EXPRESSION	mTotQty
			ROW		4	
			COL		55	
			WIDTH		20	
			HEIGHT		10	
			FONTNAME	'Helvetica'
			FONTSIZE	10	
			FONTBOLD	.f.
			FONTITALIC	.F.
			FONTUNDERLINE	.F.
			FONTSTRIKEOUT	.F.
			FONTCOLOR	{ 0 , 0 , 0 }
			ALIGNMENT	Right 
		END TEXT

		BEGIN TEXT
			EXPRESSION	mTotCostVal
			ROW		4	
			COL		100	
			WIDTH		20	
			HEIGHT		10	
			FONTNAME	'Helvetica'
			FONTSIZE	10
			FONTBOLD	.f.
			FONTITALIC	.F.
			FONTUNDERLINE	.F.
			FONTSTRIKEOUT	.F.
			FONTCOLOR	{ 0 , 0 , 0 }
			ALIGNMENT	Right 
		END TEXT
		
		BEGIN TEXT
			EXPRESSION	mTotMrpVal
			ROW		4	
			COL		145
			WIDTH		20	
			HEIGHT		10	
			FONTNAME	'Helvetica'
			FONTSIZE	10
			FONTBOLD	.f.
			FONTITALIC	.F.
			FONTUNDERLINE	.F.
			FONTSTRIKEOUT	.F.
			FONTCOLOR	{ 0 , 0 , 0 }
			ALIGNMENT	Right 
		END TEXT

	END SUMMARY
	
		BEGIN GROUP

			GROUPEXPRESSION	aData[i] [1]

			BEGIN GROUPHEADER

				BANDHEIGHT	10

				BEGIN TEXT
					EXPRESSION	aData[i][1]
					ROW		5
					COL		20	
					WIDTH		100	
					HEIGHT		10
					FONTNAME	'Helvetica'
					FONTSIZE	12	
					FONTBOLD	.f.
					FONTITALIC .T.
				END TEXT

			END GROUPHEADER

		END GROUP	

END REPORT
I am not sure how I can add code in ITERATOR clause, because I have 3 fields for total. And, I have to re-initialize the sub total variables at the starting of each group (Heare Style, aData[1])

Thanks in advance.

With best regards.

Sudip
With best regards,
Sudip
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
Joined: Wed Jul 30, 2008 6:43 pm

Re: Report Generator

Post by Roberto Lopez »

sudip wrote:Hello Master Roberto,
Thanks a lot.
Today I created a test report as follows:
The best way to give you more clues about this is to create a small, basic sample to show it you, but I have not enough time for that right now.

When possible, I'll post one.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
Joined: Wed Jul 30, 2008 6:43 pm

Re: Report Generator

Post by Roberto Lopez »

sudip wrote: <...>
I am not sure how I can add code in ITERATOR clause, because I have 3 fields for total. And, I have to re-initialize the sub total variables at the starting of each group (Heare Style, aData[1])


If I've understood correctly, you can do it, using a function as iterator instead a single expression.

So, lets suppose that you use the following:

ITERATOR MyFunc()


The function will look as follows:

Code: Select all

Function MyFunc()

i++

<...>
You must put here your accumulators for totals or subtotals.
You can compare current cycle values with previous ones to know if you must reset something.

To display the values you must specify them in expression's text property at group footer definition.

<...>

return nil
I hope that this helps.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
sudip
Posts: 1456
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: Report Generator

Post by sudip »

Thanks a lot Master Roberto. :)
With best regards.
Sudip
With best regards,
Sudip
User avatar
sudip
Posts: 1456
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: Report Generator

Post by sudip »

Hello Master Roberto,
Thanks a lot. It works :D
Stkbal.jpg
Stkbal.jpg (23.01 KiB) Viewed 4122 times
Only one point I have noticed. For groups if I use GROUPFOOTER, I have to specify BEGIN GROUPHEADER ... END GROUPHEADER, otherwise it will give runtime error. :)

With best regards.

Sudip
With best regards,
Sudip
User avatar
sudip
Posts: 1456
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: Report Generator

Post by sudip »

Hello All,

Is there any way to change the color dynamically with Report Generator? For example I want to change the color Red when stock is negative. I used following code but not successful.

Code: Select all

...
			FONTCOLOR	{ iif(Qty >= 0, 0, 255), 0 , 0 }
...
Thanks in advance.

With best regards.

Sudip
With best regards,
Sudip
Post Reply