Before Job Sub Routine

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
mcolen
Premium Member
Premium Member
Posts: 31
Joined: Wed Aug 11, 2004 8:59 am
Location: Florida

Before Job Sub Routine

Post 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
loveojha2
Participant
Posts: 362
Joined: Thu May 26, 2005 12:59 am

Post 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.
Last edited by loveojha2 on Tue Aug 08, 2006 5:33 am, edited 1 time in total.
Success consists of getting up just one more time than you fall.
balajisr
Charter Member
Charter Member
Posts: 785
Joined: Thu Jul 28, 2005 8:58 am

Post 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.
mcolen
Premium Member
Premium Member
Posts: 31
Joined: Wed Aug 11, 2004 8:59 am
Location: Florida

Post 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??
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post 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.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Post Reply