Welcome! Log In Create A New Profile

Advanced

WD-Export Table to DBF

Posted by Toddy Utomo 
Toddy Utomo
WD-Export Table to DBF
July 07, 2009 05:32PM
Hi

I try to export Table to DBF, but WD only create an empty DBF file, with no records
What wrong with this code:

PROCEDURE SendToDBF(sFullPathFileName)
XB is Data Source

sFullPathIndexName is string = Replace(sFullPathFileName,".dbf",".ndx",IgnoreCase)

HDBDescribeFile ( "SEND2DBF" , "XB" , sFullPathFileName ) 
HDBDescribeField ( "NUMBER,N,5,0" ) 
HDBDescribeField ( "ITEMCODE,C,20" ) 
HDBDescribeField ( "ITEMDESC,C,50" ) 
HDBDescribeField ( "UNITPRICE,N,10,2" ) 
HDBDescribeField ( "FIRSTSTOCK,N,15,2" ) 
HDBDescribeField ( "LASTSTOCK,N,15,2" ) 
HDBDescribeField ( "QTYSTOCK,N,15,2" )
HDBDescribeField ( "AMOUNT,N,15,2" )
HDBDescribeField ( "TRXDATE,D" ) 
HDBDescribeIndex ( sFullPathIndexName,"ITEMCODE")
HDBCreation() 

WHILE WIN_SEE_STOCK.TABLE_Table3.Column2 <> "" 
	XB.NUMBER = WIN_SEE_STOCK.TABLE_Table3.Column1
	XB.ITEMCODE = WIN_SEE_STOCK.TABLE_Table3.Column2
	XB.ITEMDESC = WIN_SEE_STOCK.TABLE_Table3.Column3
	XB.UNITPRICE = WIN_SEE_STOCK.TABLE_Table3.Column4
	XB.FIRSTSTOCK = WIN_SEE_STOCK.TABLE_Table3.Column5
	XB.LASTSTOCK = WIN_SEE_STOCK.TABLE_Table3.Column6
	XB.QTYSTOCK = WIN_SEE_STOCK.TABLE_Table3.Column7
	XB.AMOUNT = WIN_SEE_STOCK.TABLE_Table3.Column8
	XB.TRXDATE = WIN_SEE_STOCK.TABLE_Table3.Column9
	HAdd("SEND2DBF")
END


TIA
Toddy
Jimbo
Re: WD-Export Table to DBF
July 07, 2009 06:07PM
Hi Toddy,

'WHILE' is not doing an implicit read of the Table, it just checks for values to continue / end a loop.

Depends a lot on the Table, but 'reading' the Table would basically look like this

FOR X = 1 to TableCount(WIN_SEE_STOCK.TABLE_Table3)
        XB.NUMBER = WIN_SEE_STOCK.TABLE_Table3.Column1[X]
 	XB.ITEMCODE = WIN_SEE_STOCK.TABLE_Table3.Column2[X]
	XB.ITEMDESC = WIN_SEE_STOCK.TABLE_Table3.Column3[X]
	XB.UNITPRICE = WIN_SEE_STOCK.TABLE_Table3.Column4[X]
	XB.FIRSTSTOCK = WIN_SEE_STOCK.TABLE_Table3.Column5[X]
	XB.LASTSTOCK = WIN_SEE_STOCK.TABLE_Table3.Column6[X]
	XB.QTYSTOCK = WIN_SEE_STOCK.TABLE_Table3.Column7[X]
	XB.AMOUNT = WIN_SEE_STOCK.TABLE_Table3.Column8[X]
	XB.TRXDATE = WIN_SEE_STOCK.TABLE_Table3.Column9[X]
	HAdd("SEND2DBF")
 END

Of course, you can always insert conditions to select those rows which you'd like to write ..
Guenter

Toddy Utomo
Re: WD-Export Table to DBF
July 07, 2009 06:39PM
Thanks, Guenter
it work!

Regards
Toddy
Marc De Swert
Re: WD-Export Table to DBF
July 08, 2009 10:25AM
And if you place the TableCount into a variable, it's faster
because you just read1 time the rows


lv_Count is int = TableCount(WIN_SEE_STOCK.TABLE_Table3)

FOR X = 1 to lv_Count
XB.NUMBER = WIN_SEE_STOCK.TABLE_Table3.Column1[X]
XB.ITEMCODE
...


Marc :cool:
Al
Re: WD-Export Table to DBF
July 08, 2009 01:57PM
Hello Marc

There are a couple more variations on that theme

You can use:
FOR X = 1 _TO_ tablecount(WIN_SEE_STOCK.TABLE_Table3)
Using _TO_ instead of to indicates that the tablecount() should only be evaluated once

You don't really need tablecount() either. You can use

For each row of WIN_SEE_STOCK.TABLE_Table3

Regards
Al
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: