amtolo
4th November 2002, 09:47
I wan't to insert in the session tdrpl0114m000 records automatically with AFS, the order exists in the system, attach my program with comments:

function update.rpl0114(domain tcorno orno.to.update, domain tcpono pono.to.update)
{
domain tcmcs.str100 err | error message
domain tcbool insert.err

domain tcqrp2 actual.quan
domain tcdate actual.rddt


string string.orno(6)
string string.pono(4)
string string.srnb(3)


actual.quan= tdpur917.netorige* 0.001
actual.rddt=date.num()
err=""
insert.err=false

|The values orno.to.update and pono.to.update are OK
stpapi.put.field("tdrpl0114m000","tdrpl100.orno",str$( orno.to.update))
stpapi.put.field("tdrpl0114m000","tdrpl100.pono",str$(pono.to.update))

stpapi.find("tdrpl0114m000")


stpapi.get.field("tdrpl0114m000","tdrpl100.orno",string.orno)
stpapi.get.field("tdrpl0114m000","tdrpl100.pono",string.pono)
stpapi.get.field("tdrpl0114m000","tdrpl100.srnb",string.srnb)

|At this point values string.orno<>orno.to.update and string.pono<> pono.to.update
| doesn't find my values.

if orno.to.update=val(string.orno) and pono.to.update=val(string.pono) then
stpapi.put.field( "tdrpl0114m000", "tdrpl100.dqua",str$(actual.quan))
stpapi.put.field( "tdrpl0114m000", "tdrpl100.rddt",str$(actual.rddt))
stpapi.update( "tdrpl0114m000", 1, err )
if not isspace(err) then
| Problems to save.
insert.err = true
endif

else
insert.err = true
endif
stpapi.end.session("tdrpl0114m000")
}
:confused:

Thanks

mark_h
4th November 2002, 14:02
Try using stpapi.change.view instead of stpapi.find. The use stpapi.browse.set to read through the records.

Mark

amtolo
4th November 2002, 16:26
:D :D :D :D :D :D :D :D :D



With stpapi.change.view instead stpapi.find the function runs OK.

Thank's a lot Mark.

günther
11th July 2006, 15:04
The above code seems okay for tdrpl000.ened = tdrpl.ened.orno.

But on our system we habe tdrpl000.ened = tdrpl.ened.pino which changes the behaviour of session tdrpl0114m000: form 3 is the current, index 3 gets used, find uses pino + orno + pono. So I cannot get stpapi.find() or stpapi.change.view() to work even after lots of tries ...

The only solution I have at the moment is to browse the view (initial last view, then prev view until found or eof) ...

Günther