Ilansu
8th December 2002, 10:38
Hi all

I’m having a problem in getting the error message from a session.
I’m trying to run the session tdilc1120m000 using AFS.

next.sern=search.for.next.serial.number(temp.cprj,item,temp.cntr,cwar,date)

stpapi.put.field("tdilc1120m000","tdinv100.cprj"," ")
stpapi.put.field("tdilc1120m000","tdinv100.item",item)
stpapi.put.field("tdilc1120m000","tdinv100.cwar",cwar)
stpapi.put.field("tdilc1120m000","tdinv100.idat",str$(date))
stpapi.put.field("tdilc1120m000","tdinv100.sern",str$(next.sern))
stpapi.put.field("tdilc1120m000","tdinv100.kowt","1")
stpapi.put.field("tdilc1120m000","tdinv100.rlcd",suno)
stpapi.put.field("tdilc1120m000","tdinv100.comp",str$(get.compnr()))
stpapi.put.field("tdilc1120m000","tdinv100.odat",str$(date))
stpapi.put.field("tdilc1120m000","tdinv100.pdat",str$(date))
stpapi.put.field("tdilc1120m000","tdinv100.pqan",str$(quan))
stpapi.put.field("tdilc1120m000","tdinv100.wtst","1")

stpapi.insert( "tdilc1120m000", 1, error.mess )
if isspace(error.mess) then
error.mess=stpapi.get.mess.code( "tdilc1120m000" )


I run the session in a debug mode and found that if the item doesn’t have a cost price for the requested date the there is a set.input.error() function .
When I run my ASF with the same date I don’t get that message and the rest of my code is not executed as it should.(of course there was no insert)
The session get stuck after trying to put value in the subsession tdilc1121s000.
if isspace(error.mess) then
stpapi.handle.subproc("tdilc1120m000","tdilc1121s000","add")
stpapi.continue.process("tdilc1120m000", error.mess)
if isspace(error.mess) then
stpapi.put.field("tdilc1121s000","tdilc102.serb","1")
tpapi.put.field("tdilc1121s000","tdilc102.stun",tiitm001.cuni)
stpapi.put.field("tdilc1121s000","tdilc102.qstr",str$(quan))
stpapi.put.field("tdilc1121s000","tdilc102.qstk",str$(quan))
stpapi.insert( "tdilc1121s000", 1, error.mess )
endif
stpapi.handle.subproc("tdilc1120m000","tdilc1121s000","kill")
stpapi.end.session("tdilc1121s000")
if isspace(error.mess) then
stpapi.put.field("tdilc1120m000","tdinv100.wtst","2")
stpapi.update( "tdilc1120m000", 1, error.mess )
endif
endif
stpapi.end.session("tdilc1120m000")


Any suggestions ?

Thanks
Ilan S

Ilansu
9th December 2002, 11:34
In debug mode I noticed that after
stpapi.insert( "tdilc1120m000", 1, error.mess )
erro.mess=""
but after
error.mess=stpapi.get.mess.code( "tdilc1120m000" )
error.mess=" " (error.mess contains about 10 spaces)

Should I check len(error.mess ) ?

Ilan S

mark_h
9th December 2002, 13:43
There are two things you could try.

After the insert - check the transaction status to make sure you have one that is open. I recommend this anyway - that way once you and process in the sub-sessions and then return to the main session, you can check to see if you have a closed transaction status. I use that to make sure that my transaction was processed. If not I delete the record and tell the user that there was a problem with the input record.

Before running this function server I validate the data. So I make sure they gave me a valid item, lot, date, etc. I am not sure if it is possible for you to check this before running the code. Is there something you can do before processing? Sometimes when I can not trap errors from a function server I trap them before calling the session. It is not always easy, but it beats having a hung session in the background.

Mark