Print Immediate

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 implemented this solution and working very well. and we use this solution whenever we calling report/ube in Async mode.

Try to replace this line

pUbeVar->zReportFlags |= eDRRPTPrintImmediate; // Print Immediate

with this one.


pUbeVar.zReportFlags = eDRRPTSaveOutput | eDRRPTPrintImmediate;

Hope it works for you.

-Chaitanya
 
In addition to previous post.

eDRRPTPrintImmediate

This is part of data structure and set to blank.

-Chaitanya
 
At compile it is always asking me for "pUbeVar->ReportFlags" instead of "pUbeVar.ReportFlags". It will error at build if I do not use this syntax.

Also, does this solution work on a UNIX enterprise server without sending the print request separately?
 
zUBEVar.zReportFlags = eDRRPTSaveOutput | eDRRPTPrintImmediate;

We implemented this solution on AS400 not on Unix.
 
Has anyone done this mod to force Print Immediate for a UNIX or Windows enterprise server?

Also, should I be able to verify this running it locally on my development machine? If so, would I be required to route this to a printer that is setup on my development PC or one that is setup in JDE or both?
 
Back
Top