Page 1 of 1

Before Job Sub Routine

Posted: Tue Aug 08, 2006 5:26 am
by mcolen
I have written a routine with one argument which returns a single value answer. I need help in how to use this as a before-job subroutine and how to retreive the answer for use within the job. The code for the routine (which is currently saved as a transform) follows --

OPEN 'company' to COMPANY_FILE THEN
CALL DSLogInfo('opening company','Routine is GetCompanyId')
END ELSE
CALL DSLogFatal('Unable to open company','Routine is GetCompanyId')
END

READV COMPANY_ID FROM COMPANY_FILE,Arg1, 1 THEN
END ELSE
CALL DSLogFatal('Record Not Found ': Arg1 :' company','Routine is GetCompanyId')
END

Ans=COMPANY_ID

Posted: Tue Aug 08, 2006 5:30 am
by loveojha2
I need help in how to use this as a before-job subroutine and how to retreive the answer for use within the job
Open the Routine, change the Type of the Routine from the Transform Function to Before/After Subroutine. It is one of the combo box available right next to the Routine Name.

But To get the result it is advisable to use only as Transform Function otherwise you would need to write the return value to some temporary place may be sequential file from where you can use it within the job.

Posted: Tue Aug 08, 2006 5:31 am
by balajisr
In the job sequence use a routine activity to invoke the routine. Set the return value of the routine to the job parameter of the job.
If you use before job subroutine any value returned by the routine other than zero is deemed to be an error and the job is aborted.

Posted: Tue Aug 08, 2006 7:56 am
by mcolen
Have changed code to a before/after subroutine and now move ans to @user0 but how can I reference this (@user0) in a transformer stage later in the job?? It returns clean but I always have 0 when I try to use the env variable. Can this be done??

Posted: Tue Aug 08, 2006 8:35 am
by kcbland
Stay with using a function, use it as the initialization step of a Stage variable in a transformer. The derivation of the stage variable is just the stage variable itself. At startup, the function will be called, returning your value. The stage variable will always be that value. Now you can use it in derivations, key expressions, and constraints.