midjohn
4th May 2004, 09:22
Hi there,

I'm trying to insert a new row into the table tffbs004 via a program script (BaanV). The values for the fields 'leac' and 'dim2' are read from a file provided by the user and stored in variables, which are then assigned to the table fields. The insert fails with the error 'Reference 606 (reference not found) table tffbs004'. However, if I hard-code the values of these two fields in the script, the insert works successfully. Any ideas why this is happening?

Thanks.

en@frrom
4th May 2004, 11:36
You say the values are being read from a file. What file is that? How is that file created? What variables are they stored into in the program script? Are they stored into variables with the same domain as the table field? Are there no (trailing) spaces etc. in the fields?

In one of those remarks should be the solution.

Good luck!!

En.

midjohn
4th May 2004, 19:35
Hi En,

The file is a '|' (pipe) delimited .dat file. I read the values into variables of the same domain. I have checked for trailing spaces and removed them. Yet, I get the same error all the time.

The only time it worked was when I declared these variables as 'extern', placed them on the form and entered values for them through the form at run time. But why should that be different from when I read them from a file? When I check the program through a debugger, the values are read correctly.

Thanks.

oleska
4th May 2004, 21:35
Try to remove spaces before and after the string.

mark_h
4th May 2004, 21:55
You may want to try using tt.align.according.domain. I typically strip characters before and after then align it according to the domain. Do not forget include bic_tt. Also maybe if you post the code someone will see something else that maybe causing the problem.

Mark

midjohn
4th May 2004, 23:30
Hi Mark,

Here's a part of the script:

seq.gets(buffer,1024,fptr)

string.scan(buffer,"%s|%s|%s|%s", temp.cwoc, temp.leac, temp.period, temp.amnt1)

temp.leac = strip$(shiftl$(temp.leac))
temp.cwoc = strip$(shiftl$(temp.cwoc))

tt.align.according.domain(temp.leac, hold.leac, "tfgld.leac")
tt.align.according.domain(temp.cwoc, hold.cwoc, "tfgld.dimx")
.
.
.
db.retry.point()

select tffbs004.*
from tffbs004
where tffbs004._index1 = {:year.f, :budg.f, :hold.leac}
and tffbs004.dim2 = :hold.cwoc
as set with 1 rows
selectdo
selectempty
db.set.to.default(ttffbs004)
tffbs004.year = year.f
tffbs004.budg = budg.f
tffbs004.leac = hold.leac
tffbs004.dim2 = hold.cwoc
tffbs004.dty2 = 2
db.insert(ttffbs004, db.retry)
commit.transaction()
endselect

------------------------------------
Note: The variables year.f & budg.f are form fields.

Mark, i'm working on a sql server database. So when i include the file <bic_tt>, in the debugger it says '$BSE/include6.2/bic_tt not found'. My bic_tt file is under $BSE\include6.2. How can I fix this?

Thanks.

mark_h
4th May 2004, 23:56
I get the same error message in debug, but the command still works. I do not think the database matters in this case - I would expect the record to still be added.

First question: Why do this "where tffbs004._index1 = {:year.f, :budg.f, :hold.leac} and tffbs004.dim2 = :hold.cwoc" - since on my system dim2 is part of index? Yours should still work just curious why you do not use just the index for all 4 fields? At least on my system they are the first 4 fields. I did notice year on your table and that does not exist on our version.

Second question: You use db.set.to.default. I would expect you to get duplicate record if the budget, account and dimension type were not always different - are you ensuring this? You probably should check all of the fields to make sure they are correct in the db.insert. Are you getting any errors in sql server log somewhere?

Just feeling around to see what might be the problem. Still confused as to why the variables work if you set them on the form. I would expect local variables to work also.

Mark

midjohn
5th May 2004, 00:16
Hi Mark,

Thanks for your quick replies.

I'm working on BaanV. Here the table tffbs004 has changed from the BaanIV version - 'year' being the new field. I changed the index selection as you suggested. Also, the tt.align.according.domain didn't help :-(. I have no idea why the insert won't accept these local variables.

Thanks.

mark_h
5th May 2004, 01:20
At a loss at this point. In debug mode do all the variables look okay? Just wondering if maybe there is control character hiding in the data file somewhere.

DOH- I just noticed in your first post it says reference not found when you do the insert. Maybe you can validate these fields against the master table or table. Not sure what those may be - at home right now. I was just wondering did it require you to hard code one or both fields to get a record to insert? You can also look at the table and see what reference may be missing or does your error log give the field? How was the data file created - you might be able to pull it up in notepad and strip anything funny out of it by saving as plain text. I have had to do this with some txt files users have sent me.

Mark

midjohn
5th May 2004, 01:25
hey Mark,

It worked!! The tt.align... worked ... i had put the wrong domain for Work Center ;-). Thanks for all your help ... hope I didn't waste too much of your time.

Thanks again.

mark_h
5th May 2004, 01:31
Glad it worked . Was busy checking out the new interface for the board - it looks really good.

I notice that you just set up a logon - welcome to the tools forum.

Mark