Troubles using jdeLaunchUBEEx in a BSFN

Alpinist

Active Member
Has anyone used the jdeLaunchUBEEx to successfully launch a custom UBE from a BSFN. I included my code below and the input variables are populated when it calls the API, yet the UBE is not submitted.
I've checked OCM's and the BSFN compiles. I've looked at example's of standard E1 functions that do this, and I don't see any fundamental differences, but I must be missing something.
Any ideas would be most appreciated.
I'm working in E1, 8.12, with 8.97
Thank you.

<font class="small">Code:</font><hr /><pre> #include <jde.h>

#define b5543pop_c


#include <b5543pop.h>


/**************************************************************************
* Business Function: SubmitR5543POPUBE
*
* Description: Submit R55POPUBE
*
* Parameters:
* LPBHVRCOM lpBhvrCom Business Function Communications
* LPVOID lpVoid Void Parameter - DO NOT USE!
* LPDSD554 lpDS Parameter Data Structure Pointer
*
*************************************************************************/

JDEBFRTN (ID) JDEBFWINAPI SubmitR5543POPUBE (LPBHVRCOM lpBhvrCom, LPVOID lpVoid, LPDSD5543POP lpDS)

{
/************************************************************************
* Variable declarations
************************************************************************/
ID idReturnCode = ER_SUCCESS;
ID idJDEDBResult = 0;
/************************************************************************
* Declare structures
************************************************************************/
DSRIR5543POP ds5543pop = {0};

/************************************************************************
* Declare pointers
************************************************************************/
HUSER hUser = (HUSER) NULL;
PUBEVAR pUbeVar = (PUBEVAR)NULL;
/************************************************************************
* Check for NULL pointers
************************************************************************/
if ((lpBhvrCom == (LPBHVRCOM) NULL) ||
(lpVoid == (LPVOID) NULL) ||
(lpDS == (LPDSD5543POP) NULL))
{
jdeErrorSet (lpBhvrCom, lpVoid, (ID) 0, _J("4363"), (LPVOID) NULL);
return ER_ERROR;
}

idJDEDBResult = JDB_InitBhvr (lpBhvrCom,
&hUser,
(JCHAR *)NULL,
JDEDB_COMMIT_AUTO);

if (idJDEDBResult == JDEDB_FAILED)
{
jdeErrorSet(lpBhvrCom, lpVoid, (ID) 0, _J("078S"), (LPVOID) NULL);
return (ER_ERROR);
}


/************************************************************************
* Set pointers
************************************************************************/
pUbeVar = jdeAlloc(COMMON_POOL, sizeof(struct tagUBEVAR),MEM_ZEROINIT);
/************************************************************************
* Main Processing
************************************************************************/
if (pUbeVar != (PUBEVAR)NULL)
{
memset((void *)pUbeVar, (int)_J('\0'), sizeof(pUbeVar));

/*--------------------------------------------------------------------
* Load Ube Structure
*-------------------------------------------------------------------*/
pUbeVar->bPreview = FALSE;
jdeNIDcpy((JCHAR *)pUbeVar->szReport,(const JCHAR *)_J("R5543POP"));
jdeStrcpy((JCHAR *)pUbeVar->szVersion, (const JCHAR *)_J("PHA0003"));

GetLocalEnvironmentName(pUbeVar->szEnhv, 11);
pUbeVar->idRunTime = (GLRTID)lpBhvrCom->hDlg << 16;

/*--------------------------------------------------------------------
* Run the UBE Asynchronously
*-------------------------------------------------------------------*/
pUbeVar->bSynchFlag = TRUE;
/*--------------------------------------------------------------------
* Run the UBE in Batch Mode
*-------------------------------------------------------------------*/
pUbeVar->bBatchFlag = TRUE;
/*--------------------------------------------------------------------
* Load R5543POP Structure
*-------------------------------------------------------------------*/
memset((void *)&ds5543pop, (int)_J('\0'), sizeof(ds5543pop));

jdeStrcpy((JCHAR *)ds5543pop.szEdiUserId, (const JCHAR *)lpDS->szEdiUserId);
jdeStrcpy((JCHAR *)ds5543pop.szEdiBatchNumber, (const JCHAR *)lpDS->szEdiBatchNumber);
jdeStrcpy((JCHAR *)ds5543pop.szEdiTransactNumber, (const JCHAR *)lpDS->szEdiTransactNumber);

/*--------------------------------------------------------------------
* Launch the Ube
*-------------------------------------------------------------------*/
idReturnCode = jdeLaunchUBEEx((HUSER)hUser, (PUBEVAR)pUbeVar, (LPVOID)&ds5543pop,
lpBhvrCom);

MathCopy(&lpDS->mnDocumentOrderInvoiceE, &ds5543pop.mnDocumentOrderInvoiceE);


jdeFree(pUbeVar);
}
/************************************************************************
* Function Clean Up
************************************************************************/

if (hUser != NULL)
{
JDB_FreeBhvr(hUser);
}

return (idReturnCode);
}
</pre><hr />
 
Well, my first guess is that pUbeVar->bSynchFlag = TRUE; should be pUbeVar->bSynchFlag = FALSE;. At 8.12 (and prior after a certain SP) you had to do an asynchronous launch. To verify this look at the COK error logs with SAW and see if there is not a message in the logs complaining about how the UBE was launched.
 
Thank you for the response. I found a solution on metalink that gave the same instruction and I'm building a package tonight to test it.
Thanks again.
 
[ QUOTE ]
Well, my first guess is that pUbeVar->bSynchFlag = TRUE; should be pUbeVar->bSynchFlag = FALSE;. At 8.12 (and prior after a certain SP) you had to do an asynchronous launch. To verify this look at the COK error logs with SAW and see if there is not a message in the logs complaining about how the UBE was launched.

[/ QUOTE ]

I know this solution has already been seen by the original poster, but the starting point for this was Tools release 8.9.

Some other comments about the code... since you are allocing pUBEVar with MEMZEROINIT, you don't need to memset to all zeros, either, since it already is. Since you've declared ds5543pop with a = { 0 }; you don't need to memset it to all zeros either, it already is.

Note that since you have to call the UBE asynch, you can't get return values from the RI data structure either, since the UBE is asynch.

(i.e., MathCopy(&lpDS->mnDocumentOrderInvoiceE, &ds5543pop.mnDocumentOrderInvoiceE); probably isn't doing what you think)
 
I've updated my function as follows:
1. I changed the sync flag = FALSE. Now it runs Async.
2. The BSFN data structure matches the UBE data structure exactly. I read somewhere that they needed to match.

Questions:
1. Could you confirm that I can or cannot get a return value from an async call? Why or why not?
2. Will leaving the memset cause an issue?
3. What do you mean the MathCopy is not doing what I think? I was trying to return the value from the UBE back to the business service. Can that be done? How?
4. I suppose the biggest question would be am I on the right track with being able to call a UBE from a business function? Is it going to work or is there a different solution that I should explore?

<font class="small">Code:</font><hr /><pre>/**************************************************************************
* Business Function: SubmitUBER5543POP
*
* Description: Submit UBE R5543POP
*
* Parameters:
* LPBHVRCOM lpBhvrCom Business Function Communications
* LPVOID lpVoid Void Parameter - DO NOT USE!
* LPDSD554 lpDS Parameter Data Structure Pointer
*
*************************************************************************/

JDEBFRTN (ID) JDEBFWINAPI SubmitUBER5543POP (LPBHVRCOM lpBhvrCom, LPVOID lpVoid, LPDSD5543002 lpDS)

{
/************************************************************************
* Variable declarations
************************************************************************/
ID idReturnCode = ER_SUCCESS;
ID idJDEDBResult = 0;
/************************************************************************
* Declare structures
************************************************************************/
DSRIR5543POP dsReportInterconnect ={0};
/************************************************************************
* Declare pointers
************************************************************************/
HUSER hUser = (HUSER) NULL;
PUBEVAR pUbeVar = (PUBEVAR)NULL;
/************************************************************************
* Check for NULL pointers
************************************************************************/
if ((lpBhvrCom == (LPBHVRCOM) NULL) ||
(lpVoid == (LPVOID) NULL) ||
(lpDS == (LPDSD5543002) NULL))
{
jdeErrorSet (lpBhvrCom, lpVoid, (ID) 0, _J("4363"), (LPVOID) NULL);
return ER_ERROR;
}

idJDEDBResult = JDB_InitBhvr (lpBhvrCom,
&hUser,
(JCHAR *)NULL,
JDEDB_COMMIT_AUTO);

if (idJDEDBResult == JDEDB_FAILED)
{
jdeErrorSet(lpBhvrCom, lpVoid, (ID) 0, _J("078S"), (LPVOID) NULL);
return (ER_ERROR);
}


/************************************************************************
* Set pointers
************************************************************************/
pUbeVar = jdeAlloc(COMMON_POOL, sizeof(struct tagUBEVAR),MEM_ZEROINIT);

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

/*--------------------------------------------------------------------
* Load Ube Structure
*-------------------------------------------------------------------*/
pUbeVar->bPreview = FALSE;
jdeNIDcpy((JCHAR *)pUbeVar->szReport,(const JCHAR *)_J("R5543POP"));
jdeStrcpy((JCHAR *)pUbeVar->szVersion, (const JCHAR *)_J("PHA0003"));

GetLocalEnvironmentName(pUbeVar->szEnhv, 11);
pUbeVar->idRunTime = (GLRTID)lpBhvrCom->hDlg << 16;

/* PrintImmediate=TRUE */
pUbeVar->zReportFlags |= eDRRPTPrintImmediate;
/* SaveOutput=TRUE */
pUbeVar->zReportFlags |= eDRRPTSaveOutput;

/*--------------------------------------------------------------------
* Run the UBE Asynchronously
*-------------------------------------------------------------------*/
pUbeVar->bSynchFlag = FALSE;
/*--------------------------------------------------------------------
* Run the UBE in Batch Mode
*-------------------------------------------------------------------*/
pUbeVar->bBatchFlag = TRUE;
/*--------------------------------------------------------------------
* Load R5543POP Structure
*-------------------------------------------------------------------*/
memset((void *)&dsReportInterconnect, (int)_J('\0'), sizeof(dsReportInterconnect));

jdeStrcpy((JCHAR *)dsReportInterconnect.szEdiUserId, (const JCHAR *)lpDS->szEdiUserId);
jdeStrcpy((JCHAR *)dsReportInterconnect.szEdiBatchNumber, (const JCHAR *)lpDS->szEdiBatchNumber);
jdeStrcpy((JCHAR *)dsReportInterconnect.szEdiTransactNumber, (const JCHAR *)lpDS->szEdiTransactNumber);

/*--------------------------------------------------------------------
* Launch the Ube
*-------------------------------------------------------------------*/
idReturnCode = jdeLaunchUBEEx((HUSER)hUser, (PUBEVAR)pUbeVar, (LPVOID)&dsReportInterconnect,
lpBhvrCom);

MathCopy(&lpDS->mnDocumentOrderInvoiceE, &dsReportInterconnect.mnDocumentOrderInvoiceE);


jdeFree(pUbeVar);
}
/************************************************************************
* Function Clean Up
************************************************************************/

if (hUser != NULL)
{
JDB_FreeBhvr(hUser);
}

return (idReturnCode);
} </pre><hr />
 
[ QUOTE ]
I've updated my function as follows:
1. I changed the sync flag = FALSE. Now it runs Async.
2. The BSFN data structure matches the UBE data structure exactly. I read somewhere that they needed to match.

Questions:
1. Could you confirm that I can or cannot get a return value from an async call? Why or why not?
2. Will leaving the memset cause an issue?
3. What do you mean the MathCopy is not doing what I think? I was trying to return the value from the UBE back to the business service. Can that be done? How?
4. I suppose the biggest question would be am I on the right track with being able to call a UBE from a business function? Is it going to work or is there a different solution that I should explore?


[/ QUOTE ]

1. You cannot get a return value from a RI data structure with an Asynch call, which is the only kind of call you can do from a BSFN run from an interactive app. This is because an asynch call running in your callobj kernel sends a message to a UBE kernel, which inserts it into F986110 and then queue kernel schedules the job to run, when there is an available slot in the queue. Control is returned to your BSFN before the UBE is actually run.

If your BSFN is called from another UBE, then you can call child UBEs synchronously (i.e. in the same process), and then you will be able to get a return value.

2. no, it doesn't hurt. Just redundant.

3. I think 1. above covers why.

4. You can call UBEs from BSFNs. You can only get RI retrn values populated from a synch call, and synch calls can only be done from UBE to UBE, not from Interactive app to UBE.
 
Thank you for the response. This is really helping me to understand my issue.
.
I have one point I'd like to clarify. I'm using Oracle BPEL, where I've created a process flow, which calls an E1 Business Service, which calls this E1 BSFN we've been discussing, then calls UBE#1, which then calls UBE#2.
.
You said that a return value is not possible from a Interactive application calling the BSFN due to the async process.
.
In debugging the flow, the variables from the business service are passed into the BSFN correctly. It's just that the API jdeLaunchUBEEx is not launching the UBE.
.
1. Do you know if a return value is possible in the way I've described above?
.
2. Return value aside, can I even expect to launch the UBE in this manner?
.
Thank you.
 
Back
Top