Calling Functions from Batch Jobs
Posted: Wed Aug 09, 2017 3:17 am
Hot on the heels of my last question about batch jobs ...
The Function that executes in batch all calls another Function in the same Process to collect report data. This is because the CreateReport Function is used by the ServerModule that displays the data to the user and the Email Function to create the PDF.
So the "batch" Function is submitted this way from the Server Module
It calls the "Create Report" Function to collect the data. Specifying anything but "*DIRECT" for the process results in a compilation error.
The Create Report looks like
What seems to be happening is that execution gets cut off after the call to the "CreateReport" Function as indicated by the trace output.
It just stops, that's all there is. There is no indication that the job actually finished as the next entry in the trace output should have been "CMGSANCreateReport Returned".
This works fine if I use "call" to invoke the CMGSANEmailReport but "submit" does not. There does not appear to be an error log. Nothing seems to have crashed, it seems like it just stopped executing. The PDF is never generated.
Any ideas on what would cause this? Am I doing something that I should not be?
Thanks,
Joe
The Function that executes in batch all calls another Function in the same Process to collect report data. This is because the CreateReport Function is used by the ServerModule that displays the data to the user and the Email Function to create the PDF.
So the "batch" Function is submitted this way from the Server Module
Code: Select all
#SYS_APPLN.TraceMessageData( "Submitting the CMGSAN Report" )
submit process(CMGSANReportProcess) function(CMGSANEmailReport) exchange(#OFOFID #OFOTY #CWJTYP #wk_StartDate #wk_EndDate #wk_PreviousStartDate #wk_PreviousEndDate #wk_CountryCode #wk_Email) job(MYJOB) jobq(QBATCH)
#SYS_APPLN.TraceMessageData( "CMGSAN Report has been submitted" )
Code: Select all
#SYS_APPLN.TraceMessageData( "Beginning Sending Sales Analysis Email To: &1" #wk_Email )
#SYS_APPLN.TraceMessageData( "Calling CMGSANCreateReport" )
exchange fields(#OFOFID #OFOTY #CWJTYP #wk_StartDate #wk_EndDate #wk_PreviousStartDate #wk_PreviousEndDate #wk_CountryCode)
call process(*DIRECT) function(CMGSANCreateReport) pass_lst(#HeaderList #OfficeList #ClientList)
#SYS_APPLN.TraceMessageData( "CMGSANCreateReport Returned" )
Code: Select all
exchange fields(#wk_Status) option(*ALWAYS)
#SYS_APPLN.TraceMessageText( "Beginning Collecting Sales Analysis Report Data" )
#wk_Status := ER
* stash data fields in working fields, this is so they don't get overridden when we fetch data
#wk_OfficeNumber := #OFOFID
#wk_OfficeType := #OFOTY
#wk_JobType := #CWJTYP
#ApplicationService.SetLibraryList( #wk_CountryCode )
#wk_Library := #ApplicationService.GetDataLibrary( #wk_CountryCode )
* load office data and the office's client data
#SYS_APPLN.TraceMessageText( "Loading Working Lists" )
#COM_OWNER.LoadWorkingLists
* calculate all the stuff
#SYS_APPLN.TraceMessageText( "Processing Working Lists" )
#COM_OWNER.ProcessWorkingLists
* finally add to and format the response list
#SYS_APPLN.TraceMessageText( "Formatting Response Lists" )
#COM_OWNER.LoadResponseLists
#SYS_APPLN.TraceMessageText( "Finished Collecting Sales Analysis Report Data" )
#wk_Status := OK
Code: Select all
2017-08-08 11:36:55.054 PRIM_APP 0 Beginning Sending Sales Analysis Email To: [email protected]
2017-08-08 11:36:55.054 PRIM_APP 0 Calling CMGSANCreateReport
2017-08-08 11:36:55.055 PRIM_APP 0 Beginning Collecting Sales Analysis Report Data
2017-08-08 11:36:55.056 PRIM_APP 0 Loading Working Lists
2017-08-08 11:36:55.121 PRIM_APP 0 Processing Working Lists
2017-08-08 11:36:55.122 PRIM_APP 0 Formatting Response Lists
2017-08-08 11:36:55.123 PRIM_APP 0 Finished Collecting Sales Analysis Report Data
This works fine if I use "call" to invoke the CMGSANEmailReport but "submit" does not. There does not appear to be an error log. Nothing seems to have crashed, it seems like it just stopped executing. The PDF is never generated.
Any ideas on what would cause this? Am I doing something that I should not be?
Thanks,
Joe