Billing system

HMG Samples and Enhancements

Moderator: Rathinagiri

User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Billing system

Post by mol »

I just cleaned code. No relations. They are strongly lower productivity.

I've changed relation fields into function, eg. products->ProdName to function call:
FieldFromDataBase('Products', 'ProdName', 'ProdID')

where this function is defined as:

Code: Select all

function FieldFromDataBase(xArea, xField, cIndexKey)
	(xArea)->(DBSeek(cKIndexKey))
 return (xArea)->(&xField)
There were two browse controls in my invoice register. One for invoices, second for invoice items.
there was relation from invoice to invoice items to synchronize data:

Code: Select all

select('Invoices')
set relation to InvoiceID into InvoiceItems additive
select('InvoiceItems')
set filter to InvoiceItems->InvoiceID ==  Invoices->InvoiceID
[/b]

It worked OK on standalone computer, even with hundred of thousands records, but, it almost halted the system in network environment.
So, I've decided to change browse control displaying invoice items to grid control displaying array of invoice items.
This array is refreshed always when pointer in browse of invoices is moved.:

Code: Select all

	InvoiceItems->(DBSeek(Invoices->InvoiceID))
	aItems := {}
	FRM_InvoiceRegister.GRID_InvoiceItems.DeleteAllItems()
	n := len(aInvoiceItemsFields)
	do while InvoiceItems->InvoiceID == Invoices->InvoiceID .and. !InvoiceItems->(eof())
		aTemp := {}
		for i := 1 to n
			aAdd(aTemp, &(aInvoiceItemsFields[i]))
		next i
		FRM_InvoiceRegister.GRID_InvoiceItems.AddItem(aTemp)
		InvoiceItems->(DBSkip())
		aAdd(aItems, aTemp)
	enddo 
	FRM_InvoiceRegister.GRID_InvoiceItems.Refresh // this line is not necessary, I think...
[/b]

Actually, the table aItems is not necessary here, it's used for other applications.

Wow, this post is terribly theoretical :D so I want to apologize for the boring :lol:

Best regards, Marek
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Billing system

Post by Rathinagiri »

It is very informative and not at all boring Marek.

Thanks a lot for sharing.

Recently I am developing an application for XBRL. Soon I will publish as open source. In that software, a recursive function with just 100 lines of code can update a number of records in a tree. All these knowledge is gained from this forum and I feel so grateful to the total community.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Billing system

Post by esgici »

Hi Rathi
rathinagiri wrote:Recently I am developing an application for XBRL. Soon I will publish as open source. In that software, a recursive function with just 100 lines of code can update a number of records in a tree. All these knowledge is gained from this forum and I feel so grateful to the total community.
I'll wait eagerly this :arrow:

Best regards

--

Esgici
Viva INTERNATIONAL HMG :D
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Billing system

Post by mol »

rathinagiri wrote:It is very informative and not at all boring Marek.

Thanks a lot for sharing.

Recently I am developing an application for XBRL. Soon I will publish as open source. In that software, a recursive function with just 100 lines of code can update a number of records in a tree. All these knowledge is gained from this forum and I feel so grateful to the total community.

Nice words! THX Rathi!

I'm waitink for testing your work, too.
Regards, Marek
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Billing system

Post by esgici »

Hi Marek
mol wrote: ...
It worked OK on standalone computer, even with hundred of thousands records, but, it almost halted the system in network environment.

Code: Select all

set filter to InvoiceItems->InvoiceID ==  Invoices->InvoiceID
This set filter may be guilty of slowdown.

Since you are changed browse to grid, ( if I'm right understood ) yo haven't need further this set filter.

IMO set filter is guilty of slowdown under most circumstances.

Regards

--

Esgici
Viva INTERNATIONAL HMG :D
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Billing system

Post by mol »

I've tried to remove filter only, but it didn't worked much quicker.
I think, few relations can slow browse or grid significantly, too.


Code with relations and filter was very elegant. This way of coding was the assumpion of clipper authors, I think.

But, in real life it appeared to be not efficient enough.

Marek
miras
Posts: 11
Joined: Thu Jul 31, 2008 7:57 am

Re: Billing system

Post by miras »

Hi! Marek
I had the same problem, but I have to solve this replacement and it works a lot faster, and there is not much change in the source.

SELECT IRAPDVI1
* SET FILTER TO (IRAPDVI1->IR_KNJIGA = KOJAKNJIGAI1 .AND. IRAPDVI1->IR_GODINA >= TE_GODINA .AND. (IRAPDVI1->IR_REDNI >= "00000" .AND. IRAPDVI1->IR_REDNI <= '99999'))
* GO TOP
OrdScope(0,(KOJAKNJIGAI1 + TE_GODINA + "00000"))
OrdScope(1,(KOJAKNJIGAI1 + TE_GODINA + '99999'))
Go Top

Best Regards,
Miraš
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Billing system

Post by mol »

Very nice idea!
Look very smart!
I'll test it, many thanks!
Best regards, Marek

2011.11.18
I've tested ORDSCOPE and I'm impressed about performance of this solution.
I didn't know this function later. It wasn't present in good old CLIPPER :lol:

I want to thank you again for pointing me such a smart solution, Miras!
Post Reply