DataStage ExecTCL syntax ?

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
Kim Bundgaard
Participant
Posts: 16
Joined: Fri Aug 08, 2003 3:30 am
Contact:

DataStage ExecTCL syntax ?

Post by Kim Bundgaard »

Can anyone tell me where to find the syntax for ExecTCL commands.
I want to run a DataStage Routine as "before command".

The error message in DataStage is :

TestExecTCL..BeforeJob (ExecTCL): Error when executing command:
LarsTest('c:tempkib1.txt',10)
*** Output from UniVerse command was: ***
Verb "LARSTEST('C:TEMPKIB1.TXT',10)" is not in your VOC.
msigal
Participant
Posts: 31
Joined: Tue Nov 26, 2002 3:19 pm
Location: Denver Metro

Post by msigal »

Why not set up the routine to run as a before or after routine, then you wouldn't need to use TCL?

Myles

Myles Sigal
Technical Analyst
Thomson - Medstat
777 E. Eisenhower - 435B
Ann Arbor, MI 48108

myles.sigal@medstat.com
734-913-3466
Kim Bundgaard
Participant
Posts: 16
Joined: Fri Aug 08, 2003 3:30 am
Contact:

Post by Kim Bundgaard »

I try to set it up as before routine in Job Properties, and only have the ExecDOS, ExecTCL options to choose between.
What should I use to execute a DataStage Routine as a "before routine" ?
msigal
Participant
Posts: 31
Joined: Tue Nov 26, 2002 3:19 pm
Location: Denver Metro

Post by msigal »

When creating the routine you would choose "Before/After Subroutine" from the Type box on the General tab. This will affect your options for arguments. You are only allowed one input argument and you get to return an error code(non-zero would stop the stage or job). If you need two arguments as it appears you do, you can send in a single string and use a delimiter to separate values. You'll need to parse out the values in your routine. Copy your existing code to text file or something before changing the routine type, you lose the code when you make the change.

What is it that you are trying to accomplish in your routine? It appears that you are doing something with a file. You can perform DOS/Unix shell commands from here if that would do what you need to do.

Myles
Kim Bundgaard
Participant
Posts: 16
Joined: Fri Aug 08, 2003 3:30 am
Contact:

Post by Kim Bundgaard »

I do a bad job in explaining what I want to do -sorry.

The routine I call as a "before routine" generates a file with 10 records, and I want to use it as input to my job.

I know that I can do it in a DOS bat-script, but for now I have done it as a DataStage Basic routine.
And my problem is that I don't know how to call the DataStage Basic routine in "before routine".
My routine takes two argument : filename and number of records.
I only want the functionality from "Row generator plug-in" - but that plug-in is not part of my license (Parallel Extender).
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Kim

I don't think you can generate the file you are using in a job in a before routine. You need to create a batch job then put your code from the routine in there. Next run the job. Before routines were not meant to do what most people think. They don't really run before the job starts. They run as part of the job which means the source and targets have already been opened. You cannot build a source file in the before routine. At least you couldn't in older versions that I tried it in. The same is true in job code. You cannot change a parameter in job code for the same reason. You also cannot build a source file. A lot of people think you can reset a job in a before routine. Will not work because a before rouitne runs a part of the job and not "before" the job. I don't think you can get job status in an after routine either because it will always say the job is still running.

It is cleaner in a batch job anyway.

Kim.

Kim Duke
DsWebMon - Monitor over the web
www.Duke-Consulting.com
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Kim

To answer the TCL question, any routine can be turned into a TCL command if you know how. You have to create a BASIC library in a type 1 or 19 hash file. You have to do all this at a TCL prompt. You create your BASIC program. If it needs arguments then you need to convert them to command line arguments. Next you compile the program. Next you catalog the program. Now you have a TCL command. Here are the steps.



CREATE.FILE KIMBP 19
ED KIMBP RESET_JOB or UV.VI KIMBP RESET_JOB
.
.
.
get(arg.) JobName else
print "Usage: RESET_JOB JobName"
stop
end
Cmd = "DSD.RUN ":JobName:" -2"
execute Cmd capturing output
end
.
.
.
BASIC KIMBP RESET_JOB
CATALOG KIMBP RESET_JOB LOCAL COMPLETE
.
to test:
RESET_JOB MyJob


.

Kim.


Kim Duke
DsWebMon - Monitor over the web
www.Duke-Consulting.com
Kim Bundgaard
Participant
Posts: 16
Joined: Fri Aug 08, 2003 3:30 am
Contact:

Post by Kim Bundgaard »

Thank you - I'll do it in another way.
/Kim
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You certainly can do what you want to do in a BASIC before-job subroutine, because a before-job subroutine is executed before any connections, files, etc., are opened.

You create the Routine with type "before/after subroutine" (not the default of "transform function" - adjust on the General tab). This subroutine has two arguments, InputArg is whatever is in the field adjacent to the subroutine name in the caller. ErrorCode should be set to zero within the subroutine; any other value will cause the job to abort when the subroutine returns.

To create text files in the project directory, use the OpenSeq statement, and don't forget to handle the possibility that the file does not yet exist (the ELSE clause is taken, and STATUS() returns 0), then use WriteSeq statements to write lines into the file. Don't forget to CloseSeq when you're done, as this releases the update lock taken by OpenSeq.

To create hashed files in the project directory, use CREATE.FILE or CREATE TABLE statments invoked through DSExecute, then you can use OPEN, RECORDLOCKU and WRITE statements to populate it with BASIC code, or invoke INSERT statements (or UPDATE.RECORD commands) via calls to DSExecute.

In your original post you were trying to execute a function calling it directly by name (LARSTEST). This is not possible; before/after subroutines are subroutines, not functions. You could certainly create a before/after subroutine that invokes LARSTEST.
SUBROUTINE LARSSUB(InputArg, ErrorCode)
DEFFUN LARSTEST(Arg1,Arg2) CALLING "DSU.LARSTEST"
ErrorCode = 0
Arg1 = Field(InputArg, " ", 1, 1)
Arg2 = Field(InputArg, " ", 2, 1)
Result = LARSTEST(Arg1, Arg2)
Message = "Result of LARSTEST = " : Quote(Result)
Call DSLogInfo(Message, "LARSSUB")
RETURN


Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518
Post Reply