Calling BSFN from external DLL

LHoffman

Active Member
Hello everybody,

I have a DLL library which I´m calling 2 BSFN from there.

When I call a C BSFN, it works fine, but when I call a NER I got a strange behavior on JCHAR parameters.

Here´s a piece of code which call C BSFN

<font class="small">Code:</font><hr /><pre>
ID idResult;
int j = 0;
INT NumErrors = 0;
INT NumWarnings = 0;
LPJDEERROR_RECORD ErrorRec;
DSD0000051 dsGetCompanyName;

// jdeCallObject variables
LPCG_BHVR lpVoid = NULL;
LPVOID lpDS = NULL;
LPBHVRCOM lpBhvrCom = NULL;
ERROR_EVENT_KEY EventKeyLocal;

// Set up the lpBhvrCom amd lpVoid objects.
jdeCreateBusinessFunctionParms(hUser1, &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.iGridCol = 0;
EventKeyLocal.iGridRow = 0;
EventKeyLocal.wEvent = 1;
lpBhvrCom->lpEventKey = (LPVOID)&EventKeyLocal;

//Initialize data structure
memset((void *) &dsGetCompanyName, (int) '\0', sizeof(DSD0000051));


//
// Pass the function parameter through DS
//
jdeStrncpy(dsGetCompanyName.szCompany, (const JCHAR *) szCompania,DIM(dsGetCompanyName.szCompany));

idResult = jdeCallObject( _J("GetCompanyName"),
NULL,
lpBhvrCom,
lpVoid,
&dsGetCompanyName,
(void *)NULL,
(int)0,
(JCHAR *) NULL,
(JCHAR *) NULL,
(int)0);

printf("\nGetCompanyName return: %d\n",idResult);

// Does the call have errors?
if (jdeErrorGetCountEx(lpBhvrCom, &NumErrors, &NumWarnings, lpVoid) > 0)
{
jdeErrorSetToFirstEx(lpBhvrCom, lpVoid);
while (ErrorRec = jdeErrorGetNextDDItemNameInfoEx(lpBhvrCom, lpVoid))
{
// Process Errors here
}
}

// Free memory used by lpBhvrCom and lpVoid
jdeFree(((LPCG_BHVR)lpVoid)->lpErrorEventKey);
jdeErrorTerminateEx(((LPCG_BHVR)lpVoid)->lpHdr);
jdeFreeBusinessFunctionParms(lpBhvrCom, lpVoid);

jdePrintf(_J("Company: %s"), dsGetCompanyName.szCompanyName);
</pre><hr />

Here´s a piece of code which call a NER BSFN

<font class="small">Code:</font><hr /><pre>
ID idResult;
int j = 0;
INT NumErrors = 0;
INT NumWarnings = 0;
LPJDEERROR_RECORD ErrorRec;
DSDN0700760 dsGetAlphaName = {0};

// jdeCallObject variables
LPCG_BHVR lpVoid = NULL;
LPVOID lpDS = NULL;
LPBHVRCOM lpBhvrCom = NULL;
ERROR_EVENT_KEY EventKeyLocal;

// Set up the lpBhvrCom amd lpVoid objects.
jdeCreateBusinessFunctionParms(hUser1, &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.iGridCol = 0;
EventKeyLocal.iGridRow = 0;
EventKeyLocal.wEvent = 1;
lpBhvrCom->lpEventKey = (LPVOID)&EventKeyLocal;

//Initialize data structure
memset((void *) &dsGetAlphaName, (int) '\0', sizeof(DSDN0700760));

//
// Pass the function parameter through DS
//
MathCopy(&dsGetAlphaName.mnAddressNumberIn_AN8, &mnCadastro);

idResult = jdeCallObject( _J("GetFirstAndLastNameFromAddrBook"),
NULL,
lpBhvrCom,
lpVoid,
&dsGetAlphaName,
(void *)NULL,
(int)0,
(JCHAR *) NULL,
(JCHAR *) NULL,
(int)0);

printf("\nGetAlphaName return: %d\n",idResult);

// Does the call have errors?
if (jdeErrorGetCountEx(lpBhvrCom, &NumErrors, &NumWarnings, lpVoid) > 0)
{
jdeErrorSetToFirstEx(lpBhvrCom, lpVoid);
while (ErrorRec = jdeErrorGetNextDDItemNameInfoEx(lpBhvrCom, lpVoid))
{
// Process Errors here
}
}

// Free memory used by lpBhvrCom and lpVoid
jdeFree(((LPCG_BHVR)lpVoid)->lpErrorEventKey);
jdeErrorTerminateEx(((LPCG_BHVR)lpVoid)->lpHdr);
jdeFreeBusinessFunctionParms(lpBhvrCom, lpVoid);

jdePrintf(_J("Alpha Name: %s"),&dsGetAlphaName.szEmpFirstName_EMPFNAME);
</pre><hr />

After call NER from jdeCallObject the JCHAR parameters from DataStruct(dsGetAlphaName) apparently is populated with Unicode caracters(appears like little squares in VS watch window)

Additional information

<ul type="square">[*]E1 9.0, Wintel, Oracle 10.2.0.3.0, Microsoft Visual Studio 2005
[*]VS Project Preprocessor Definitions: KERNEL;WIN32;_DEBUG;_CONSOLE
[*]VS Project Include directories: C:\e900\system\include;C:\e900\system\includev;C:\e900\DV900\include
[*]VS Project Library directories: C:\e900\system\lib32;C:\e900\system\libv32
[*]VS Project Dependencies: jdekrnl.lib jdeuser.lib jdel.lib jdeunicode.lib
[/list]

Is there a reason for that NER behavior?

Thanks!
 
Hi,

There should be no differnece between C and NER...

What is the F0101.ABALPHA field populated with for the AN8 you are fetching?

Craig
 
Hi Craig,

For F0101.AN8 = 28108 I have F0101.ALPH = 'LISTA TESTE', using N0700760 in a APPL it works fine.

But calling that NER through my C code, I have a strange output in VS Watch Window(please see the attachment).

Any idea? Thanks!
 

Attachments

  • 164337-NER.doc
    70 KB · Views: 118
Back
Top