Krzysztof_PL
27th February 2019, 16:46
Hi everyone,
I am using BaaN IV and I want to add a new record in the tfgld1101m000 session using ottstpapihand. I am a novice and have tried in all ways. Can someone write me an example of how I should do it?

mark_h
27th February 2019, 17:56
Search this forum for the session tfgld1101m000. There should be several examples around what people have done - here is one such thread http://www.baanboard.com/baanboard/showthread.php?t=67971&highlight=tfgld1101m000.

Krzysztof_PL
1st March 2019, 15:56
Thank you, Mark_h, for your answer. I added a new record in tfgld1101m000 and transactions. Now I want to enter the session tfcmg2100s000 and again I do not know how. I'm writing a program in C #. When I do it this way:
baanClass.ParseExecFunction("ottstpapihand", $"stpapi.handle.subproc(\"tfgld1101m000\", \"tfcmg2100s000\", \"add\")");
baanClass.ParseExecFunction("ottstpapihand", $"stpapi.continue.process(\"tfgld1101m000\", \"{errorString}\")");
The program hangs. What am I doing wrong?

mark_h
11th March 2019, 03:29
Look at this http://www.baanboard.com/baanboard/showthread.php?t=68720&highlight=tfcmg2100s000 thread. The first thing I usually try to do is search the AFS forum by the session a member is asking about.

Krzysztof_PL
19th March 2019, 16:31
Thank you, Mark.
I saw this post and this is a good way to do what I want, but ... I have the last step in my process to automate. From the tfcmg2100s000 session I have to go to the tfcmg2106s000 session and find one document there.
In the next step, I need to update rcpt field and click continue. Do you have any solution for this? How do you click the button?

mark_h
19th March 2019, 23:52
I might be missing something, but if you have control of the tfcmg2106s000 then all you need to do is stpapi.put of the data for the receipt and then stpapi.continue. So typically when you run thru the process in baan you just replicate(most cases) what happens with api code. So typically you start with a main session and control the subsessions from there. So you start with tfgld1101m000, it launchs tfcmg2100s000, then you click continue there and it launches tfcmg2106s000, update field and do a continue(or save). Then close sessions in reverse order. So I would have commands for tfgld1101m000, with stpapi.handle.subproc for tfmcg2100s000, then I would have commands for this session with a stpapi.handle subproc for tfcmg2106s000. Then as each subsession opens it typically has what you need like manually - you just put the information and do continue.

Krzysztof_PL
20th March 2019, 12:37
Now I'm trying to do it this way:
["stpapi.put.field(\"tfgld1101s000\",\"tfgld101.year\",\"2019\")",
"stpapi.put.field(\"tfgld1101s000\",\"tfgld101.btno\",\"59\")",
"stpapi.put.field(\"tfgld1101s000\",\"tfgld101.ttyp\",\"150\")",
"stpapi.find(\"tfgld1101s000\",\"\")",
"stpapi.handle.subproc(\"tfgld1101s000\",\"tfcmg2100s000\",\"add\")",
"stpapi.continue.process(\"tfgld1101s000\",\"\")",
"stpapi.put.field(\"tfcmg2100s000\",\"tfcmg204.ttyp\",\"150\")",
"stpapi.put.field(\"tfcmg2100s000\",\"tfcmg204.tran\",\"3\")",
"stpapi.put.field(\"tfcmg2100s000\",\"tfcmg204.ccur\",\"EUR\")",
"stpapi.put.field(\"tfcmg2100s000\",\"tfcmg204.suno\",\"113839\")",
"stpapi.put.field(\"tfcmg2100s000\",\"tfcmg204.amnt\",\"182,90\")",
"stpapi.insert(\"tfcmg2100s000\",1,\"\")",
"stpapi.handle.subproc(\"tfcmg2100s000\",\"tfcmg2106s000\",\"add\")",
"stpapi.continue.process(\"tfcmg2100s000\",\"\")",
"stpapi.put.field(\"tfcmg2106s000\",\"tfacp200.ttyp\",\"411\")",
"stpapi.put.field(\"tfcmg2106s000\",\"tfacp200.ninv\",\"60046151\")",
"stpapi.change.view(\"tfcmg2106s000\",\"\")",
"stpapi.put.field(\"tfcmg2106s000\",\"tfacp200.rcpt\",\"1\")",
"stpapi.update(\"tfcmg2106s000\",1,\"\")",
"stpapi.end.session(\"tfcmg2106s000\")",
"stpapi.end.session(\"tfcmg2100s000\")",
"stpapi.end.session(\"tfgld1101s000\")"]

It creates something like that (pic1), and it should be something like that(pic2)

mark_h
20th March 2019, 18:04
"stpapi.continue.process(\"tfcmg2100s000\",\"\")",
"stpapi.put.field(\"tfcmg2106s000\",\"tfacp200.ttyp\",\"411\")",
"stpapi.put.field(\"tfcmg2106s000\",\"tfacp200.ninv\",\"60046151\")",
"stpapi.change.view(\"tfcmg2106s000\",\"\")",
"stpapi.put.field(\"tfcmg2106s000\",\"tfacp200.rcpt\",\"1\")",
"stpapi.update(\"tfcmg2106s000\",1,\"\")",
"stpapi.end.session(\"tfcmg2106s000\")",
"stpapi.end.session(\"tfcmg2100s000\")",
"stpapi.end.session(\"tfgld1101s000\")"]

If I was doing this in a baan session, I would start debugging in the above spot. After the continue on tfcmg2100s000 I would make sure that 2106s000 was controlled by the parent ID of tfcmg2100m000. I could do this thru option dialog/start shell on my baan login. If that worked I would then put a couple of get fields for tfacp200.ttyp and tfacp200.ninv. Assuming the change.view returned a 1 - view found. If it returned 0 or 2 there might be an issue. I would also check to see if in tfcmg2106s000 if the button pointed to update or continue.

Keep in mind we do not use these sessions like this, so what starts when and how I am not sure of.

Krzysztof_PL
22nd March 2019, 14:33
Mark, I got the source code for the session. Can I use stpapi.form.command in BaaN IV? stpapi.form.command returns -2. Do you know what that means?
Now I'm trying something like:
stpapi.handle.subproc(\"tfcmg2100s000\",\"tfcmg2106s000\",\"add\")
stpapi.continue.process(\"tfcmg2100s000\",\"\")
stpapi.put.field(\"tfcmg2106s000\",\"tfacp200.ttyp\",\"411\")
stpapi.put.field(\"tfcmg2106s000\",\"tfacp200.ninv\",\"60046346\")
stpapi.put.field(\"tfcmg2106s000\",\"tfacp200.line\",\"0\")
stpapi.find(\"tfcmg2106s000\",\"\") -- return 1
stpapi.put.field(\"tfcmg2106s000\",\"tfacp200.rcpt\",\"1\")
stpapi.form.command(\"tfcmg2106s000\", \"5\", \"write.fields.to.tb\", \"\")

mark_h
25th March 2019, 13:18
Stpapi.form.command based off the documentation does not return a value. I would expect that last field to be something with an error message in it.

void stpapi.form.command(string session, long command.type, string command.prog, ref string err.mesg)