Re:JDB_InitEnv

  • Thread starter serge_viardot58
  • Start date

serge_viardot58

Member
Re:JDB_InitEnv

first
if you could send the source code, i'im interset
Second
Do you=
check the existence of the BSFN into the the source and include director=
y and into the dll ?
[email protected]

Tojdelistsubscr=
[email protected]

Cc

DateFri, 6 Feb 2004 11:35:27 -0600

SubjectR=
e:JDB_InitEnv



r as the dlls, I have done a DllImport on jdekrnl.dll for the JDB_InitEnv=
(and several other JDB APIs). The Environment is DEMOB73. If I enter tha=
t into the Environment field on the login screen, then everything seems t=
o be fine. I can do an InitUser, OpenTable, SelectAll, and Fetch fine. It=
is just if I go to the Available Enironement screen (either through visu=
al assist or through just clicking on OK with no environement filled in).=
I have tested this on a normal OW install and it does seem to be fine, so=
it may just be that this particular function is not built for DEMO jr. T=
hat is probably OK, but a little annoying. Also, the same thing doesn't o=
ccur when I am logining into DEMO jr after clicking on Solution Explorer =
or OExplorer.
: http://www.jdelist.com/ubb/showthreaded.php?Cat=3D&Board=3DOWDEV&Number=
=3D67464
stop receiving these messages, login to http://www.jdelist.com/forums, c=
lick Control Panel, then click Edit by "Subscribe / Unsubscribe from rece=
iving board posts by email, change message notifications, etc." and adjus=
t your subscription preferences. JDEList is not affiliated with JDEdwards=
=AE


Serge Viardot
Ing=E9nieur de D=E9veloppement
Division Industri=
e
[email protected]
 
Re:JDB_InitEnv

Well, this is C# so it is not relevante to other languages. I believe even managed C++ has a different mechanism.

Here is the basic Code for the JDB_InitEnv. This seems to work as I have done an InitEnv, InitUser, OpenTable, SelectAll, Fetch in sequence and all have returned JDEDB_PASSED. This was basically a proof of concept. I have moved on to writting a Class that wraps the MathNumeric Structure and APIs. Now I have some interesting issues trying to pass and return a C structure to and from the C# managed code.

// project created on 2/4/2004 at 6:28 AM

using System;
using System.Runtime.InteropServices;

namespace MyNamespace
{
class myClass
{
private IntPtr hEnv;
private int iStatus;

public myClass()
{
iStatus = JDEDB_FAILED;
try
{
Connect();
}
catch(System.Exception e)
{
Console.WriteLine("Message: {0}", e.Message);
}
}

public void Connect()
{
iStatus = JDEDB_FAILED;
try
{
if(JDB_InitEnv(ref hEnv) == JDEDB_PASSED)
iStatus = JDEDB_PASSED;
}
catch(System.Exception e)
{
throw e;
}
}



[DllImport ("jdekrnl.dll")]
private static extern int JDB_InitEnv (
[MarshalAs(UnmanagedType.SysInt)] ref IntPtr hEnv);

public const int JDEDB_FAILED_REC_CHANGE = -5;
public const int JDEDB_RECORD_LOCKED = -4;
public const int JDEDB_NODBDATA = -3;
public const int JDEDB_INVALID_USERPWD = -2;
public const int JDEDB_ERROR = -1;
public const int JDEDB_NODATA = 0;
public const int JDEDB_FAILED = 0;
public const int JDEDB_PASSED = 1;
public const int JDEDB_COMMIT_AUTO = 0; /* Auto-commitment. */
public const int JDEDB_COMMIT_MANUAL = 1; /* Manual commitments. */


}
}
 
Re:JDB_InitEnv

This is the C++ code i use to connect to jde, as you notice, you have to do some initialisation of some structures before to use it :
BOOL CJdeWorkFlowDlg::JDEConnect(CString cSzUser, CString cSzPassWord)
{
/************************************************************************
* Variable and Structure Declarations
************************************************************************/
BOOL ReturnValue = true;
int iIndex;
ID idJDBReturn = JDEDB_PASSED;
BOOL bReportSuccess = FALSE;
char szEnvironment[255],szUser[255],szPassWord[255];
int nSize,iLength;
/************************************************************************
* Structure Declarations
************************************************************************/

/************************************************************************
* Declare structures
************************************************************************/
/************************************************************************
/* Initialize Values
*************************************************************************/
/************************************************************************
/* connect to JDE
*************************************************************************/
nSize=sizeof(szEnvironment);
iLength=(int)cSzUser.GetLength();
strcpy(szUser,cSzUser.Left(iLength));
iLength=(int)cSzPassWord.GetLength();
strcpy(szPassWord,cSzPassWord.Left(iLength));
GetPrivateProfileString("CONNECTION","Environment","DV7333",szEnvironment,nSize,"WorkFlow.ini");
if (strlen(szUser)==0)
{
ReturnValue=false;
m_StatusBar.SetPaneText(0,"pas de nom d'utilisateuri");
}
if (strlen(szPassWord)==0)
{
ReturnValue=false;
m_StatusBar.SetPaneText(0,"pas de mot de passe");
}

if (strlen(szEnvironment)==0)
{
ReturnValue=false;
m_StatusBar.SetPaneText(0,"pas d'envionnement défini");
}
if (ReturnValue)
{
if(JDB_InitEnvOvr(&hEnv,szEnvironment,szUser,szPassWord)!=JDEDB_PASSED)
{
m_StatusBar.SetPaneText(0,"JDB_InitEnvOvr failed");
ReturnValue=false;
}
}
if (ReturnValue)
{
// Initialize User
if(JDB_InitUser(hEnv, &hUser, NULL,JDEDB_COMMIT_AUTO)!=JDEDB_PASSED)
{
m_StatusBar.SetPaneText(0,"JDB_InitUser failed");
ReturnValue=false;
}
if (ReturnValue)
{
// Set up the lpBhvrCom amd lpVoid objects
jdeCreateBusinessFunctionParms(hUser, &lpBhvrCom,(LPVOID*) &lpVoid);
lpVoid->lpHdr = jdeErrorInitializeEx();
lpVoid->lpErrorEventKey = (LPERROR_EVENT_KEY) jdeAlloc(COMMON_POOL, sizeof(ERROR_EVENT_KEY), MEM_ZEROINIT | MEM_FIXED);
lpVoid->lpHdr->nCurDisplayed = -1;
lpBhvrCom->lpObj->lpFormHdr = lpVoid->lpHdr;
//EventKeyLocal.hwndCtrl = NULL;
EventKeyLocal.hwndCtrl = GetSafeHwnd();
EventKeyLocal.iGridCol = 0;
EventKeyLocal.iGridRow = 0;
EventKeyLocal.wEvent = 1;
lpBhvrCom->lpEventKey = (LPVOID)&EventKeyLocal;
lpBhvrCom->hDlg=GetSafeHwnd();
}
}
/************************************************************************
* Function Clean Up
************************************************************************/

return ReturnValue;

}
hEnv should be an HENV type.
Hope this should help
 
Back
Top