rohan_rege
12th September 2002, 03:28
In my code to simualte Maintain Transactions

even after I put in all the fields ,and use stpapi.insert .
i get an error saying " Value cannot be Zero.."
I dont know for which field its saying so , bcoz i have put in values for each input field on the session.

and so i removed the stpapi.insert command and
instead put in a stpapi.save command

now the prog runs sucessfully w/o the above error message
implying that it saved the record
but the record doesnt get saved...when i try to check for it in the session


pls any suggestions

foll is the log whn i use stpapi.insert :

LOGGING STARTED
09-11-2002
>tfgld1100m000 browse.set
152->get.fields
152<-get.fields...
152->last.set
152<-last.set0
<tfgld1100m000 1 ok
>tfgld1100m000 get.field:tfgld100.btno
<tfgld1100m000 get.field:tfgld100.btno=16745
>tfgld1100m000 put.field:tfgld100.tedt 09112002
>tfgld1100m000 get.field:tfgld100.tedt
<tfgld1100m000 get.field:tfgld100.tedt=09112002
>tfgld1100m000 put.field:tfgld100.year 2002
>tfgld1100m000 get.field:tfgld100.year
<tfgld1100m000 get.field:tfgld100.year=2002
>tfgld1100m000 put.field:tfgld100.btno 16746
>tfgld1100m000 get.field:tfgld100.btno
<tfgld1100m000 get.field:tfgld100.btno=16746
>tfgld1100m000 put.field:tfgld100.btno jai gurudeva
>tfgld1100m000 get.field:tfgld100.btno
<tfgld1100m000 get.field:tfgld100.btno=jai gurude
>tfgld1100m000 put.field:tfgld100.fprd 9
>tfgld1100m000 get.field:tfgld100.fprd
<tfgld1100m000 get.field:tfgld100.fprd=9
>tfgld1100m000 put.field:tfgld100.rprd 3
>tfgld1100m000 get.field:tfgld100.rprd
<tfgld1100m000 get.field:tfgld100.rprd=3
>tfgld1100m000 put.field:tfgld100.vyer 2002
>tfgld1100m000 get.field:tfgld100.vyer
<tfgld1100m000 get.field:tfgld100.vyer=2002
>tfgld1100m000 put.field:tfgld100.vprd 9
>tfgld1100m000 get.field:tfgld100.vprd
<tfgld1100m000 get.field:tfgld100.vprd=9
>tfgld1100m000 insert
152->add.set+save
152<-add.set+save1
<tfgld1100m000 Value cannot be zero
>tfgld1100m000 get.mess.code
<tfgld1100m000 tfgldd0004
>tfgld1100m000 end.session
152->end.program
152<-end.program1


and what follows is the log when i only use stpapi.save
>tfgld1100m000 browse.set
249->get.fields
249<-get.fields...
249->last.set
249<-last.set0
<tfgld1100m000 1 ok
>tfgld1100m000 get.field:tfgld100.btno
<tfgld1100m000 get.field:tfgld100.btno=16745
>tfgld1100m000 put.field:tfgld100.tedt 09112002
>tfgld1100m000 get.field:tfgld100.tedt
<tfgld1100m000 get.field:tfgld100.tedt=09112002
>tfgld1100m000 put.field:tfgld100.year 2002
>tfgld1100m000 get.field:tfgld100.year
<tfgld1100m000 get.field:tfgld100.year=2002
>tfgld1100m000 put.field:tfgld100.btno 16746
>tfgld1100m000 get.field:tfgld100.btno
<tfgld1100m000 get.field:tfgld100.btno=16746
>tfgld1100m000 put.field:tfgld100.btno jai gurudeva
>tfgld1100m000 get.field:tfgld100.btno
<tfgld1100m000 get.field:tfgld100.btno=jai gurude
>tfgld1100m000 put.field:tfgld100.fprd 9
>tfgld1100m000 get.field:tfgld100.fprd
<tfgld1100m000 get.field:tfgld100.fprd=9
>tfgld1100m000 put.field:tfgld100.rprd 3
>tfgld1100m000 get.field:tfgld100.rprd
<tfgld1100m000 get.field:tfgld100.rprd=3
>tfgld1100m000 put.field:tfgld100.vyer 2002
>tfgld1100m000 get.field:tfgld100.vyer
<tfgld1100m000 get.field:tfgld100.vyer=2002
>tfgld1100m000 put.field:tfgld100.vprd 9
>tfgld1100m000 get.field:tfgld100.vprd
<tfgld1100m000 get.field:tfgld100.vprd=9
>tfgld1100m000 save
249->update.db
249<-update.db0
<tfgld1100m000
>tfgld1100m000 end.session
249->end.program
249<-end.program1


ofcourse i tried a combn of both stpapi.insert(0 , err)
and then stpapi.save

but same thing....insert gives a error message as above
and save says successful....
But when i check whether it has inserted the record...the answer is always - NO

regards
Rohan

**SAT**
12th September 2002, 08:34
Can you please post your code here, so that someone can find out what the error is.
Regards,

lbencic
12th September 2002, 17:18
the message tfgldd0004 message comes up when the tedt.f field on the form is 0. That's the Transaction Entry Date field.

ssellens
12th September 2002, 17:26
Hi Rohan,

I am not 100% sure on this but I think save will only work to an already existing record, and does not invoke the insert function on the table.

Steve

rohan_rege
12th September 2002, 18:03
Hi ,
i am posting my code wrt my prev post.

as i said, even after putting all the fields i am getting the error
"Value cannot be Zero" when i use stpapi.insert

any suggestions ?????????
function in.tfgld1100m000()
{
string inpdate(8)

string transaction_date(10)
string fiscal_year(10)
string batch_descr(10)
string fiscal_period(10)
string rprt_period(10)
string tax_year(10)
string tax_period(10)
string batch_no(10)
long rc , batno

rc = f1100m000.last( )
stpapi.get.field( "tfgld1100m000", "tfgld100.btno", batch_no )
message(batch_no)




inpdate = date.to.inputstr$( date.num() , "%D002", 8 )



stpapi.put.field( "tfgld1100m000", "tfgld100.tedt", inpdate)
stpapi.get.field( "tfgld1100m000", "tfgld100.tedt", transaction_date)
message(transaction_date)




stpapi.put.field( "tfgld1100m000", "tfgld100.year", "2002" )
stpapi.get.field( "tfgld1100m000", "tfgld100.year", fiscal_year )
message(fiscal_year )

batno = val(batch_no)
batno = batno+1
batch_no = str$(batno)

stpapi.put.field( "tfgld1100m000", "tfgld100.btno", batch_no )
stpapi.get.field( "tfgld1100m000", "tfgld100.btno", batch_no )
message(batch_no)

|f1100m000.put.Batch_Reference("test")

stpapi.put.field( "tfgld1100m000", "tfgld100.btno", "test" )
stpapi.get.field( "tfgld1100m000", "tfgld100.btno", batch_descr)


message(batch_descr)

stpapi.put.field( "tfgld1100m000", "tfgld100.fprd", "9" )
stpapi.get.field( "tfgld1100m000", "tfgld100.fprd", fiscal_period )
message(fiscal_period)

stpapi.put.field( "tfgld1100m000", "tfgld100.rprd", "3" )
stpapi.get.field( "tfgld1100m000", "tfgld100.rprd", rprt_period )
message(rprt_period)


stpapi.put.field( "tfgld1100m000", "tfgld100.vyer", "2002" )
stpapi.get.field( "tfgld1100m000", "tfgld100.vyer", tax_year )
message(tax_year)


stpapi.put.field( "tfgld1100m000", "tfgld100.vprd", "9" )
stpapi.get.field( "tfgld1100m000", "tfgld100.vprd", tax_period )
message(tax_period)




| f1100m000.insert(0,err)


ret = stpapi.insert("tfgld1100m000" , true , err)


if(strip$(err)<>"") then
msg = f1100m000.get.last.message.code()
msg = "tfgld1100m000 insert: "& strip$(err)&" "& strip$(msg)

message(msg)
else
message(" test successfull " )
endif




f1100m000.end( )
}

lbencic
12th September 2002, 18:28
The error comes when the transaction date is 0.

I think when you fill the date, you should just use



stpapi.put.field( "tfgld1100m000", "tfgld100.tedt", str$(date.num()))



That's what the help example shows in the AFS Developer's guide.

rohan_rege
12th September 2002, 19:29
hi ,

thanks for fixing the problem...

its working fine now......

i just wanted to know one more thing...

whenever i got to enter a system date into the field , i now know that i have to use str$(date.num() as in

stpapi.put.field( "tfgld1100m000", "tfgld100.tedt", str$(date.num()))

But suppose the input is to be read from an ascii file.
since the date there is in string format...
how do we transform it into a date which has the same domain format as req by the table field where it will be inserted.

eg. suppose the corr. date field in the table has a domain : tfgld.date.

i tried using the date commands in baan , but was not successful at it as of yet....being very new to coding in baan

this is what i tried :

num.day = val(budt(3;2))
num.month = val(budt(1;2))
num.year = val(budt(5;4))
tfgld998.budt = date.to.num(num.year, num.month, num.day)

but it gives a fatal error 205..out of range..when i try to insert this fiel in the table

obviously , bcoz the tfgld998.budt ..didnt receive the date input in the format desired....

the domain of tfgld998.budt is tfgld.date ,with format %D002

pls give some suggestions if possible

regards,
Rohan

lbencic
12th September 2002, 19:39
If the date itself is an illegal format - the domain error is 'Date not allowed'. Since you are getting the 205 / out of range error, I think maybe it's not the date command. The date.to.num syntax looks fine.

The out of range maybe has to do with the string parsing - although the syntax looks fine here too. Try through debug and make sure your num.day, num.month and num.year are having the values you expect. They should be declared as longs. Also, maybe use the 'lval' instead of 'val'. It's a little quicker anyway even if it is not the problem.