Retirement Notice
|
|
User login
|
|
Frontpage Sponsor
|
|
Poll
|
What do you expect from your SI Implementation partner for the success of ERP implementation. Bring best practices - Not to offer more CR's Leveraging standard functions 20% Need more honesty to work with the Users until their processes are fully mapped & Users are trained 40% Focus on process automation/ integrations/ Real time data/ BI analytics 13% Stick to basics 27% Total votes: 15 |
|
|
 |

11th December 2010, 22:10
|
Junior Member
|
|
Join Date: Dec 2008
Posts: 27
|
|
Baan: v4 -
DB: Oracle -
OS: Hp-unix
|
Error - cannot read session or object on print report attempt
Attempting to print order acknowledgement with the following code.
BaaN throws "Can't read session or object (tdsls44010002)"
The object BaaN is complaining about really do not exist.. I guess it is inferring this from request submitted.
also note the code is throwing 'Process is gone'
When I run the code I get this debugger output
[color="SeaGreen"]
1: SetEnum
141527: Putfield orno.f
000: Putfield comp.f
999: Putfield comp.t
141527: Putfield orno.t
2: SetEnum prnt.discount
2: Putfield prnt.sellpr
1: Putfield printed
1: Putfield quant.to.print
2: Putfield prnt.options
1: Putfield num.copies
InsertSession(tdsls4401m000):1
FindSession(tdsls4401m000), Found=ok.Found
CountinueProces(tdsls4401m000):Process is gone[/COLOR]
Code:
#region button1 click
private void button1_Click(object sender, EventArgs e)
{
// Reference myBW is tlibimp from Baan 4 bw type lib
// 2010 Dec 3rd a.p
// myBw.IDispatchBaan4 b = new myBw.Baan4();
b.Timeout = 1;
string qry = "select tiitm001.citg from tiitm001 group by tiitm001.citg order by tiitm001.citg";
string sf = string.Format("olesql_parse(\"{0}\")", qry);
int i = b.ParseExecFunction("ottdllsql_query", sf);
Debug.WriteLine(sf);
Debug.WriteLine(i);
int handle = int.Parse(b.ReturnValue);
string s2 = "";
sf = string.Format("olesql_fetch({0})", handle); b.ParseExecFunction("ottdllsql_query", sf);// fetch the first one
while (b.ReturnValue != "110")
{
s2 = string.Format("olesql_getstring(\"tiitm001.citg\",\" \")"); i = b.ParseExecFunction("ottdllsql_query", s2); // Get string
Debug.WriteLine("funccall={0} rv={1} Error={2}", b.FunctionCall.Remove(b.FunctionCall.IndexOfAny(new char[] { '\0' }), 1), b.ReturnValue, b.Error);
i = b.ParseExecFunction("ottdllsql_query", sf); // fetch nexyt
}
Debug.WriteLine("wait...");
Debug.WriteLine(b.Error);
Debug.WriteLine(b.ReturnValue);
b.Quit();
Debug.WriteLine("hello");
b = null;
}
#endregion
public string PutField(string session, KeyValuePair<string, Object> kvp)
{
string sParams = string.Format("stpapi.put.field(\"{0}\",\"{1}\",\"{2}\")", session, kvp.Key, kvp.Value);
b.DllName = "ottstpapihand";
b.ParseExecFunction("ottstpapihand", sParams);
string[] rv = b.FunctionCall.Split(new char[] { ',', '\0', '\"' }, StringSplitOptions.RemoveEmptyEntries);
return rv[3];
}
public string GetField(string session, KeyValuePair<string, object> kvp)
{
string sParams = string.Format("stpapi.get.field(\"{0}\",\"{1}\",\"{2}\")", session, kvp.Key, kvp.Value);
b.ParseExecFunction("ottstpapihand", sParams);
string rv = b.FunctionCall.Split(new char[] { ',', '\0', '\"' }, StringSplitOptions.RemoveEmptyEntries)[3];
return rv;
}
public string SetEnum(string session, KeyValuePair<string, object> kvp)
{
string sParams = string.Format("stpapi.enum.answer(\"{0}\",\"{1}\",{2})", session, kvp.Key, kvp.Value);
b.ParseExecFunction("ottstpapihand", sParams);
string rv = b.FunctionCall.Split(new char[] { ',', '\0', '\"', ')' }, StringSplitOptions.RemoveEmptyEntries)[3];
return rv;
}
public string InsertSession(string s)
{
string err = " ";
b.ParseExecFunction("ottstpapihand", String.Format("stpapi.insert(\"{0}\",1,\"{1}\")", s, err));
string[] x = b.FunctionCall.Split(new char[] { ',', '\0', '\"' }, StringSplitOptions.RemoveEmptyEntries);
return x[2];
}
public string ContinueProcess(string session)
{
b.ParseExecFunction("ottstpapihand", String.Format("stpapi.continue.process(\"{0}\",\"{1}\")", session, " "));
string[] x = b.FunctionCall.Split(new char[] { ',', '\0', '\"' }, StringSplitOptions.RemoveEmptyEntries);
return x[2];
}
public string Find(string session)
{
b.ParseExecFunction("ottstpapihand", String.Format("stpapi.find(\"{0}\",\"{1}\")", session, ""));
return b.ReturnValue;
}
public void PrintReport(string session)
{
b.ParseExecFunction("ottstpapihand", String.Format("stpapi.print.report(\"{0}\", \"{1}\")", session, " "));
}
public void SetReport(string session, string reportName, string device)
{
b.ParseExecFunction("ottstpapihand", String.Format("stpapi.set.report(\"{0}\",\"{1}\",\"{2}\" , \"{3}\" )", session, reportName, device, " "));
}
public string GetMessageCode(string session)
{
string x = " ";
string sParams = string.Format("stpapi.get.mess.code(\"{0}\",\"{1}\")", session, x);
b.ParseExecFunction("ottstpapihand", sParams);
string[] rv = b.FunctionCall.Split(new char[] { ',', '\0', '\"' }, StringSplitOptions.RemoveEmptyEntries);
return rv[2];
}
#region btnExecDll click
private void btnExecDll_Click(object sender, EventArgs e)
{
#region kill running bw.exe processes
Process[] p = Process.GetProcessesByName("bw");
foreach (Process x in p)
{
Debug.WriteLine(x.CloseMainWindow());
x.Kill();
}
#endregion
b = new myBw.Baan4();
string sSession = "tdsls4401m000";
Debug.WriteLine("SetEnum", SetEnum(sSession, new KeyValuePair<string, object>("selection", 1)));
Debug.WriteLine("Putfield orno.f", PutField(sSession, new KeyValuePair<string, object>("orno.f", "141527")));
Debug.WriteLine("Putfield comp.f", PutField(sSession, new KeyValuePair<string, object>("comp.f", "000")));
Debug.WriteLine("Putfield comp.t", PutField(sSession, new KeyValuePair<string, object>("comp.t", "999")));
Debug.WriteLine("Putfield orno.t", PutField(sSession, new KeyValuePair<string, object>("orno.t", "141527")));
Debug.WriteLine("SetEnum prnt.discount", SetEnum(sSession, new KeyValuePair<string, object>("prnt.discount", 2)));
Debug.WriteLine("Putfield prnt.sellpr", PutField(sSession, new KeyValuePair<string, object>("prnt.sellpr", 2)));
Debug.WriteLine("Putfield printed", PutField(sSession, new KeyValuePair<string, object>("printed", 1)));
Debug.WriteLine("Putfield quant.to.print", PutField(sSession, new KeyValuePair<string, object>("quan.to.print", 1)));
Debug.WriteLine("Putfield prnt.options", PutField(sSession, new KeyValuePair<string, object>("prnt.options", 2)));
//Debug.WriteLine("SetEnum prnt.spellr", SetEnum(sSession, new KeyValuePair<string, object>("prnt.sellpr", 2)));
//Debug.WriteLine("SetEnum printed", SetEnum(sSession, new KeyValuePair<string, object>("printed", 1)));
//Debug.WriteLine("SetEnum quan.to.prin", SetEnum(sSession, new KeyValuePair<string, object>("quan.to.print", 1)));
//Debug.WriteLine("SetEnum prnt.options", SetEnum(sSession, new KeyValuePair<string, object>("prnt.options", 2)));
Debug.WriteLine("Putfield num.copies", PutField(sSession, new KeyValuePair<string, object>("num.copies", 1)));
SetReport(sSession, "tdsls440101000", "D66");
Debug.WriteLine(String.Format("InsertSession({0}):{1}",sSession, InsertSession(sSession)));
// PrintReport(sSession);
Debug.WriteLine(String.Format("FindSession({0}), Found={1}", sSession, Find(sSession) == "1" ? "ok.Found" : "***Error notfound***"));
Debug.WriteLine(String.Format("CountinueProces({0}):{1}",sSession, ContinueProcess(sSession)));
b.Quit(); b = null;
}
#endregion
}
}
Any help appreciated
Anthony
|

13th December 2010, 15:47
|
 |
Guru
|
|
Join Date: Sep 2001
Location: Kentucky, USA
Posts: 7,819
|
|
Baan: Baan 4C4 A&D1 -
DB: Oracle -
OS: Sun Solaris
|
Well I don't know this coding, but the one thing I saw was SetReport(sSession, "tdsls440101000", "D66"); this line. When using api commands the report should have an r in from of it like rtdsls440101000.
__________________
Mark
GO Cards!
My latest mantra - make sure you have latest stpapi patches and the latest session object. If on LN then please explore the option of using DAL2 functionality.
Shared Solutions for Baan systems provided free by Baan Board.
Play the Google game and help Baanboard get better rankings. Do your part. Click here to find how.
|

14th December 2010, 14:36
|
Junior Member
|
|
Join Date: Dec 2008
Posts: 27
|
|
Baan: v4 -
DB: Oracle -
OS: Hp-unix
|
Print S.O.A via OLE working
Hi Mark thanks onces again.. Primary error was ommiting r prefix.
on top; Just setting parameters and process continue was sufficient to get it working;
For those interesested, here is the revised code
Code:
#region button1 click
private void button1_Click(object sender, EventArgs e)
{
// Reference myBW is tlibimp from Baan 4 bw type lib
// 2010 Dec 3rd a.p
// myBw.IDispatchBaan4 b = new myBw.Baan4();
b.Timeout = 1;
string qry = "select tiitm001.citg from tiitm001 group by tiitm001.citg order by tiitm001.citg";
string sf = string.Format("olesql_parse(\"{0}\")", qry);
int i = b.ParseExecFunction("ottdllsql_query", sf);
Debug.WriteLine(sf);
Debug.WriteLine(i);
int handle = int.Parse(b.ReturnValue);
string s2 = "";
sf = string.Format("olesql_fetch({0})", handle); b.ParseExecFunction("ottdllsql_query", sf);// fetch the first one
while (b.ReturnValue != "110")
{
s2 = string.Format("olesql_getstring(\"tiitm001.citg\",\" \")"); i = b.ParseExecFunction("ottdllsql_query", s2); // Get string
Debug.WriteLine("funccall={0} rv={1} Error={2}", b.FunctionCall.Remove(b.FunctionCall.IndexOfAny(new char[] { '\0' }), 1), b.ReturnValue, b.Error);
i = b.ParseExecFunction("ottdllsql_query", sf); // fetch nexyt
}
Debug.WriteLine("wait...");
Debug.WriteLine(b.Error);
Debug.WriteLine(b.ReturnValue);
b.Quit();
Debug.WriteLine("hello");
b = null;
}
#endregion
public string PutField(string session, KeyValuePair<string, Object> kvp)
{
string sParams = string.Format("stpapi.put.field(\"{0}\",\"{1}\",\"{2}\")", session, kvp.Key, kvp.Value);
b.DllName = "ottstpapihand";
b.ParseExecFunction("ottstpapihand", sParams);
string[] rv = b.FunctionCall.Split(new char[] { ',', '\0', '\"' }, StringSplitOptions.RemoveEmptyEntries);
return rv[3];
}
public string GetField(string session, KeyValuePair<string, object> kvp)
{
string sParams = string.Format("stpapi.get.field(\"{0}\",\"{1}\",\"{2}\")", session, kvp.Key, kvp.Value);
b.ParseExecFunction("ottstpapihand", sParams);
string rv = b.FunctionCall.Split(new char[] { ',', '\0', '\"' }, StringSplitOptions.RemoveEmptyEntries)[3];
return rv;
}
public string SetEnum(string session, KeyValuePair<string, object> kvp)
{
string sParams = string.Format("stpapi.enum.answer(\"{0}\",\"{1}\",{2})", session, kvp.Key, kvp.Value);
b.ParseExecFunction("ottstpapihand", sParams);
string rv = b.FunctionCall.Split(new char[] { ',', '\0', '\"', ')' }, StringSplitOptions.RemoveEmptyEntries)[3];
return rv;
}
public string InsertSession(string s)
{
string err = " ";
b.ParseExecFunction("ottstpapihand", String.Format("stpapi.insert(\"{0}\",1,\"{1}\")", s, err));
string[] x = b.FunctionCall.Split(new char[] { ',', '\0', '\"' }, StringSplitOptions.RemoveEmptyEntries);
return x[2];
}
public string ContinueProcess(string session)
{
b.ParseExecFunction("ottstpapihand", String.Format("stpapi.continue.process(\"{0}\",\"{1}\")", session, " "));
string[] x = b.FunctionCall.Split(new char[] { ',', '\0', '\"' }, StringSplitOptions.RemoveEmptyEntries);
return x[2];
}
public string Find(string session)
{
b.ParseExecFunction("ottstpapihand", String.Format("stpapi.find(\"{0}\",\"{1}\")", session, ""));
return b.ReturnValue;
}
public void PrintReport(string session)
{
b.ParseExecFunction("ottstpapihand", String.Format("stpapi.print.report(\"{0}\", \"{1}\")", session, " "));
}
public void SetReport(string session, string reportName, string device)
{
b.ParseExecFunction("ottstpapihand", String.Format("stpapi.set.report(\"{0}\",\"{1}\",\"{2}\" , \"{3}\" )", session, reportName, device, " "));
}
public string GetMessageCode(string session)
{
string x = " ";
string sParams = string.Format("stpapi.get.mess.code(\"{0}\",\"{1}\")", session, x);
b.ParseExecFunction("ottstpapihand", sParams);
string[] rv = b.FunctionCall.Split(new char[] { ',', '\0', '\"' }, StringSplitOptions.RemoveEmptyEntries);
return rv[2];
}
#region kill running bw.exe processes
public void killProcesses(string pname)
{
Process[] p = Process.GetProcessesByName(pname);
foreach (Process x in p)
{
Debug.WriteLine(x.CloseMainWindow());
x.Kill();
}
}
#endregion
#region btnExecDll click
private void btnExecDll_Click(object sender, EventArgs e)
{
b = new myBw.Baan4();
string sSession = "tdsls4401m000";
Debug.WriteLine("SetEnum", SetEnum(sSession, new KeyValuePair<string, object>("selection", 1)));
Debug.WriteLine("Putfield orno.f", PutField(sSession, new KeyValuePair<string, object>("orno.f", "141527")));
Debug.WriteLine("Putfield comp.f", PutField(sSession, new KeyValuePair<string, object>("comp.f", "000")));
Debug.WriteLine("Putfield comp.t", PutField(sSession, new KeyValuePair<string, object>("comp.t", "999")));
Debug.WriteLine("Putfield orno.t", PutField(sSession, new KeyValuePair<string, object>("orno.t", "141527")));
Debug.WriteLine("Putfield prnt.discount", PutField(sSession, new KeyValuePair<string, object>("prnt.discount", 2)));
Debug.WriteLine("SetEnum prnt.spellr", PutField(sSession, new KeyValuePair<string, object>("prnt.sellpr", "2")));
Debug.WriteLine("SetEnum printed", PutField(sSession, new KeyValuePair<string, object>("printed", 1)));
Debug.WriteLine("SetEnum quan.to.prin", PutField(sSession, new KeyValuePair<string, object>("quan.to.print", "1")));
Debug.WriteLine("SetEnum prnt.options", PutField(sSession, new KeyValuePair<string, object>("prnt.options", "2")));
Debug.WriteLine("Putfield num.copies", PutField(sSession, new KeyValuePair<string, object>("num.copies", "1")));
Debug.WriteLine(GetField(sSession, new KeyValuePair<string, object>("num.copies", "Get field")), "gotten");
SetReport(sSession, "rtdsls440101000", "105");
Debug.WriteLine(String.Format("CountinueProces({0}):{1}", sSession, ContinueProcess(sSession)));
b.Quit(); b = null;
}
#endregion
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|