wtf_Feng
6th July 2009, 16:02
the codes are below:

Set Baanobj = CreateObject("Baan4.Application")
SessionName = "tiitm0101m000"
FieldName1 = "tiitm001.item"
FieldValue1 = Trim(Text1.Text)
ErrMessage = Space(30)


Baanobj.ParseExecFunction "ottstpapihand", "stpapi.put.field(" & Chr(34) & SessionName & Chr(34) & "," & Chr(34) & FieldName1 & Chr(34) & "," & Chr(34) & FieldValue1 & Chr(34) & ")"
MsgBox Baanobj.functioncall

Baanobj.ParseExecFunction "ottstpapihand", "stpapi.get.field(" & Chr(34) & SessionName & Chr(34) & "," & Chr(34) & FieldName1 & Chr(34) & ", " & Chr(34) & ErrMessage & Chr(34) & " )"
MsgBox Baanobj.functioncall

Baanobj.ParseExecFunction "ottstpapihand", "stpapi.find(" & Chr(34) & SessionName & Chr(34) & ", " & Chr(34) & ErrMessage & Chr(34) & ")"
MsgBox Baanobj.functioncall

Baanobj.ParseExecFunction "ottstpapihand", "stpapi.delete(" & Chr(34) & SessionName & Chr(34) & ",10, " & Chr(34) & ErrMessage & Chr(34) & ")"
MsgBox (Baanobj.functioncall)

=================================
when I try to delete the session"tiitm0101m000",it says "command cancelled".
How can I solve this problem?
thank you very much!

mark_h
6th July 2009, 16:27
Well the first thing that pops into my mind when I see command cancelled is to update your stpapi libraries to get the latest and greatest.

Have you tried the series of commands in a baan program? I can't help much with VB code. When you run manually does it ask any questions? I know our system does so I would expect a stpapi.enum.answer for any questions asked.

wtf_Feng
7th July 2009, 03:04
It works well with commands such as stpapi.update ,stpapi.insert,except stpapi.delete .
How can I get the latest and greatest of the stpapi libraries and which one should I update? The client or the server?
Thank you for your reply~

mark_h
7th July 2009, 15:30
It would be the Baan server that got updated. I would first pose the question to infor about the stpapi.delete problem. They would be better at recommending what is needed.

mark_h
7th July 2009, 15:36
Something else that comes to mind - is this baan 5 or what is the version of Baan? That can make a difference.

wtf_Feng
7th July 2009, 16:37
Many thanks
The Baan product version is B40c.67

mark_h
7th July 2009, 18:38
I just noticed you have ,10, in the code - shouldn't that be ,1,? Let me test some code.

mark_h
7th July 2009, 18:44
On our system launching tiitm0101m000 launches tppdm0110m000 and this simple little snippet of code worked for me:

stpapi.put.field("tppdm0110m000","tiitm001.item", "SOMEDUMMYITEM")
ret = stpapi.find("tppdm0110m000")
if(ret <> 1) then
message("err")
endif
stpapi.enum.answer("tppdm0110m000", "tiitm01012", tcyesno.yes)
stpapi.delete("tppdm0110m000",1,err)
message(err)
stpapi.end.session("tppdm0110m000")

wtf_Feng
8th July 2009, 06:27
I have modify my program with your advice but the program don't work!

This my new program :
code:
Set Baanobj = CreateObject("Baan4.Application")
SessionName = "tppdm0110m000"
FieldName1 = "tiitm001.item"
FieldValue1 = Trim(Text1.Text)
ErrMessage = Space(30)
'ans = "tcyesno.yes"
AnswerValue = "tiitm01012"

Baanobj.ParseExecFunction "ottstpapihand", "stpapi.put.field(" & Chr(34) & SessionName & Chr(34) & "," & Chr(34) & FieldName1 & Chr(34) & "," & Chr(34) & FieldValue1 & Chr(34) & ")"
MsgBox Baanobj.functioncall

Baanobj.ParseExecFunction "ottstpapihand", "stpapi.find(" & Chr(34) & SessionName & Chr(34) & ", " & Chr(34) & ErrMessage & Chr(34) & ")"
' MsgBox Baanobj.functioncall

Baanobj.ParseExecFunction "ottstpapihand", "stpapi.enum.answer(" & Chr(34) & SessionName & Chr(34) & ", " & Chr(34) & AnswerValue & Chr(34) & ",1)"
MsgBox Baanobj.functioncall

Baanobj.ParseExecFunction "ottstpapihand", "stpapi.delete(" & Chr(34) & SessionName & Chr(34) & ",1, " & Chr(34) & ErrMessage & Chr(34) & ")"
MsgBox (Baanobj.functioncall)

Baanobj.ParseExecFunction "ottstpapihand", " stpapi.end.session(" & Chr(34) & SessionName & Chr(34) & ")"

================================================================
When I do the "stpapi.delete" ,it also says "command cancelled"
How can I solve the proplem?

Thank you very much!

mark_h
8th July 2009, 15:30
The item that you are trying to delete - can you delete it manually? I just created and deleted a part. I did not try one that I know the system would not let me delete. If it is not this then I would log a case with infor.

mark_h
8th July 2009, 15:34
Yep - I would log a case with infor. I get a message saying Item could not be deleted.

wtf_Feng
8th July 2009, 15:41
I can delete the session manually but can't delete it using the stpapi.delete.

Aha, nice to hear that you can cath the exception.The problem has been bothered me for a few days.

I'm looking forward to getting the message from you/Infor.

Thanks again

günther
8th July 2009, 16:55
Are we talking about a test system with minimal data, or are we talking about thousands of articles up to millions of finance data? If so, forget about that.

There is a session tiitm0203m000 "Delete Items" for that purpose! And that session will run for hours to delete one item. I run it on weekends.

Günther