fmorais
3rd November 2005, 13:21
Hi everyone.

Trying to create a function server to maintain inbound data (BIVc4)

Had some problems which are already referred in other threads and were able to correct them. Also installed some solutions for tdilc4515s000.

Read some threads about creating a similar function server and my code is more or less the same.

My current problem is that no errors are generated and everything seems to be working but, the receipt line is not inserted in the tdilc4104s000 session.

Logged the actions to afs.log and there is nothing there to give me a hint.
A curious thing, is that in the line:

stpapi.get.field("tdilc4104s000", "tdilc402.serb", fm.serb)

the variable fm.serb returns empty, indicating that the line was not inserted.

Can anybody give me a hint?
Please find my code bellow.



function insere.linha()
{
long posicao
domain tcdate data.lote
string data.lote$(8)
domain tcqiv1 quant2
domain tcconv factor.conv

long rc


domain tcmcs.str20 fm.kooa
domain tcmcs.str20 fm.ordem
domain tcmcs.str20 fm.lote
domain tcmcs.str5 fm.serb

|Executar
stpapi.put.field("tdilc4103m000","runnumber", logname$)

|Tipo de Ordem
stpapi.put.field("tdilc4103m000","k.o.order", str$(etol(tdilc.kooa.act.pmg)))

|Ordem
stpapi.put.field("tdilc4103m000","ordernr", str$(ordem))


stpapi.handle.subproc("tdilc4103m000", "tdilc4104s000", "add")
stpapi.continue.process("tdilc4103m000", error.msg)



stpapi.handle.subproc("tdilc4104s000","tdilc4515s000","add")
stpapi.handle.subproc("tdilc4104s000","tdilc4512s000","add")

retval = stpapi.insert("tdilc4104s000", 1, error.msg)

stpapi.put.field("tdilc4515s000","tdilc402.koor", str$(etol(tdilc.kooa.act.pmg)))
stpapi.put.field("tdilc4515s000","tdilc402.orno", str$(ordem))
stpapi.put.field("tdilc4515s000","tdilc402.pono", "0")
stpapi.put.field("tdilc4515s000","tdilc402.sera", "0")
stpapi.put.field("tdilc4515s000","tdilc402.item", artigopa)
rc = stpapi.change.view("tdilc4515s000", error.msg)
if not isspace(error.msg) or rc<> 1 then

stpapi.get.field("tdilc4515s000", "tdilc402.koor", fm.kooa)
stpapi.get.field("tdilc4515s000", "tdilc402.orno", fm.ordem)
stpapi.get.field("tdilc4515s000", "tdilc402.clot", fm.lote)

erro.rep = "Linha2 - " & error.code & " - " & error.msg
rprt_send()
stpapi.end.session("tdilc4515s000")
stpapi.end.session("tdilc4512s000")
stpapi.end.session("tdilc4104s000")
stpapi.end.session("tdilc4103m000")
endif

rc = stpapi.browse.set("tdilc4515s000", "first.set", error.msg)
rc = stpapi.find("tdilc4515s000", error.msg)

stpapi.get.field("tdilc4515s000", "tdilc402.koor", fm.kooa)
stpapi.get.field("tdilc4515s000", "tdilc402.orno", fm.ordem)
stpapi.get.field("tdilc4515s000", "tdilc402.clot", fm.lote)


rc = stpapi.mark("tdilc4515s000", error.msg)
stpapi.continue.process("tdilc4515s000", error.msg)
if not isspace(error.msg) or rc<> 1 then
erro.rep = "Linha3 - " & error.code & " - " & error.msg
rprt_send()
stpapi.end.session("tdilc4515s000")
stpapi.end.session("tdilc4512s000")
stpapi.end.session("tdilc4104s000")
stpapi.end.session("tdilc4103m000")
endif


stpapi.end.session("tdilc4515s000")
stpapi.put.field("tdilc4104s000", "tdilc402.loca", localizacao)
stpapi.put.field("tdilc4104s000", "tdilc402.qstr", str$(quantidade))

rc = stpapi.update("tdilc4104s000",0,error.msg)
if rc<> 1 then
erro.rep = "Linha4 - " & error.code & " - " & error.msg
rprt_send()
stpapi.end.session("tdilc4515s000")
stpapi.end.session("tdilc4512s000")
stpapi.end.session("tdilc4104s000")
stpapi.end.session("tdilc4103m000")
endif


stpapi.get.field("tdilc4104s000", "tdilc402.serb", fm.serb)


stpapi.end.session("tdilc4512s000")
stpapi.end.session("tdilc4104s000")
stpapi.end.session("tdilc4103m000")



}


Thanks a lot
Fred

fmorais
3rd November 2005, 13:56
It seems the values are not being returned from tdilc4515s000 into tdilc4104s000.

I put some get.field statements after ending tdilc4515s000 and the fm.xxx variables are empty.

stpapi.end.session("tdilc4515s000")

stpapi.get.field("tdilc4104s000", "tdilc402.orno", fm.ordem)
stpapi.get.field("tdilc4104s000", "tdilc402.clot", fm.lote)
stpapi.get.field("tdilc4104s000", "tdilc402.serb", fm.serb)

I already had solutions 114464, 157915, 162257 and 162259 installed.

Can anybody give me some input?

Thanks
Fred

mark_h
3rd November 2005, 15:38
Here is my subroutine to do inbound:


function extern maintain_inbound( domain tcmcs.str12 runnumber,
domain tdilc.kooa order.type,
domain tcorno order.number,
domain tdilc.loca order.location,
ref string msg())
{
|string dummy(32)

msg = ""
stpapi.handle.subproc("tdilc4103m000","tdilc4104s000","add")
stpapi.put.field("tdilc4103m000","runnumber",runnumber)
stpapi.put.field("tdilc4103m000","k.o.order",str$(order.type))
stpapi.put.field("tdilc4103m000","ordernr",str$(order.number))
stpapi.continue.process("tdilc4103m000",msg)
if not isspace(msg) then
stpapi.end.session("tdilc4103m000")
return
endif
stpapi.handle.subproc("tdilc4104s000","tdilc4515s000","add")
rc = stpapi.insert("tdilc4104s000",1,msg)
stpapi.put.field("tdilc4515s000","tdilc402.koor",str$(order.type))
stpapi.put.field("tdilc4515s000","tdilc402.orno",str$(order.number))
rc = stpapi.change.view("tdilc4515s000",msg)
if not isspace(msg) or rc<>1 then
msg = "Production order not ready for delivery"
stpapi.end.session("tdilc4515s000")
stpapi.end.session("tdilc4104s000")
stpapi.end.session("tdilc4103m000")
return
endif
| Found that the current qty to receive is the last set and not
| the first set. Try to put these into stores 05062004
rc = stpapi.browse.set("tdilc4515s000","last.set", msg)
rc = stpapi.mark("tdilc4515s000",msg)
stpapi.continue.process("tdilc4515s000",msg)
if not isspace(msg) or rc<>1 then
stpapi.end.session("tdilc4515s000")
stpapi.end.session("tdilc4104s000")
stpapi.end.session("tdilc4103m000")
return
endif
stpapi.end.session("tdilc4515s000")
stpapi.put.field("tdilc4104s000","tdilc402.loca",order.location)
rc = stpapi.update("tdilc4104s000",1,msg)
stpapi.end.session("tdilc4104s000")
stpapi.end.session("tdilc4103m000")
}


I would not expect fm.ordem, fm.lote, fm.serb to have a value until after the browse statement. The above code is called after completing a production order (another subroutine) so I expect the qty to be stored to be the last set.

fmorais
3rd November 2005, 19:22
Thanks Mark, for your prompt reply.

I am checking the variables only after browsing and marking the records in tdilc4515s000 and closing the session.
After this, the variables in tdilc4104s000 should have values...

Your code was one of the examples I studied when I was making the function server, and my code is more or less like it.

By reading a few more threads I noticed it seems I also need to install solution 134561.
The only problem is that, because it's updating the standard program, I can only test the result after restarting the shared memory, which will happen this weekend.

I will try again next week, and post the results

Thanks
Fred

mark_h
3rd November 2005, 19:48
Sorry - I did not read close enough about the get.fields. The only thing I found in question was the find command - not sure that is needed. Hopefully the patches will take care of your problem.

fmorais
8th November 2005, 13:07
Hi again.

Just tested the Function server and it is working now.
So, what I was missing was the installation of 134561.

Thanks Mark
Fred