tbrault
26th March 2002, 18:08
I want to open a sub session with vb.
In fact, I want to open the session delivery management (tdsls4120m000), and with the spécial option and the sub menu, I want to open the subsession "delivery note management" (tdsls4121s000). In baan, when you open the subsession, there is a qst (tdsls41211) "Automatically insert delivery note?", and i want to answer yes. After, I want to close the subsession. But, my program don't work. I can compilated without pb but the delivery note are not writed.
Help me.
That's my program :
-------------------------------------------------------------------
Public Function test()
'--> DECLARATION
'--> Declaration variable session et champ--
Dim BaanSess As String
Dim SousBaanSess As String
Dim QuestionBaanSess As String
Dim OrdreKeyValue As String
Dim PositionKeyValue As String
'------------------------------------------
'--> Declaration valeur--------------------
Dim OrdreValue As String
Dim PositionValue As String
Dim FormNumber As Long
Dim option2 As String
Dim option1 As String
Dim ErrMessage1 As String
'------------------------------------------

'--> Programme

'--> Champs
BaanSess = "tdsls4120m000"
SousBaanSess = "tdsls4121s000"
QuestionBaanSess = "tdsls41211"
OrdreKeyValue = "tdsls045.orno"
PositionKeyValue = "tdsls045.pono"
'--> Valeur----
OrdreValue = "141356"
PositionValue = "60"
FormNumber = 1
option1 = "add"
option2 = "tcyesno.yes"
ErrMessage1 = Space(30)

Set baanobj = CreateObject("Baan4.Application")
'--> recherche
baanobj.ParseExecFunction "ottstpapihand", "stpapi.put.field(" & Chr(34) & BaanSess & Chr(34) & "," & Chr(34) & OrdreKeyValue & Chr(34) & "," & Chr(34) & OrdreValue & Chr(34) & ")"
baanobj.ParseExecFunction "ottstpapihand", "stpapi.put.field(" & Chr(34) & BaanSess & Chr(34) & "," & Chr(34) & PositionKeyValue & Chr(34) & "," & Chr(34) & PositionValue & Chr(34) & ")"
ret = baanobj.ParseExecFunction("ottstpapihand", "stpapi.find(" & Chr(34) & BaanSess & Chr(34) & "," & Chr(34) & ErrMessage1 & Chr(34) & ")")
'--> Clic
baanobj.ParseExecFunction "ottstpapihand", "stpapi.handle.subproc(" & Chr(34) & BaanSess & Chr(34) & "," & Chr(34) & SousBaanSess & Chr(34) & "," & Chr(34) & option1 & Chr(34) & ")"
baanobj.ParseExecFunction "ottstpapihand", "stpapi.zoom.session(" & Chr(34) & BaanSess & Chr(34) & "," & FormNumber & "," & Chr(34) & SousBaanSess & Chr(34) & "," & Chr(34) & ErrMessage1 & Chr(34) & ")"
baanobj.ParseExecFunction "ottstpapihand", "stpapi.enum.answer(" & Chr(34) & SousBaanSess & Chr(34) & "," & Chr(34) & QuestionBaanSess & Chr(34) & "," & option2 & ")"
baanobj.ParseExecFunction "ottstpapihand", "stpapi.end.session(" & Chr(34) & SousBaanSess & Chr(34) & ")"
baanobj.ParseExecFunction "ottstpapihand", "stpapi.end.session(" & Chr(34) & BaanSess & Chr(34) & ")"
End Function

mark_h
26th March 2002, 19:52
From you code I notice you do both a stpapi.handle.subproc and stpapi.zoom, I do not ever recall using these together. I do recall trying to use them together and it did not work. My rule of thumb is - if you 'push' a button on the form manually then you use stpapi.handle.subproc in a function server. If you go to application and then zoom to a subsession then you use stpapi.zoom. This is NOT always the case, but it usually works.

I also notice that after you do the stpapi.enum.answer you end the session. You might need to do a save or a update first before you exit the session.

Just a few ideas and I hope they help you.

Mark

Sigh - I could probably help better if people would pick sessions that we use. As it is I can only look at the code and make suggestions that I hope are helpful. :)

tbrault
27th March 2002, 11:01
I have modify my program with your advice but the program don't work!
In fact, the session work like this :
- run session tdsls4120m000 : delivery management session.
- click "special" button
- select"zoom"
after there is a menu that appear.
- select delivery note management (tdsls4121s000)
--> A qst appear (tdsls41211) : "Automatically insert delivery note?", and i want to answer : "yes"
-Save and quit.

How I must do my program to open this subsession?
that's my new program :

-----------------------------------------------------------------------
Public Function test()
'--> DECLARATION
'--> Declaration variable session et champ--
Dim BaanSess As String
Dim SousBaanSess As String
Dim QuestionBaanSess As String
Dim OrdreKeyValue As String
Dim PositionKeyValue As String
'------------------------------------------
'--> Declaration valeur--------------------
Dim OrdreValue As String
Dim PositionValue As String
Dim FormNumber As Long
Dim option2 As String
Dim option1 As String
Dim ErrMessage1 As String
'------------------------------------------

'--> Programme

'--> Champs
BaanSess = "tdsls4120m000"
SousBaanSess = "tdsls4121s000"
QuestionBaanSess = "tdsls41211"
OrdreKeyValue = "tdsls045.orno"
PositionKeyValue = "tdsls045.pono"
'--> Valeur----
OrdreValue = "141356"
PositionValue = "60"
FormNumber = 1
option1 = "add"
option2 = "tcyesno.yes"
ErrMessage1 = Space(30)

Set baanobj = CreateObject("Baan4.Application")
'--> recherche
baanobj.ParseExecFunction "ottstpapihand", "stpapi.put.field(" & Chr(34) & BaanSess & Chr(34) & "," & Chr(34) & OrdreKeyValue & Chr(34) & "," & Chr(34) & OrdreValue & Chr(34) & ")"
baanobj.ParseExecFunction "ottstpapihand", "stpapi.put.field(" & Chr(34) & BaanSess & Chr(34) & "," & Chr(34) & PositionKeyValue & Chr(34) & "," & Chr(34) & PositionValue & Chr(34) & ")"
ret = baanobj.ParseExecFunction("ottstpapihand", "stpapi.find(" & Chr(34) & BaanSess & Chr(34) & "," & Chr(34) & ErrMessage1 & Chr(34) & ")")
'--> Clic

baanobj.ParseExecFunction "ottstpapihand", "stpapi.zoom.option(" & Chr(34) & BaanSess & Chr(34) & "," & FormNumber & "," & Chr(34) & SousBaanSess & Chr(34) & "," & Chr(34) & ErrMessage1 & Chr(34) & ")"
baanobj.ParseExecFunction "ottstpapihand", "stpapi.continue.process(" & Chr(34) & SousBaanSess & Chr(34) & "," & Chr(34) & ErrMessage1 & Chr(34) & ")"
baanobj.ParseExecFunction "ottstpapihand", "stpapi.enum.answer(" & Chr(34) & SousBaanSess & Chr(34) & "," & Chr(34) & QuestionBaanSess & Chr(34) & "," & option2 & ")"
ret = baanobj.ParseExecFunction("ottstpapihand", "stpapi.update(" & Chr(34) & SousBaanSess & Chr(34) & "," & FormNumber & "," & Chr(34) & ErrMessage1 & Chr(34) & ")")
baanobj.ParseExecFunction "ottstpapihand", "stpapi.end.session(" & Chr(34) & SousBaanSess & Chr(34) & ")"
baanobj.ParseExecFunction "ottstpapihand", "stpapi.end.session(" & Chr(34) & BaanSess & Chr(34) & ")"
End Function

mark_h
27th March 2002, 15:45
First I am attaching a document of what our tdsls4120m000 looks like. So my reply is based on that.

First lets make sure the find has truly found the record you want. This is how I typically do a find on this type of multi-occurence type form. First I usually put the field - not the real commands just shorthand to save time.

stpapi.put.field(sess,ordervalue)
stpapi.put.field(sess,pono)
returncode = stpapi.change.view(sess)

The above would set the order and position for tdsls4120m000 session. By checking the return code you make sure you had the correct records. I am not positive how you do that in VB.

The next step would be to make sure you had the correct record in the multi-occurence form.

returncode = stpapi.browse.set(sess,"first.set")

I would at this point get some of the fields on the form to make sure I had the correct record. If not the correct record you could use the above command with "next.set" to get the next multi-occ record. You can use this to loop through the records until you found the correct one. You may need to mark this record - not really sure.

Once you are positive you have the correct record you say "click" special button. What does this do in the session when running manually? It sounds like it pops up a menu of some sort, you select zoom, then you select the tdsls4121s000? On our system I can go to application, zoom and then run tdsls4121s000. On our system this sub-session is called "Maintain Bills of Lading". We are on 4c3 a&d. My guess is that you would mark the record and then just do a zoom. When I say mark the record I am talking about the stpapi.mark command - just learned this today. Found this command when using ttstpcreatdll, but I do not have any documentation on it.

What I would do is first run "ttstpcreatdll" and look at the commands you get. In the attached zip file is the one from our system. This always helps me see how the session works. Next I would remove the continue and just do a straight zoom. I would run the VB code in debug mode, this way you could look and see what is running before the zoom and after the zoom. Use your option dialog and do a ps before and after zoom. What I expect to see is just the tdsls4120m000 session running first and then the tdsls4120m000 and tdsls4121s000 both running.

Oh yeah - I would move the stpapi.enum.answer to BEFORE the zoom. You want this to default before the question is asked. So it would be
stpapi.enum.answer
stpapi.zoom
stpapi.save or update <-- Still not sure about this it may or may not be necessary.
stpapi.end <-- End both sessions.

Sorry about being long winded - I really think the best steps would be (1) Make double sure you have found the correct record. This can be critical for the next steps. (2) Doing a ps to see what happens before and after zoom.

Mark

tbrault
27th March 2002, 16:37
In my system; when I do a zoom, there is a pop up menu that appear before and I must select the subsession tdsls4121s000.
How do I have to create my program to open the menu and start the subsession?
Help me. Pleasssseeeeeeeee!!!
thomas

mark_h
27th March 2002, 17:01
Lets do this in two steps. First lets make sure you find in the tdsls4120m000 session is working correctly. Here is a link (http://www.baanboard.com/baanboard/showthread.php?s=&threadid=1168) that shows how to do the get field piece in VB. So lets start there. Try your code first doing enough get fields to make sure you have the correct record set.

If you do not have the correct record try what is below:
stpapi.put.field(sess,ordervalue)
stpapi.put.field(sess,pono)
returncode = stpapi.change.view(sess)
returncode = stpapi.browse.set(sess,"first.set")

The only problem is the returncodes. I have not done this before in VB. That is why I am posting just the stpapi commands. Anyway I suggest doing a get on the order and position to make sure you have the exact record you are working on.

Once the find is correct we can work on the zoom piece.

Mark

gfasbender
27th March 2002, 17:30
The zoom process should work with the following:


stpapi.handle.subproc("tdsls4120m000", " tdsls4121s000", "add")
stpapi.enum.answer("tdsls4121s000"," "tdsls41211", option2)
stpapi.zoom.option("tdsls4120m000", FormNumber, "tdsls4121s000", ErrMessage1)
stpapi.continue.process("tdsls4121s000", ErrMessage1)
stpapi.update("tdsls4121s000", FormNumber, ErrMessage1)
stpapi.end.session("tdsls4121s000")
stpapi.end.session("tdsls4120m000")

tbrault
27th March 2002, 18:24
I modify my program :
I can select the good record without pb, but the zoom session don't work :
When my program executed the command line "stapi.zoom.option", I see that I have an error message : Command cancelled ; and the program continu (but nothing arrived)

mark_h
27th March 2002, 18:47
After your find try doing a stpapi.mark( "tdsls4120m000" ). Maybe a record has to be selected before doing the zoom. If you think it will help I can post a sample of one of my zooms that I know works. I have never used the stpapi.mark before just found it today while running the ttstpcreatdll on your session.

Mark

PS - I checked the few places I have used stpapi.zoom and I never use the handle.subproc with them. I am not disagreeing with Gordon because different sessions need different commands and Gordon has been most helpful before in solving my function server problems.

tbrault
27th March 2002, 22:24
Ok, can you post the sample ? That can help me.

mark_h
28th March 2002, 14:38
Attached is a script for a sub-session I developed. It contains a zoom around line 971. Just so you know I always use ttstpcreatdll on each session to create a library. I included all of these libraries so you could see actual stpapi commands that are executed.

This session is used to allow the buyers to create pegged purchase orders. We are on 4c3 the A and D version. So all of our GRP orders are pegged. This session allows the buyer to select some of the pegs or all of them. It has a little bit of everything in it. I did not clean it up so there may lines commented out from when I was testing it nor did I include the main session that calls this sub-session.

Forgot to mention that these are Baan Libraries and code. Not really VB, but you should be able to execute them from VB.

Hope it helps!

Mark

()New link to AFS Document - Thanks to Youp2001 (http://www.baanboard.com/baanboard/showthread.php?s=&threadid=889)

lasmartres
12th January 2004, 10:45
Hello,

I read your question on the subprocess in session tdsls4120m000.



I have the same problem.
Are you create you the subprocess on session tdsls4102s000 and why ?


Please help me?


thanks

mark_h
12th January 2004, 15:50
Just saw the PM and found this. Sorry, but I am not going to be much help here. Maybe if you post your code someone will notice something that may help.

Mark

lasmartres
13th January 2004, 12:38
hello

thanks for your help


Dim ssql As String
Dim erreur As String
Dim i As Integer
Dim error As String

Set baanobj = CreateObject("Baan4.Application")

ssql = "stpapi.put.Field(" & Chr(34) & "tdsls4120m000" & Chr(34) & "," & Chr(34) & "tdsls045.orno" & Chr(34) & "," & Chr(34) & "124163" & Chr(34) & ")"
erreur = baanobj.ParseExecFunction("ottstpapihand", ssql)

ssql = "stpapi.put.Field(" & Chr(34) & "tdsls4120m000" & Chr(34) & "," & Chr(34) & "tdsls045.pono" & Chr(34) & "," & Chr(34) & "10" & Chr(34) & ")"
erreur = baanobj.ParseExecFunction("ottstpapihand", ssql)

ssql = "stpapi.find(" & Chr(34) & "tdsls4120m000" & Chr(34) & ") "
erreur = baanobj.ParseExecFunction("ottstpapihand", ssql)


ssql = "stpapi.zoom.option( "& Chr(34) & "tdsls4120m000" & Chr(34) &",1, "& Chr(34) & "tdsls4121s000" & Chr(34) &"," & Chr(34) & Chr(34) &")"
erreur = baanobj.ParseExecFunction("ottstpapihand", ssql)



The subsession tdsls4121s000 is not created.

mark_h
13th January 2004, 15:58
From the documentation on stpapi.zoom.option the fourth parameter is the error message. I do not see that in the code(maybe just a typo), maybe add it and see what the error message is. That may answer the problem.

Mark

lasmartres
13th January 2004, 17:01
Not error message after execution in the fourth parameter

mark_h
13th January 2004, 17:54
I just glanced at the session on our system and it looks like it starts a menu. You may want to look at this post (http://www.baanboard.com/baanboard/showthread.php?s=&threadid=13858) and try this command stpapi.handle.subproc("tdsls4102s000", "mtdsls000090451", "10"). You would use the tdsls4120m000 session as first parameter, which ever menu it calls as second parameter, and then the number on that menu. This is about the last thing I can think of to try.

Mark