rduncan10
12th March 2007, 18:01
Hi,

Can someone tell me what is wrong with this code? It is driving me nuts.

The codes is supposed to read values from a CSV file exported from Excel and process updates based on them. But no matter what I try, this never finds any results in the item master:

|* Script Type: 4

|****************************** DECLARATION SECTION ***************************
declaration:
table ttiitm001 | Items

string line.in(50)
string item.no(16)
double purch.price
long fp

extern domain tcitem this.item

#define TR(x) strip$(shiftl$(x))

|****************************** FUNCTION SECTION ***************************
functions:

function import.data()
{

| fp previously opened with fp = seq.open(file.path & "/" & file.name, "r")

string pp.text(10)
long ret
while not seq.gets(line.in, 1024, fp)
ret=string.scan(line.in, %s,%s", item.no, pp.text)
this.item = strip$(item.no)
this.item = shiftr$(this.item)
this.item = toupper$(this.item)
| Also Tried:
| this.item = TR(item.no)
| this.item = item.no

purch.price = val(pp.text)
update.item()
endwhile
seq.close(fp)
}

function update.item()
{
db.retry.point()
select tiitm001.*
from tiitm001 for update
where tiitm001._index1 = {:this.item}
selectdo
....
endselect
}

The input file would look something like this:

12345,15.50
1293,5.33
1293-A,5.44

I know this reads the file: I can have it print a two column report with each value, but no matter what I do, that select clause never finds anything. And I have verified that the items exist in the item master.

Thanks,
Rob

gfasbender
12th March 2007, 18:28
Try:

ret=string.scan(line.in, "%s,%s", item.no, pp.text)

bigjack
12th March 2007, 19:25
Try using tt.align.according.domain to align the read variable to proper format...
include bic_tt file to use this function