alokdixt
5th April 2016, 18:27
Hi,
I am trying to create an AFS script for Hours accounting session but getting error "Start date must be entered". I am getting this error only when tihra100.cwtt = "" otherwise it is going well. please help me here

Below is the script



stpapi.put.field("tihra1101m000", "tihra100.year", str$(year.al))
stpapi.put.field("tihra1101m000", "tihra100.week", str$(week.al))
stpapi.put.field("tihra1101m000", "tihra100.emno", str$(emno.al))
ret.val = stpapi.find("tihra1101m000",gapi.error.code)

stpapi.get.field("tihra1101m000", "tihra100.year", year.p)
stpapi.get.field("tihra1101m000", "tihra100.week", week.p)
stpapi.get.field("tihra1101m000", "tihra100.emno", emno.p)

stpapi.put.field("tihra1101m000", "tihra100.hrdt", str$(hrdt.al))
stpapi.put.field("tihra1101m000", "tihra100.dayn", str$(etol(dayn.al)))
stpapi.put.field("tihra1101m000", "tihra100.koht", str$(etol(koht.al)))
stpapi.put.field("tihra1101m000", "tihra100.cprj", str$(cprj.al))
stpapi.put.field("tihra1101m000", "tihra100.pdno", str$(pdno.al))
stpapi.put.field("tihra1101m000", "tihra100.opno", str$(opno.al))
stpapi.put.field("tihra1101m000", "tihra100.cact", str$(cact.al))
stpapi.put.field("tihra1101m000", "tihra100.tano", str$(tano.al))
stpapi.put.field("tihra1101m000", "tihra100.cwoc", str$(cwoc.al))
stpapi.put.field("tihra1101m000", "tihra100.cwtt", str$(cwtt.al))
stpapi.put.field("tihra1101m000", "tihra100.stdy", str$(etol(stdy.al)))
stpapi.put.field("tihra1101m000", "tihra100.sttm", str$(sttm.al))
stpapi.put.field("tihra1101m000", "tihra100.endy", str$(etol(endy.al)))
stpapi.put.field("tihra1101m000", "tihra100.entm", str$(entm.al))
stpapi.put.field("tihra1101m000", "tihra100.hrea", str$((hrea.al * -1)))

stpapi.put.field("tihra1101m000", "tihra100.ckow", str$(ckow.al))
stpapi.put.field("tihra1101m000", "tihra100.htst", str$(etol(htst.al)))
stpapi.put.field("tihra1101m000", "tihra100.pccp", str$(pccp.al))
stpapi.enum.answer("tihra1101m000", "tihras0029", tcyesno.no)
inserted = stpapi.insert("tihra1101m000", 1, gapi.error.code)

if not inserted then
while true
error.code = stpapi.get.mess.code("tihra1101m000", gapi.error.code)
if (isspace(gapi.error.code)) then
break
endif
message(gapi.error.code)
ret = stpapi.recover("tihra1101m000", dummy.msg)
endwhile
else
endif
// Again putting dayn value as it was returning zero after insert//

stpapi.put.field("tihra1101m000", "tihra100.dayn", str$(etol(dayn.al)))
stpapi.put.field("tihra1101m000", "tihra100.stdy", str$(etol(stdy.al)))
stpapi.put.field("tihra1101m000", "tihra100.endy", str$(etol(endy.al)))


if not stpapi.save("tihra1101m000", gapi.error.code) then
stpapi.get.field("tihra1101m000", "tihra100.dayn", dayn.al.p)
while true
error.code = stpapi.get.mess.code("tihra1101m000", gapi.error.code)
if (isspace(gapi.error.code)) then
break
endif
message(gapi.error.code)
endwhile
ret = stpapi.recover("tihra1101m000", dummy.msg)
stpapi.end.session("tihra1101m000")
return(false)
else
stpapi.get.field("tihra1101m000", "tihra100.dayn", dayn.al.p)


endif

stpapi.end.session("tihra1101m000")
return(true)

mark_h
5th April 2016, 22:53
You can search for other threads in this forum - there are several and this is just one http://www.baanboard.com/baanboard/showthread.php?t=5800. Now maybe is cwtt is always set, but other threads exist. Do you own source code to tihra1101 where you can debug it to see what is happening?

Ajesh
8th April 2016, 20:50
Looks like cwtt is a mandatory field if cwtt is indeed the "Start date".