Baanboard.com

Go Back   Baanboard.com > Forum > Baan SIGs > AFS/DDC/OLE: Function servers

Retirement Notice

Baanboard is shutting down on 31-dec-2023. See: http://www.baanboard.com/baanboard/showthread.php?t=76043


User login

Frontpage Sponsor

Main

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

Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 11th December 2010, 22:10
anthony peiris anthony peiris is offline
Junior Member
 
Join Date: Dec 2008
Posts: 27
anthony peiris is on a distinguished road
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
Reply With Quote
  #2  
Old 13th December 2010, 15:47
mark_h's Avatar
mark_h mark_h is offline
Guru
 
Join Date: Sep 2001
Location: Kentucky, USA
Posts: 7,819
mark_h will become famous soon enoughmark_h will become famous soon enough
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.
Reply With Quote
  #3  
Old 14th December 2010, 14:36
anthony peiris anthony peiris is offline
Junior Member
 
Join Date: Dec 2008
Posts: 27
anthony peiris is on a distinguished road
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
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
error in stpapi.enum.answer - Cant read session or object anthony peiris AFS/DDC/OLE: Function servers 2 9th December 2010 13:51
BW Message Can't read Session or Object marwest98 Tools Administration & Installation 3 8th October 2008 13:11
Can't open dd_table of ttadv999 Cannot read session or object (ttstpoledaem) vadimb Tools Administration & Installation 1 12th August 2008 04:47
Session not print the selected linked report nasheer Tools Development 2 21st February 2008 07:15


All times are GMT +2. The time now is 01:15.


©2001-2023 - Baanboard.com - Baanforums.com