Need Help!!!

badri01

Active Member
Hi List,
I am trying to call a report from a C function using jdeLaunchUBEEx.I have used the codes from Address Book example and B4200310 for creating this function(Whipping Boy's previous posts helped me for doing it).I have done all the compiler settings ,But getting 2 hard errors when Compiling.Please have a look and any help will be really appreciated.
Error is as follows
----------------------------------------------------------------------
--------------------Configuration: TestUBECall - Win32 Debug--------------------
Compiling...
TestUBECall.cpp
C:\badri\JDE Docs\CallUBE\TestUBECall.cpp(67) : error C2440: '=' : cannot convert from 'void *' to 'struct tagUBEVAR *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
C:\badri\JDE Docs\CallUBE\TestUBECall.cpp(80) : error C2227: left of '->szCMComputerID' must point to class/struct/union
Error executing cl.exe.

TestUBECall.obj - 2 error(s), 0 warning(s)
-----------------------------------------------------------------------
-----------------------------------------------------------------------
C Program is as follows
-----------------------------------------------------------------------

#include <jde.h>


// The make file is a standard VC++ 6.0 project for a Win32 Console Application,
// Win32 Dynamic-Link Library, etc.
// The following settings need to be changed:
// define KERNEL (/D "KERNEL")
// add include paths ../include,../includea,../includev
// change byte alignment to 1 byte and change code generation to _stdcall if
// using the JDEError API's.
// link with JDEKRNL.LIB & JDEL.LIB
//
// The command line parameters to the program are:
// -u user -p password -e environment

int _cdecl main()
{
HENV hEnv = NULL;
HUSER hUser = NULL;
HREQUEST hRequest = NULL;
LPJDEERROR_RECORD ErrorRec = NULL;
INT NumErrors = 0;
INT NumWarnings = 0;
ID idResult;
LPCG_BHVR lpVoid = NULL;
LPVOID lpDS = NULL;
LPBHVRCOM lpBhvrCom = NULL;
ERROR_EVENT_KEY EventKeyLocal;


// Initialize Environment Handle
if(JDB_InitEnvOvr(&hEnv,"DEMOB73","DEMO","DEMO")!=JDEDB_PASSED)
{
fprintf(stderr,"JDB_InitEnvOvr failed.\n");
return -1;
}

// Initialize User
if(JDB_InitUser(hEnv, &hUser, NULL,JDEDB_COMMIT_AUTO)!=JDEDB_PASSED)
{
fprintf(stderr,"JDB_InitUser failed\n");
return -1;
}

// 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.iGridCol = 0;
EventKeyLocal.iGridRow = 0;
EventKeyLocal.wEvent = 1;
lpBhvrCom->lpEventKey = (LPVOID)&EventKeyLocal;

//=================================================

/************************************************************************
* Variable and Structure Declarations
************************************************************************/
PUBEVAR pUbeVar = (PUBEVAR)NULL;

/************************************************************************
* Main Processing
************************************************************************/
pUbeVar = jdeAlloc(COMMON_POOL, sizeof(struct tagUBEVAR),MEM_ZEROINIT);

if (pUbeVar != (PUBEVAR)NULL)
{
memset((void *)pUbeVar, (int)'\0', sizeof(pUbeVar));

/*--------------------------------------------------------------------
* Load Ube Structure
*-------------------------------------------------------------------*/
pUbeVar->bPreview = FALSE;
jdeNIDcpy((char *)pUbeVar->szReport,(const char *)"R5607COL");
strcpy((char *)pUbeVar->szVersion, (const char *)"SHA001"); /* CHG 2830649 */

strcpy((char *)pUbeVar->szMachineKey, (const char *)lpDS->szCMComputerID);
GetLocalEnvironmentName(pUbeVar->szEnhv, 11);
pUbeVar->idRunTime = (GLRTID)lpBhvrCom->hDlg << 16;

/*--------------------------------------------------------------------
* Run the UBE Asynchronously
*-------------------------------------------------------------------*/
pUbeVar->bSynchFlag = FALSE;

/*--------------------------------------------------------------------
* Run the UBE in Batch Mode
*-------------------------------------------------------------------*/
pUbeVar->bBatchFlag = TRUE;

/*--------------------------------------------------------------------
* Launch the Ube
*-------------------------------------------------------------------*/
jdeLaunchUBEEx((HUSER)hUser, (PUBEVAR)pUbeVar, (LPVOID)NULL,
lpBhvrCom);

}

//===================================================

// Clean up the lpBhvrCom and lpVoid objects and free the user and environment
jdeErrorClear(lpBhvrCom);
jdeFree(((LPCG_BHVR)lpVoid)->lpErrorEventKey);
jdeErrorTerminateEx(((LPCG_BHVR)lpVoid)->lpHdr);
jdeFreeBusinessFunctionParms(lpBhvrCom,lpVoid);
if(hUser)JDB_FreeUser(hUser);
if(hEnv)JDB_FreeEnv(hEnv);

printf("exit main\n");
return 0;
}
--------------------------------------------------------------------
Thanks in advance
Badri
 
You don't need to clear the memory, since the jdealloc has the MEM_ZEROINIT line, which sets the initial value.
Also, there seemed to be a } missing.

Then:
strcpy((char *)pUbeVar->szMachineKey, (const char *)lpDS->szCMComputerID);

You should remove the (const char *). Also. THe code should really be use jdeStrcpy.






/************************************************************************
* Main Processing
************************************************************************/
pUbeVar = jdeAlloc(COMMON_POOL, sizeof(struct tagUBEVAR),MEM_ZEROINIT);

if (pUbeVar != (PUBEVAR)NULL)
{
memset((void *)pUbeVar, (int)'\0', sizeof(pUbeVar));
 
Thanks Peter,
Can you be a lil more specific,I am really sorry I dont know C much.When you mean "You don't need to clear the memory",do you mean no need of "memset((void *)pUbeVar, (int)'\0', sizeof(pUbeVar)); .Also when I tried with jdeStrcpy ,I am getting 3 errors and a warning,It is as folllows,

-------------------Configuration: TestUBECall - Win32 Debug--------------------
Compiling...
TestUBECall.cpp
C:\Badri\JDE Docs\CallUBE\TestUBECall.cpp(67) : error C2440: '=' : cannot convert from 'void *' to 'struct tagUBEVAR *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
C:\Badri\JDE Docs\CallUBE\TestUBECall.cpp(81) : warning C4003: not enough actual parameters for macro 'jdeStrcpy'
C:\Badri\JDE Docs\CallUBE\TestUBECall.cpp(81) : error C2227: left of '->szCMComputerID' must point to class/struct/union
C:\Badri\JDE Docs\CallUBE\TestUBECall.cpp(81) : error C2059: syntax error : ')'
Error executing cl.exe.

TestUBECall.obj - 3 error(s), 1 warning(s)

Also Peter,If you have a simple code which functioned perfectly with a jdeLaunchUBEEx ,Please send it to me.
Thanking you once again
 
JdeStrcpy needs three elements (length is the other missing one).
Best bet is too within C, do a find in file search (in your source dorectory), for the words "jdeLaunchUBEEx". That way, you have your own working program to look at.
 
Hi Badri,

Were you able to get it work finally, coz I need to implement a similiar solution and I am stuck with these two errors. I would appreciate your help if you have a working piece of code in which you have resolved these errors.

Thanks in advance...
-Bipin
 
Back
Top