popeye
4th February 2002, 23:26
Hi,
I am using Function Server for deleting Purchase Order lines.

When I do a find(), I get a return value of 1.
1 = Record found.
But when I do a get() for the order and position, I get
different values. Basically it goes to the first Purchase Order/Line.

Why is this happening?
I have attached a snapshot of my debug screen for your
perusal. Check the value of hold.orno, hold.pono, tmp.orno and tmp.pono.

Here is the script.
Check the |.new and |.old lines.

Thanks.
+++++++++++++++++++++++++++++++++++

function extern domain tcbool tdpurodll00001.delete.po.line(domain tcorno hold.orno,
domain tcpono hold.pono,
ref domain tcmcs.str100 hold.error)
{

long ret
domain tcorno tmp.orno
domain tcpono tmp.pono

hold.error = ""

stpapi.enum.answer("tdpur4105s000", "ttstpq0100", ttyeno.yes)
stpapi.handle.subproc("tdpur4105s000","tdpur5106s000","kill")

f4105s000.put.Purchase_Order(hold.orno)
f4105s000.put.Position_Number(hold.pono)
ret = f4105s000.find()
|if ret = 1 then | .old
tmp.orno = f4105s000.get.Purchase_Order() | .new
tmp.pono = f4105s000.get.Position_Number() | .new
if tmp.orno = hold.orno and tmp.pono = hold.pono then | .new
f4105s000.delete(0, hold.error)
if not isspace(hold.error) then
f4105s000.end()
return(FALSE)
endif
else
hold.error = "Purchase Order not found"
f4105s000.end()
return(FALSE)
endif
f4105s000.end()
return(TRUE)
}Code tags (http://www.baanboard.com/baanboard/misc.php?s=&action=bbcode) added.
~Vamsi

popeye
4th February 2002, 23:31
forgot to attach the pic :)

mark_h
5th February 2002, 15:51
Is there a session controlling the tdpur4105s000 or are you starting the subsession by itself. I was just wondering what would happen if you did the find twice in a row?


Mark

popeye
5th February 2002, 20:24
Mark,
I tried calling the put()s and the find() twice.
It worked. Why is that? Weird, eh?
"Baansense" ... I guess :)

f4105s000.put.Purchase_Order(hold.orno)
f4105s000.put.Position_Number(hold.pono)
ret = f4105s000.find()

f4105s000.put.Purchase_Order(hold.orno)
f4105s000.put.Position_Number(hold.pono)
ret = f4105s000.find()

Thanks !

mark_h
5th February 2002, 22:16
From the code you posted I did not see anything that initiated the sub-session. Usually a subsession is called from a main session (Maybe you did that somewhere else). Anyway, that may do an initial find or first.set to get things running. It maybe that you need to do a change view before doing the find. I am sorry but we do not use the sessions you are talking about and I do not know how they run. Just from glancing at the session you may need to do a stpapi.change.view first. I think you can use in the library f4105s000.set.view(). This should get you the first set.

Mark

popeye
5th February 2002, 22:44
Mark,
Thanks for the posts.

The subsession is being activcated from PO header.
But I'm directly using the subsession without invoking the
main session.

when i call the puts and find twice it works.

:)