Page 5 of 5

Re: Billing system

Posted: Thu Nov 10, 2011 7:44 am
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

Re: Billing system

Posted: Thu Nov 10, 2011 9:30 am
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.

Re: Billing system

Posted: Thu Nov 10, 2011 9:38 am
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

Re: Billing system

Posted: Thu Nov 10, 2011 10:10 am
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

Re: Billing system

Posted: Thu Nov 10, 2011 8:10 pm
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

Re: Billing system

Posted: Fri Nov 11, 2011 7:22 am
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

Re: Billing system

Posted: Mon Nov 14, 2011 4:52 pm
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š

Re: Billing system

Posted: Mon Nov 14, 2011 6:11 pm
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!