steveauckly
20th April 2006, 17:04
I am trying to control session tdrpl0120m000 using API functionality. I want to browse through each record in the session and process it. Problem - I have no problem getting the first record, but when I call stpapi.browse.set("tdrpl0120m000", "next.set", error.msg), the first record remains current. I see from some other posts in the past that browse.set can behave funny, but I haven't gotten a definitive answer to this one. Please help! Here is my code:
ret = stpapi.browse.set(confirm.bo.session,"first.set",error.mess)
while ret
stpapi.get.field(confirm.bo.session,"tdrpl100.orno",rpl.orno)
|process this record here
ret = 0
while ret = 0 and count < 10
ret = stpapi.browse.set(confirm.bo.session ,"next.set" ,error.mess)
count = count + 1
endwhile
endwhile
stpapi.get.field(confirm.bo.session,"tdrpl100.orno",rpl.orno)
message("Last orno = %s",rpl.orno) |Gives same orno as first.set
stpapi.end.session(confirm.bo.session)
mark_h
20th April 2006, 17:43
Questions - Are you executing a find before the first.set? I am just wondering if you are using the stpapi.browse.view command around the little piece of code you pasted? Are you talking about orders with positions like 10, 20, etc. ? I would expect when using next.set it would return the same order, but maybe a different position.
mark_h
20th April 2006, 17:47
Oops forgot to mention you code works on my system for an order with multiple positions. I suspect if your orders only have one position you need to try ret = stpapi.browse.view("tdrpl0120m000","next.view",err) to get the next order.
steveauckly
20th April 2006, 17:53
You're right, I needed to be using stpapi.browse.view instead of set. Thanks Mark!
mojo1980
11th December 2007, 18:48
Hi I'm having a more or less similar problem (function server).
I'm using the main session tfgld1101m000 with different subsessions (tfgld1115s000 and tfgld1103s000).
I'm able to create different type of transaction and the transactions. However, after their creations, I am unable to select the required type to add additional transations. For the first type created, I am able to select it, but others I can't.
EXAMPLE:
JEM --> new doc 2 transaction
JEM --> new doc 3 transactions
JEM --> new doc 2 transactions
JIM --> new doc 2 transactions
JIM --> new doc 2 transactions --> ERROR
I am using stpapi.browse.set with next, I am able to find the set. I do stpapi.mark, still no error message, but when stpapi.handle.subproc and stpapi.continue.process, it opens the JEM session instead of the JIN session. Am I using the stpapi.mark incorrectly??? Any help???
thanks
Here's part of my code.
while ret<>0
buff = ""
ret = stpapi.browse.set("tfgld1101m000", "next.set")
stpapi.get.field("tfgld1101m000", "tfgld101.ttyp", buff)
if buff=tpcnv997.type then
ret2 = stpapi.mark("tfgld1101m000", error.msg)
break
else
if ret= 0 then
add.type()
break
endif
endif
endwhile
stpapi.handle.subproc("tfgld1101m000", "tfgld1103s000", "add")
stpapi.continue.process("tfgld1101m000", error.msg)
stpapi.put.field("tfgld1103s000", "ccur.f", tpcnv997.ccur)
if stpapi.change.view("tfgld1103s000", error.msg) = 0 then
write.log("stpapi.change.view tfgld1103s000 " & error.msg)
endif
mark_h
11th December 2007, 19:56
Does stpapi.get.field("tfgld1101m000", "tfgld101.ttyp", buff) returne the next ttyp correctly? If so instead of a browse set try using find. I have one program where I do a next.set, the record does not change but I can read the fields, then I do a put of the fields with a find. The find then makes the record current. Just a thought.
mojo1980
11th December 2007, 23:12
Thanks Mark,
yes I went with the stpapi find instead. And now it works correctly.