psehouri
19th March 2008, 11:40
Hello,

If I use this vbscript code below to print 15L units via : tcmcs0401m000 and everything works fine.

Dim SessionImpression
Dim RapportImpression
Dim ErrMessage1
Dim OfKey1
Dim OfKey2
Dim OfKeyValue1
Dim OfKeyValue2
Dim CodeImprimante

SessionImpression = "tcmcs0401m000"
RapportImpression = "rtcmcs040101000"
ErrMessage1 = Space(30)
OfKey1 = "cuni.f"
OfKey2 = "cuni.t"
CodeImprimante = "L"
OfKeyValue1 = "15L"
OfKeyValue2 = "15L"

Set BaanObj = CreateObject("Baan4.Application.510")
BaanObj.ParseExecFunction "ottstpapihand", "stpapi.put.field(" & Chr(34) & SessionImpression & Chr(34) & "," & Chr(34) & OfKey1 & Chr(34) & "," & Chr(34) & OfKeyValue1 & Chr(34) & ")"
BaanObj.ParseExecFunction "ottstpapihand", "stpapi.put.field(" & Chr(34) & SessionImpression & Chr(34) & "," & Chr(34) & OfKey2 & Chr(34) & "," & Chr(34) & OfKeyValue2 & Chr(34) & ")"
BaanObj.ParseExecFunction "ottstpapihand", "stpapi.set.report(" & Chr(34) & SessionImpression & Chr(34) & "," & Chr(34) & RapportImpression & Chr(34) & "," & Chr(34) & CodeImprimante & Chr(34) & "," & Chr(34) & ErrMessage1 & Chr(34) & ")"
BaanObj.ParseExecFunction "ottstpapihand", "stpapi.continue.process(" & Chr(34) & SessionImpression & Chr(34) & "," & Chr(34) & ErrMessage1 & Chr(34) & ")"
BaanObj.ParseExecFunction "ottstpapihand", "stpapi.end.session(" & Chr(34) & SessionImpression & Chr(34) & ")"
BaanObj.Quit


If I want to do the same using Python using the code below, I get a BW Message saying :

DispInvoke Failed, error = -2147352573

So, the session works, but I can't quit the session automatically because of the BW Message...

Someone already experience and solve this problem ???
Than'x...


import win32com.client

Societe = "510"
LanceBaaN = "Baan4.Application." + Societe

SessionImpression = "tcmcs0410m000"
RapportImpression = "rtcmcs041001000"
ErrMessage1 = ""
OfKey1 = "ccty.f"
OfKey2 = "ccty.t"
CodeImprimante = "L-PAYSAGE"
OfKeyValue1 = "FRA"
OfKeyValue2 = "FRA"

BaanObj = win32com.client.Dispatch(LanceBaaN)

BaanObj.ParseExecFunction("ottstpapihand", "stpapi.put.field(" + chr(34) + SessionImpression + chr(34) + "," + chr(34) + OfKey1 + chr(34) + "," + chr(34) + OfKeyValue1 + chr(34) + ")")
BaanObj.ParseExecFunction("ottstpapihand", "stpapi.put.field(" + chr(34) + SessionImpression + chr(34) + "," + chr(34) + OfKey2 + chr(34) + "," + chr(34) + OfKeyValue2 + chr(34) + ")")
BaanObj.ParseExecFunction("ottstpapihand", "stpapi.set.report(" + chr(34) + SessionImpression + chr(34) + "," + chr(34) + RapportImpression + chr(34) + "," + chr(34) + CodeImprimante + chr(34) + "," + chr(34) + ErrMessage1 + chr(34) + ")")
BaanObj.ParseExecFunction("ottstpapihand", "stpapi.continue.process(" + chr(34) + SessionImpression + chr(34) + "," + chr(34) + ErrMessage1 + chr(34) + ")")

BaanObj.ParseExecFunction("ottstpapihand", "stpapi.end.session(" + chr(34) + SessionImpression + chr(34) + ")")
BaanObj.Quit

psehouri
21st March 2008, 11:49
Yep, help please !!!

mark_h
21st March 2008, 12:29
Sorry, but I would say there are not many python programmers on the board. So your best bet might be posting on a python board. Or show patience until someone that does know Python shows up to make a suggestion.

psehouri
21st March 2008, 14:18
Hello Mark, but I don't think it's a Python issue... The message is a BW Message...

I saw in a precedent post that the problem already appear about PHP and BaaN on this forum...

mark_h
21st March 2008, 14:37
I can't say for sure, but I see two sets of code which looks identical to me. One works in vb and one doesn't in python. I do not understand all the details in making the connection, but to me it looks like python is not making a connection. Where exactly in the code does it get this error? If it is the BaanObj = win32com.client.Dispatch(LanceBaaN) statement then to me it points to the library(or windows DLL) that contains win32com.client.dispatch. That falls way outside my knowledge base - it could me a windows update, a baan client update or even maybe a baan patch.

psehouri
21st March 2008, 15:05
I can't say for sure, but I see two sets of code which looks identical to me. One works in vb and one doesn't in python. I do not understand all the details in making the connection, but to me it looks like python is not making a connection. Where exactly in the code does it get this error? If it is the BaanObj = win32com.client.Dispatch(LanceBaaN) statement then to me it points to the library(or windows DLL) that contains win32com.client.dispatch. That falls way outside my knowledge base - it could me a windows update, a baan client update or even maybe a baan patch.

Hello Mark_u,
my Python Code connects to BaaN because, the execution of the session continue and give the good result.
THe code doing the connection is : BaanObj = win32com.client.Dispatch("Baan4.Application.510")

If I comment the other lines, I get the error. So, I think you're right, maybe it's a Python issue, I continue to search...

psehouri
25th March 2008, 09:48
Hello,

The problem was due to ambiguous definition of method or property...

So, flagging (what Python believes to be) a property as a method fix it...


Maybe it's the first code in Python on this site, I'm happy :D

The code becomes :


import win32com.client

Societe = "510"
LanceBaaN = "Baan4.Application." + Societe

SessionImpression = "tcmcs0410m000"
RapportImpression = "rtcmcs041001000"
ErrMessage1 = ""
OfKey1 = "ccty.f"
OfKey2 = "ccty.t"
CodeImprimante = "L"
OfKeyValue1 = "FRA"
OfKeyValue2 = "FRA"

BaanObj = win32com.client.Dispatch(LanceBaaN)
BaanObj._FlagAsMethod("ParseExecFunction")
BaanObj.ParseExecFunction("ottstpapihand", "stpapi.put.field(" + chr(34) + SessionImpression + chr(34) + "," + chr(34) + OfKey1 + chr(34) + "," + chr(34) + OfKeyValue1 + chr(34) + ")")
BaanObj.ParseExecFunction("ottstpapihand", "stpapi.put.field(" + chr(34) + SessionImpression + chr(34) + "," + chr(34) + OfKey2 + chr(34) + "," + chr(34) + OfKeyValue2 + chr(34) + ")")
BaanObj.ParseExecFunction("ottstpapihand", "stpapi.set.report(" + chr(34) + SessionImpression + chr(34) + "," + chr(34) + RapportImpression + chr(34) + "," + chr(34) + CodeImprimante + chr(34) + "," + chr(34) + ErrMessage1 + chr(34) + ")")
BaanObj.ParseExecFunction("ottstpapihand", "stpapi.continue.process(" + chr(34) + SessionImpression + chr(34) + "," + chr(34) + ErrMessage1 + chr(34) + ")")
BaanObj.ParseExecFunction("ottstpapihand", "stpapi.end.session(" + chr(34) + SessionImpression + chr(34) + ")")
BaanObj._FlagAsMethod("Quit")
BaanObj.Quit
BaanObj = None

mark_h
25th March 2008, 13:56
Glad you got it fixed and you posted the solution.

matigro
10th July 2009, 21:54
Nice script, after headbanging with the wall to understand some things about Windows(tm) and connections, I made it run! :D
The only problem I found is that it needs one configuration to connect to LN for itself. i.e. I can't use same connection with my LN worktop, I use one at the time. :( And it is not a common way to do it (for the company I work).
Is this problem in all other programming languages?

Thanks, psehouri. "Now is better than never."

psehouri
16th July 2009, 23:53
Nice script, after headbanging with the wall to understand some things about Windows(tm) and connections, I made it run! :D
The only problem I found is that it needs one configuration to connect to LN for itself. i.e. I can't use same connection with my LN worktop, I use one at the time. :( And it is not a common way to do it (for the company I work).
Is this problem in all other programming languages?

Thanks, psehouri. "Now is better than never."

You're right, I need one connection for the AFS, and another to use another AFS... on the same computer of course. It's the same using VBS or Python scripts... it's a BaaN "rule"...

arthur_info
28th December 2009, 20:25
I'm using vb.net and my Baan version is Baan40c.68. I'm facing the same problem here, but the solution BaanObj._FlagAsMethod("Quit") doesn't work... Somebody has any other suggestion?

Thanks in advance.

matigro
29th December 2009, 13:42
I'm using vb.net and my Baan version is Baan40c.68. I'm facing the same problem here, but the solution BaanObj._FlagAsMethod("Quit") doesn't work.

Look on first post of this thread, psehouri wrote a vb script that was working.
Hello,
If I use this vbscript code below to print 15L units via : tcmcs0401m000 and everything works fine.

Dim SessionImpression
Dim RapportImpression
Dim ErrMessage1
(..some code....)
Set BaanObj = CreateObject("Baan4.Application.510")
BaanObj.ParseExecFunction "ottstpapihand", "stpapi.put.field(" & Chr(34) & SessionImpression & Chr(34) & "," & Chr(34) & OfKey1 & Chr(34) & "," & Chr(34) & OfKeyValue1 & Chr(34) & ")"
(...more code...)
BaanObj.Quit



The way that close connection in VB language is BaanObj.Quit

Method BaanObj._FlagAsMethod("Quit") is used in Python language to close connection.

The name in CreateObject method is the name that you used when you create it in BECS (Baan Environment and Configuration Selector).
ie: I have one that I called BaanV_server1 so I have something like this Set BaanObj = CreateObject("Baan4.Application.BaanV_server1")
You could see this name in BECS, click in the connection/configure/Automation

Hope it helps you

arthur_info
29th December 2009, 18:43
Yes... I've tried that but the error continues... I've created another post to collect all the 3 errors that I'm trying to solve...

But thanks for all...