Like this that I use to "upsert" an employee from Active Directory attibutes
Code: Select all
exchange fields(#DistinguishedName)
call process(*DIRECT) function(PTOEMPUpsert) pass_lst(#MessageList)
The Function structure is typically something like this
Code: Select all
function options(*DIRECT) rcv_list(#MessageList)
* working fields / lists / components
* main function flow
return
* method routines
I specifically use the "return" statement at the end of every Function, I have tried using the if_error(*NEXT) and *RETURN and still nothing. I have verifed this by having trace statements immediately before the Function, inside the Function and after the Function.
Code: Select all
#SYS_APPLN.TraceMessageData( "Calling PTOUpsert Function" )
exchange fields(#DistinguishedName)
call process(*DIRECT) function(PTOEMPUpsert) pass_lst(#MessageList)
#SYS_APPLN.TraceMessageData( "Returned from PTOEMPUpsert. Status: &1 EmployeeId: &2" #wk_Status #EmployeeId )
From what I have read in the docs, it seems like Functions are mainly designed for iSeries 5250 screen design and use.
Am I using Functions in an un-intended way? Should I just avoid them as much as I can? I can't stay away from them all together because they appear to be the only way to "submit" a long running job to batch.
How to I get a Function to ALWAYS return control?