deviceofmisery
13th January 2011, 09:52
Hello,
I try to control some Baan sessions from a .Net application, but I'm new in all that stuff.
When I try to delete a project the software stucks in the next BaanIVObj.ParseExecFunction I call.
Can anybody help?
Here the Code from the c# project:
{... some Code to get the right record ...}
BaanIVObj.ParseExecFunction("ottstpapihand", string.Format("stpapi.mark(\"{0}\", \"{1}\")", sessionMaintainProjects, ret));
BaanIVObj.ParseExecFunction("ottstpapihand", string.Format("stpapi.delete(\"{0}\", 1, \"{1}\")", sessionMaintainProjects, ret));
IN THE FOLLOWING LINE THE PROGRAMM GET STUCK
BaanIVObj.ParseExecFunction("ottstpapihand", string.Format("stpapi.enum.answer(\"{0}\", \"{1}\", 1)", sessionMaintainProjects, "tipcs21013"));
BaanIVObj.ParseExecFunction("ottstpapihand", string.Format("stpapi.end.session(\"{0}\")", "ttstpsplopen"));
\BaanIVObj.ParseExecFunction("ottstpapihand", string.Format("stpapi.enum.answer(\"{0}\", \"{1}\", 1)", sessionMaintainProjects, "ttstpq0100"));
BaanIVObj.ParseExecFunction("ottstpapihand", string.Format("stpapi.continue.process(\"{0}\", \"{1}\")", sessionMaintainProjects, ret));
anthony peiris
13th January 2011, 11:21
Set a breakpoint at the line immediately after the creation of baan4 object, and when the BaaN options dialog comes up, set runtime options 'show messages', 'output to console','output to file' .
also set a break point immediately before the baan4 object is destroyed. examine the console messages for dsnError code !=0 .
(The console will show messages from spawned internal function calls too..).
That should give you a fairly good idea of what is going on under the hood.
mark_h
13th January 2011, 15:36
Your stpapi code is confusing. I would expect stpapi.find, stpapi.mark(not always needed), stpapi.enum.answer(all of them), stpapi.delete, stpapi.end.session. On our system tipcs21013 is delete project - so this should be answered before the stpapi.delete. The same is true for ttstpq0100 - I can't remember what that question is, but it should also be before the delete. Also why are you ending ttstpsplopen? Typically this session is never under api control.
Sample code:
function extern delete_outbound_seqn( domain tcmcs.str12 runnumber,
domain tdilc.kooa order.type,
domain tcorno order.number,
domain tcpono order.position,
domain tcmcs.long order.serb,
ref string msg())
{
msg = ""
stpapi.handle.subproc("tdilc4101m000","tdilc4102s000","add")
stpapi.put.field("tdilc4101m000","runnumber",runnumber)
stpapi.put.field("tdilc4101m000","k.o.order",str$(order.type))
stpapi.put.field("tdilc4101m000","ordernr",str$(order.number))
stpapi.continue.process("tdilc4101m000",msg)
if not isspace(msg) then
stpapi.end.session("tdilc4101m000")
return
endif
stpapi.enum.answer("tdilc4102s000","ttstpq0100",tcyesno.yes)
stpapi.put.field("tdilc4102s000","tdilc401.koor",str$(order.type))
stpapi.put.field("tdilc4102s000","tdilc401.orno",str$(order.number))
stpapi.put.field("tdilc4102s000","tdilc401.pono",str$(order.position))
stpapi.put.field("tdilc4102s000","tdilc401.sera","0")
stpapi.put.field("tdilc4102s000","tdilc401.serb",str$(order.serb))
rc = stpapi.find("tdilc4102s000",msg)
if rc = 1 then
stpapi.delete("tdilc4102s000",true,msg)
else
msg = "Position not found on tdilc4101m000 for delete."
endif
stpapi.end.session("tdilc4513s000")
stpapi.end.session("tdilc4102s000")
stpapi.end.session("tdilc4101m000")
}
deviceofmisery
14th January 2011, 04:12
Hi you all,
@anthony: Thanks, great advice. That can help me alot!
@mark:
first: sry for the confusing code!
great, i didn't know that i have to answer the questions before the stpapi.delete(), now i changed that. but nevertheless, after the delete command the program stuck in the next command. i tried it with stpapi.end.session() and stpapi.continue.process().
Code now:
BaanIVObj.ParseExecFunction("ottstpapihand", "stpapi.find(\"tipcs2101m000\", ret)");
BaanIVObj.ParseExecFunction("ottstpapihand", "stpapi.mark(\"tipcs2101m000\", ret)");
BaanIVObj.ParseExecFunction("ottstpapihand", "stpapi.enum.answer(\"tipcs2101m000\", \"tipcs21013\", true)");
BaanIVObj.ParseExecFunction("ottstpapihand", "stpapi.enum.answer(\"tipcs2101m000\", \"ttstpq0100\", true)");
BaanIVObj.ParseExecFunction("ottstpapihand", "stpapi.delete(\"tipcs2101m000\", 1, ret)");
BaanIVObj.ParseExecFunction("ottstpapihand", "stpapi.end.session(\"tipcs2101m000\")");
deviceofmisery
14th January 2011, 06:13
After some minutes the 'BW Message' pops up saying:
1: message_loop_nesting error, nesting level = 2(should be 1) 00459CB0
2: message_loop_nesting error, nesting level = 2(should be 1) 00459CB0
3: message_loop_nesting error, nesting level = 2(should be 1) 00459CB0
4: message_loop_nesting error, nesting level = 2(should be 1) 00459CB0
5: message_loop_nesting error, nesting level = 2(should be 1) 00459CB0
6: message_loop_nesting error, nesting level = 2(should be 1) 00459CB0
7: message_loop_nesting error, nesting level = 2(should be 1) 00459CB0
8: message_loop_nesting error, nesting level = 2(should be 1) 00459CB0
...
...
23: message_loop_nesting error, nesting level = 2(should be 1) 00459CB0
mark_h
14th January 2011, 15:41
No problem about the code - I just could not figure out if you were trying to do two different things or just delete a record. So here is how I figure out what code to run. First I run the session manually. I document what I do step by step in this case it looked like:
(1) Hit find button
(2) enter project - record found
(3) Hit delete
(4) question tipcs21013 - delete project answer yes
(5) session tipcs2270s000 opens
(6) enter printer device
(7) test project just created so report says no data found
(8) ttstpq0100 -delete record - answer yes
(9) project deleted
This translates into this code - and yes it worked on my system
function dele.project()
{
spool.device = "ASCIF"
spool.fileout = creat.tmp.file$(bse.tmp.dir$())
stpapi.put.field("tipcs2101m000","tipcs020.cprj", "MARKT1")
stpapi.find("tipcs2101m000", err)
stpapi.enum.answer("tipcs2101m000", "tipcs21013", tcyesno.yes)
stpapi.enum.answer("tipcs2101m000", "ttstpq0100", tcyesno.yes)
stpapi.handle.subproc("tipcs2101m000", "tipcs2270s000", "ADD")
stpapi.set.report("tipcs2270s000", "rtipcs227001000",spool.device, err)
stpapi.delete("tipcs2101m000", 1, err)
stpapi.end.session("tipcs2270s000")
stpapi.end.session("tipcs2101m000")
}
So from the documentation(and lots of practice :) ) I know to answer the questions first, to use stpapi.handle for the subsession, endsubsession first and then main session. It took about 15 minutes to write this code - luckily we use this session and I could test. Man I miss writing code. :)
mark_h
14th January 2011, 15:44
Ooops - another hit cause I made a mistake in the code. I ended tipcs2770s000 instead of tipcs2270s000. If you look at the option dialog box, you can hit start shell. Then do a ps and a return. This shows you the processes still running. You can watch them come and go as you debug code. This helps also. Hope the code works for you.
deviceofmisery
17th January 2011, 04:16
He mark, thanks for all your help!
... it still don't work.
Now alter line
BaanIVObj.ParseExecFunction("ottstpapihand", string.Format("stpapi.set.report(\"{0}\", \"{1}\", \"{2}\", \"{3}\")", "tipcs2270s000", "rtipcs227001000", "spool.device", ret));
the software says "Session not available". Is it because of the 'spool.device'? What is it? I think for OLE I need to replace it, like I replaced 'tcyesno.yes' with 'true' to make it work.
2nd thing:
after the stpapi.delete(...) command it says "Update canceled", even though the project status is on 'free', so it should be possible! And that he still get stuck in some kind of loop (nesting_loop)
mark_h
17th January 2011, 15:53
I tested this and this also works on our system. I think we are on like SP26 along with the current stpapi libraries and tools patches. This eliminates the need for spool.device and the project markt1 gets deleted. I do not get any error message from stpapi.delete. Just make sure you are finding the correct project.
stpapi.put.field("tipcs2101m000","tipcs020.cprj", "MARKT1")
rc = stpapi.find("tipcs2101m000", err)
if rc = 1 then
stpapi.enum.answer("tipcs2101m000", "tipcs21013", tcyesno.yes)
stpapi.enum.answer("tipcs2101m000", "ttstpq0100", tcyesno.yes)
stpapi.handle.subproc("tipcs2101m000", "tipcs2270s000", "END")
stpapi.delete("tipcs2101m000", 1, err)
endif
stpapi.end.session("tipcs2101m000")
}
deviceofmisery
18th January 2011, 03:10
ok, maybe its on the stpapi. Where can I look which version i have. And in case, where can I easiely and fast get the newes?
Thanks!
mark_h
18th January 2011, 15:25
ALways infor support is your best solution. The question I have is can you test the baan code directly in baan itself?