santana
17th August 2005, 14:38
Hi all, i am triyng to create baan clients ( tccom010 ) whith VB aplication using this function in baan DLL:

All of them return 0 but the client is not inserted in the table, can anynone give me a clue ?
Thanks


PS - Bellow the Baan DLL called


function extern void tccom1101m000f.put.cliente( const domain tccuno vcuno, const domain tcnama vnama,
const domain tcnamc vnamc,const domain tcpstc vpstc,const domain tcccty vccty,
const domain tctelp vtelp,const domain tctelx vtelx)
{
DLLUSAGE
Function to set Customer, name and other required and user definable fields
ENDDLLUSAGE
stpapi.put.field( "tccom1101m000", "tccom010.cuno", vcuno )
stpapi.put.field( "tccom1101m000", "tccom010.nama", vnama )
stpapi.put.field( "tccom1101m000", "tccom010.namc", vnamc )
stpapi.put.field( "tccom1101m000", "tccom010.pstc", vpstc )
stpapi.put.field( "tccom1101m000", "tccom010.ccty", vccty )
stpapi.put.field( "tccom1101m000", "tccom010.telp", vtelp )
stpapi.put.field( "tccom1101m000", "tccom010.telx", vtelx )
}

function extern void tccom1101m000f.put.cliente_def( )
{
DLLUSAGE
Function to set Customer default data for non inputable fields
ENDDLLUSAGE
stpapi.put.field( "tccom1101m000", "tccom010.comp", "941" )
stpapi.put.field( "tccom1101m000", "tccom010.crep", "0" )
stpapi.put.field( "tccom1101m000", "tccom010.clan", "PT" )
stpapi.put.field( "tccom1101m000", "tccom010.ccur", "EUR" )
stpapi.put.field( "tccom1101m000", "tccom010.cvyn", "2" )
stpapi.put.field( "tccom1101m000", "tccom010.crlr", "0" )
stpapi.put.field( "tccom1101m000", "tccom010.clin", "0" )
stpapi.put.field( "tccom1101m000", "tccom010.eded", "0" )
stpapi.put.field( "tccom1101m000", "tccom010.cnpa", "1" )
stpapi.put.field( "tccom1101m000", "tccom010.itpr", "2" )
stpapi.put.field( "tccom1101m000", "tccom010.ncin", "0" )
stpapi.put.field( "tccom1101m000", "tccom010.lidt", "0" )
stpapi.put.field( "tccom1101m000", "tccom010.back", "1" )
stpapi.put.field( "tccom1101m000", "tccom010.scom", "2" )
stpapi.put.field( "tccom1101m000", "tccom010.cfcg", "001" )
stpapi.put.field( "tccom1101m000", "tccom010.odis", "0" )
stpapi.put.field( "tccom1101m000", "tccom010.prio", "99" )
stpapi.put.field( "tccom1101m000", "tccom010.ackx", "2" )
stpapi.put.field( "tccom1101m000", "tccom010.ccra", "0" )
}

function extern long tccom1101m000f.insert( long do.update, ref string error )
{
DLLUSAGE
Function to insert a record in session tccom1101m000
Fields must be put before calling this function
ENDDLLUSAGE
return( stpapi.insert( "tccom1101m000", do.update, error ) )
}
function extern long tccom1101m000f.save( ref string error )
{
DLLUSAGE
Function to save an update/insert/delete in session tccom1101m000
ENDDLLUSAGE
return( stpapi.save( "tccom1101m000", error ) )
}
function extern void tccom1101m000f.end([string error(500)])
{
DLLUSAGE
Function to end connection to session tccom1101m000
ENDDLLUSAGE
if get.argc() = 0 then
stpapi.end.session( "tccom1101m000" )
else
error = get.string.arg(1)
stpapi.end.session( "tccom1101m000" , error )
put.string.arg(1, error)
endif

mark_h
17th August 2005, 15:30
I take it your VB code calls things in this order:

tccom1101m000f.put.cliente
tccom1101m000f.put.cliente_def
tccom1101m000f.insert

Is this correct? You probably should post your VB code - that way someone who knows VB might see a problem.

santana
17th August 2005, 17:19
Thanks for the reply! here's a portion of the code. "Cliente" and "Cliente_def" are new functions that "put" a group of fields at a time.
BtnInsertGlobal_Click is the button that trigers the "add customer".
Thanks in Advance!

private void EscreveLog(string msg)
{
lstBoxLog.Items.Add(System.DateTime.Now.ToString("HH:mm:ss:fffff") + " \t " + msg);

}

private void btnInsertGlobal_Click(object sender, System.EventArgs e)
{


Baan4.Baan4Class baanObject = null;
int resultado=0;
string operacao = "";

try
{
baanObject = new Baan4Class();
}
catch(System.Exception ex)
{
EscreveLog("Erro: Deu erro a instanciar o objecto baan : " + ex.Message);
MessageBox.Show("Deu erro a instanciar o objecto baan : " + ex.ToString());
}


try
{
operacao = txtFuntion.Text + ".put.cliente(\"" + txtCuno.Text + "\", \"" + txtNama.Text + "\", \"" + txtlNamc.Text + "\", \"" + txtPstc.Text + "\", \"" + txtCcty.Text + "\", \"" + txtTelp.Text + "\", \"" + txtTelx.Text + "\")";
resultado = baanObject.ParseExecFunction(txtSession.Text, operacao);
}
catch(System.Exception ex)
{
EscreveLog("Erro: Deu erro a executar operacao : " + operacao + " ----- " + ex.Message);
MessageBox.Show("Deu erro a executar operacao : " + operacao + " ----- " + ex.ToString());
}
EscreveLog("Resultado Baan : " + operacao + " ---- " + baanObject.ReturnValue + " ----- " + resultado.ToString());


try
{
operacao = txtFuntion.Text + ".put.cliente_def()";
resultado = baanObject.ParseExecFunction(txtSession.Text, operacao);
}
catch(System.Exception ex)
{
EscreveLog("Erro: Deu erro a executar operacao : " + operacao + " ----- " + ex.Message);
MessageBox.Show("Deu erro a executar operacao : " + operacao + " ----- " + ex.ToString());
}
EscreveLog("Resultado Baan : " + operacao + " ---- " + baanObject.ReturnValue + " ----- " + resultado.ToString());



try
{
operacao = txtFuntion.Text + ".insert(1,\"" + String.Empty.PadLeft(500, " ".ToCharArray()[0]) + "\")";
// MessageBox.Show(operacao);
resultado = baanObject.ParseExecFunction(txtSession.Text, operacao);
}
catch(System.Exception ex)
{
EscreveLog("Erro: Deu erro a executar operacao : " + operacao + " ----- " + ex.Message);
MessageBox.Show("Deu erro a executar operacao : " + operacao + " ----- " + ex.ToString());
}
EscreveLog("Resultado Baan : " + operacao + " ---- " + baanObject.ReturnValue + " ----- " + resultado.ToString());

try
{
operacao = txtFuntion.Text + ".save(\"" + String.Empty.PadLeft(500, " ".ToCharArray()[0]) + "\")";
resultado = baanObject.ParseExecFunction(txtSession.Text, operacao);
}
catch(System.Exception ex)
{
EscreveLog("Erro: Deu erro a executar operacao : " + operacao + " ----- " + ex.Message);
MessageBox.Show("Deu erro a executar operacao : " + operacao + " ----- " + ex.ToString());
}
EscreveLog("Resultado Baan : " + operacao + " ---- " + baanObject.ReturnValue + " ----- " + resultado.ToString());


try
{
operacao = txtFuntion.Text + ".end(\"" + String.Empty.PadLeft(500, " ".ToCharArray()[0]) + "\")";
resultado = baanObject.ParseExecFunction(txtSession.Text, operacao);
}
catch(System.Exception ex)
{
EscreveLog("Erro: Deu erro a executar operacao : " + operacao + " ----- " + ex.Message);
MessageBox.Show("Deu erro a executar operacao : " + operacao + " ----- " + ex.ToString());
}
EscreveLog("Resultado Baan : " + operacao + " ---- " + baanObject.ReturnValue + " ----- " + resultado.ToString());

baanObject.Quit();

baanObject = null;


}

mark_h
17th August 2005, 20:15
The VB code is beyond my skills, but you should be able to put your library in debug mode. Then as the code executes you can watch what happens in the library. You could check the library and make sure no errors are being returned.

Also try inserting one by hand(using only the fields in your function server) to make sure all the mandatory fields are included. Our system forces terms of payment to be entered and I did not see that in your list.

monica23
14th December 2007, 15:53
Hi,
anybody can help me...i want to connect Baan through VB is this code is ok...??after object creation its get hang....when i try to close VB application its give error application is running...anybody can help

code :

Private Sub Command1_Click()
Set BaanObj = CreateObject("baan4.application")
BaanObj.timeout = 10
On Error GoTo BaanAutomationError

B_function = "start.session(" & Chr(34) & "tiitm0101m000" & Chr(34) & ")"
BaanObj.ParseExecFunction "otccomdllbaan", B_function
Exit Sub
BaanAutomationError:
MsgBox "Baan IV automation error: " & BaanObj.Error
MsgBox "Return value function: " & B_function & " " & BaanObj.ReturnValue
BaanObj.Quit
Set BaanObj = Nothing
Exit Sub

End Sub

Private Sub Command2_Click()
BaanObj.Quit
Set BaanObj = Nothing

End Sub

mark_h
14th December 2007, 16:22
Are you connecting to Baan 4 or 5? On which line does it hang? Do you actually get connected to Baan - do you see the option dialog box? What is in the tccomdllbaan?

mark_h
14th December 2007, 16:42
You might want to review this thread (http://www.baanboard.com/baanboard/showthread.php?t=8929&highlight=call.session) also.

monica23
17th December 2007, 07:01
thanks for reply mark...i try to connect baan 5.... yeah i can see dialogue box....

mark_h
17th December 2007, 17:54
What is in tccomdllbaan? Post the code that you use. I know the thread I posted contains a sample dll that I know works for Baan IV, but I do not know about Baan 5.

monica23
18th December 2007, 15:47
right now i try for baan 4

mark_h
18th December 2007, 20:17
Here is what works for me on baan 4:

This code is in the library tdapidllrecpt

| Used this from excel to call some of my sessions.
function extern call.session(const string sessname())
{
zoom.to$(sessname,Z.SESSION, "", "", 0)
}



Excel VB code to call the above library and launch a given session.

Sub test1()
Set BaanObj = CreateObject("Baan4.Application")
ThisWorkbook.Sheets("Performance").Activate
BaanObj.Timeout = 10
On Error GoTo BaanAutomationError

B_function = "call.session(" & Chr(34) & "tiitm0101m000" & Chr(34) & ")"
BaanObj.ParseExecFunction "otdapidllrecpt", B_function

BaanObj.Quit
Set BaanObj = Nothing
' error handling
Exit Sub

BaanAutomationError:
MsgBox "Baan IV automation error: " & BaanObj.Error
MsgBox "Return value function: " & B_function & " " & BaanObj.ReturnValue
BaanObj.Quit
Set BaanObj = Nothing
Exit Sub

End Sub


Good luck!