Pierce1991
Member
I am trying to utilize some recommendations I found on here for forcing a scheduled UBE to print immediately as it is run.
I have developed an automated process for my client that includes a call to R46171->R46471->R46472. They require the wave sheet to print out on the printer as it is run.
I have created a new business function that will replace the report interconnect call with a direct call to the API to submit the R46472 with the print immediate option set, as well as, calling the API to send a print request after R46472 is done running.
When I run this on the server, everything says it complete normally. I have the wave sheet, but it does not print on the printer. I am unable to generate any logs for the R46471, which is calling this business function. I can see them for R46171 and R46472, but not the R46471.
I was considering the modification that has been discussed previously on this site to use a F986110 trigger to send this print request. However, it won't make much sense to attempt that if I cannot even get this print request to work.
If anyone has any ideas, I would be eternally grateful.
My client is in B7333 SP23 and the business function code is as follows:
<font class="small">Code:</font><hr /><pre> JDEBFRTN (ID) JDEBFWINAPI CallR46472 (LPBHVRCOM lpBhvrCom, LPVOID lpVoid, LPDSD55CLUBE1 lpDS)
{
/************************************************************************
* Variable and Structure Declarations
************************************************************************/
PUBEVAR pUbeVar = (PUBEVAR)NULL;
SERVER_PRINT SvrPrint = {0};
PRT_PRINTER_INFO zPRTPrinterInfo = {0};
DSRIR46472 ds46472; /* Data Structure for R46472 */
HUSER hUser = (HUSER)NULL;
ID idJDBReturn = JDEDB_PASSED; /* DB API Return Code */
ID idReturnCode = ER_SUCCESS; /* Return Code */
/************************************************************************
* Declare structures
************************************************************************/
/************************************************************************
* Declare pointers
************************************************************************/
/************************************************************************
* Check for NULL pointers
************************************************************************/
if ((lpBhvrCom == (LPBHVRCOM) NULL) ||
(lpVoid == (LPVOID) NULL) ||
(lpDS == (LPDSD55CLUBE1) NULL))
{
jdeErrorSet (lpBhvrCom, lpVoid, (ID) 0, "4363", (LPVOID) NULL);
return ER_ERROR;
}
/**************************************************************************
* Initialize Behavior Routine
**************************************************************************/
idJDBReturn = JDB_InitBhvr((void *)lpBhvrCom, &hUser, (char *) NULL,
JDEDB_COMMIT_AUTO);
if (idJDBReturn != JDEDB_PASSED)
{
jdeSetGBRError(lpBhvrCom, lpVoid, (ID) 0, "078S"); /* "3143" */
return ER_ERROR;
}
/************************************************************************
* 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
*-------------------------------------------------------------------*/
jdeNIDcpy((char *)pUbeVar->szReport,(const char *)"R46472");
if (IsStringBlank(lpDS->szVersion))
{
strcpy((char *)pUbeVar->szVersion, (const char *)"AUTOCOM1");
}
else
{
strcpy((char *)pUbeVar->szVersion, (const char *)lpDS->szVersion);
}
pUbeVar->hUser = hUser;
/*--------------------------------------------------------------------
* Get machine name and environment
*-------------------------------------------------------------------*/
if((jdeGetHostName(pUbeVar->szMachineKey, 16, 0) !=0) ||
(GetLocalEnvironmentName(pUbeVar->szEnhv, 11) ==0))
{
idReturnCode = ER_ERROR;
}
else
{
/*--------------------------------------------------------------------
* Change UBE run parameters based on call type
*-------------------------------------------------------------------*/
pUbeVar->idRunTime = (GLRTID)lpBhvrCom->hDlg << 16;
pUbeVar->bBatchFlag = TRUE; // Batch mode (no prompting)
if (lpDS->cServer == '1')
{
pUbeVar->bSynchFlag = FALSE; // Asynchronously
pUbeVar->bPreview = FALSE;
pUbeVar->zReportFlags |= eDRRPTPrintImmediate; // Print Immediate
}
else
{
pUbeVar->bSynchFlag = TRUE; // Synchronously
pUbeVar->bPreview = TRUE;
}
/*--------------------------------------------------------------------
* Load R46472 Structure
*-------------------------------------------------------------------*/
memset((void *)&ds46472, (int)'\0', sizeof(ds46472));
MathCopy(&ds46472.mnPutawayTaskNumber, &lpDS->mnPutawayTaskNumber);
/*--------------------------------------------------------------------
* Launch the Ube
*-------------------------------------------------------------------*/
idJDBReturn = jdeLaunchUBEEx((HUSER)hUser, (PUBEVAR)pUbeVar, (LPVOID)&ds46472,
lpBhvrCom);
if(idJDBReturn != JDEDB_PASSED)
{
idReturnCode = ER_ERROR;
}
else
{
/*--------------------------------------------------------------------
* Send the print request
*-------------------------------------------------------------------*/
if(!IsStringBlank(lpDS->szPrinter) && (lpDS->cServer != '1'))
{
memcpy(&SvrPrint.mJobNumber,&pUbeVar->mnJobNum, sizeof(MATH_NUMERIC));
strcpy(SvrPrint.szHostName, pUbeVar->szMachineKey);
strcpy(zPRTPrinterInfo.szPrinter, lpDS->szPrinter);
zPRTPrinterInfo.ulNumberOfCopies = 1;
SvrPrint.cPrint = 'Y';
SvrPrint.cDelete = 'N';
prtPDF_SendPrintRequestEx(hUser,&SvrPrint,&zPRTPrinterInfo);
}
}
}
}
/************************************************************************
* Function Clean Up
************************************************************************/
jdeFree(pUbeVar);
return idReturnCode;
} </pre><hr />
I have developed an automated process for my client that includes a call to R46171->R46471->R46472. They require the wave sheet to print out on the printer as it is run.
I have created a new business function that will replace the report interconnect call with a direct call to the API to submit the R46472 with the print immediate option set, as well as, calling the API to send a print request after R46472 is done running.
When I run this on the server, everything says it complete normally. I have the wave sheet, but it does not print on the printer. I am unable to generate any logs for the R46471, which is calling this business function. I can see them for R46171 and R46472, but not the R46471.
I was considering the modification that has been discussed previously on this site to use a F986110 trigger to send this print request. However, it won't make much sense to attempt that if I cannot even get this print request to work.
If anyone has any ideas, I would be eternally grateful.
My client is in B7333 SP23 and the business function code is as follows:
<font class="small">Code:</font><hr /><pre> JDEBFRTN (ID) JDEBFWINAPI CallR46472 (LPBHVRCOM lpBhvrCom, LPVOID lpVoid, LPDSD55CLUBE1 lpDS)
{
/************************************************************************
* Variable and Structure Declarations
************************************************************************/
PUBEVAR pUbeVar = (PUBEVAR)NULL;
SERVER_PRINT SvrPrint = {0};
PRT_PRINTER_INFO zPRTPrinterInfo = {0};
DSRIR46472 ds46472; /* Data Structure for R46472 */
HUSER hUser = (HUSER)NULL;
ID idJDBReturn = JDEDB_PASSED; /* DB API Return Code */
ID idReturnCode = ER_SUCCESS; /* Return Code */
/************************************************************************
* Declare structures
************************************************************************/
/************************************************************************
* Declare pointers
************************************************************************/
/************************************************************************
* Check for NULL pointers
************************************************************************/
if ((lpBhvrCom == (LPBHVRCOM) NULL) ||
(lpVoid == (LPVOID) NULL) ||
(lpDS == (LPDSD55CLUBE1) NULL))
{
jdeErrorSet (lpBhvrCom, lpVoid, (ID) 0, "4363", (LPVOID) NULL);
return ER_ERROR;
}
/**************************************************************************
* Initialize Behavior Routine
**************************************************************************/
idJDBReturn = JDB_InitBhvr((void *)lpBhvrCom, &hUser, (char *) NULL,
JDEDB_COMMIT_AUTO);
if (idJDBReturn != JDEDB_PASSED)
{
jdeSetGBRError(lpBhvrCom, lpVoid, (ID) 0, "078S"); /* "3143" */
return ER_ERROR;
}
/************************************************************************
* 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
*-------------------------------------------------------------------*/
jdeNIDcpy((char *)pUbeVar->szReport,(const char *)"R46472");
if (IsStringBlank(lpDS->szVersion))
{
strcpy((char *)pUbeVar->szVersion, (const char *)"AUTOCOM1");
}
else
{
strcpy((char *)pUbeVar->szVersion, (const char *)lpDS->szVersion);
}
pUbeVar->hUser = hUser;
/*--------------------------------------------------------------------
* Get machine name and environment
*-------------------------------------------------------------------*/
if((jdeGetHostName(pUbeVar->szMachineKey, 16, 0) !=0) ||
(GetLocalEnvironmentName(pUbeVar->szEnhv, 11) ==0))
{
idReturnCode = ER_ERROR;
}
else
{
/*--------------------------------------------------------------------
* Change UBE run parameters based on call type
*-------------------------------------------------------------------*/
pUbeVar->idRunTime = (GLRTID)lpBhvrCom->hDlg << 16;
pUbeVar->bBatchFlag = TRUE; // Batch mode (no prompting)
if (lpDS->cServer == '1')
{
pUbeVar->bSynchFlag = FALSE; // Asynchronously
pUbeVar->bPreview = FALSE;
pUbeVar->zReportFlags |= eDRRPTPrintImmediate; // Print Immediate
}
else
{
pUbeVar->bSynchFlag = TRUE; // Synchronously
pUbeVar->bPreview = TRUE;
}
/*--------------------------------------------------------------------
* Load R46472 Structure
*-------------------------------------------------------------------*/
memset((void *)&ds46472, (int)'\0', sizeof(ds46472));
MathCopy(&ds46472.mnPutawayTaskNumber, &lpDS->mnPutawayTaskNumber);
/*--------------------------------------------------------------------
* Launch the Ube
*-------------------------------------------------------------------*/
idJDBReturn = jdeLaunchUBEEx((HUSER)hUser, (PUBEVAR)pUbeVar, (LPVOID)&ds46472,
lpBhvrCom);
if(idJDBReturn != JDEDB_PASSED)
{
idReturnCode = ER_ERROR;
}
else
{
/*--------------------------------------------------------------------
* Send the print request
*-------------------------------------------------------------------*/
if(!IsStringBlank(lpDS->szPrinter) && (lpDS->cServer != '1'))
{
memcpy(&SvrPrint.mJobNumber,&pUbeVar->mnJobNum, sizeof(MATH_NUMERIC));
strcpy(SvrPrint.szHostName, pUbeVar->szMachineKey);
strcpy(zPRTPrinterInfo.szPrinter, lpDS->szPrinter);
zPRTPrinterInfo.ulNumberOfCopies = 1;
SvrPrint.cPrint = 'Y';
SvrPrint.cDelete = 'N';
prtPDF_SendPrintRequestEx(hUser,&SvrPrint,&zPRTPrinterInfo);
}
}
}
}
/************************************************************************
* Function Clean Up
************************************************************************/
jdeFree(pUbeVar);
return idReturnCode;
} </pre><hr />