Opening and Closing JSM
Posted: Wed Mar 29, 2017 6:59 am
I am using Integrator and the PDFDocumentService and SMTPMailService to create a PDF, email it and finally delete it off the server.
I created 3 separate functions to do each of the above actions. Each of these actions open and close the JSM server.
There is one main "run" function that invokes the other functions. I want to be able to submit this function instead of waiting on it (call).
Each function exchanges the wk_Status with the *ALWAYS option.
Is it ok to be opening and closing the JSM Server repeatedly or should I open it once, do everything and then close it?
I really don't like having really big code files, so if I need open it once, can I pass (exchange) the handle around?
As an example, I have these functions The "run" one is the main function and looks like
The Create, Email and Delete all have their own JSMX_OPEN and JSMX_CLOSE commands.
I created 3 separate functions to do each of the above actions. Each of these actions open and close the JSM server.
There is one main "run" function that invokes the other functions. I want to be able to submit this function instead of waiting on it (call).
Each function exchanges the wk_Status with the *ALWAYS option.
Is it ok to be opening and closing the JSM Server repeatedly or should I open it once, do everything and then close it?
I really don't like having really big code files, so if I need open it once, can I pass (exchange) the handle around?
As an example, I have these functions The "run" one is the main function and looks like
Code: Select all
function options(*DIRECT) rcv_list(#JSMXMessages)
define_com class(#VLFServerTraceHandler) scope(*APPLICATION)
* fields we receive from the calling progam
group_by name(#ReceiveFields) fields(#CLOFID #CLOCN #CLOD)
* list we receive from the calling program, will populate with messages from JSM operations
def_list name(#JSMXMessages) fields(#JSMXSTS #JSMXMSG) type(*WORKING) entrys(*MAX)
#SYS_APPLN.TraceMessageText( "Running Sales Analysis Report" )
* default to an error state
#wk_Status := ER
exchange fields(#wk_Status) option(*ALWAYS)
* the exchange board is cleared after every function call, so we have to exchange it every time
exchange fields(#CLOFID #CLOCN #CLOD)
call process(*DIRECT) function(CreateSalesAnalysisReport) pass_lst(#JSMXMessages)
if (#wk_Status <> OK)
return
endif
* the file path is exchanged back to us
exchange fields(#wk_FilePath)
call process(*DIRECT) function(EmailSalesAnalysisReport) pass_lst(#JSMXMessages)
if (#wk_Status <> OK)
return
endif
exchange fields(#wk_FilePath)
call process(*DIRECT) function(DeleteSalesAnalysReport) pass_lst(#JSMXMessages)
if (#wk_Status <> OK)
return
endif
#wk_Status := OK