Edditing DS Macros

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

ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

There's no need to edit the macro definitions. You can simply override them with newer macro definitions of your own. The newer $DEFINE will replace the older.
In your case, leave out the $IFNDEF that tests whether it is already defined (and its corresponding $ENDIF of course).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

ray.wurlod wrote:It's better (more "bullet proof") to guard against redefinition of constants.
Thanks for the clarification. 8)
-craig

"You can never have too many knives" -- Logan Nine Fingers
JDionne
Participant
Posts: 342
Joined: Wed Aug 27, 2003 1:06 pm

Post by JDionne »

I hate seeing two experts talk to each other about my post....Its always way over my head :)
What exactly are you saying Ray? That the way that chulett helped me is not the best way to do this?
Also there was one thing that disrupted my sleep last night:
My working code is as follows
$INCLUDE DSINCLUDE JOBCONTROL.H
ErrorCode = 0 ;* set this to non-zero to stop the stage/job

FileName = Ereplace(Ereplace(DSJobStartTimestamp,":","_")," ","_")
CmdString = "\\scrbbususcnc04\ETL_Processes\456msg\Batch_files\456Move.bat ":FileName
Call DSExecute("NT",CmdString,ScreenOutput,CmdReturnCode)
*If CmdReturnCode <> 0 Then
*Ans = "ERROR" : CmdReturnCode
*else Ans = 0
*End


The thing that gets me is that this is only good for one Batch file....Is there a way to make this dynamic?
Jim
Sure I need help....But who dosent?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

JDionne wrote:What exactly are you saying Ray? That the way that chulett helped me is not the best way to do this?
Sorta. :wink: Best is to only include the JOBCONTROL header if it needs to be included. $IFNDEF basically means "If Not Defined", so Ray is checking and only "defining" it if it needs to be defined - ie, isn't already defined. It will be fine in this case without it, he's showing you a way you could always throw it in when doing 'Job Control Stuff' and not having to worry about whether it is being doubled-up or not. That help?

And yes, you can make it more dynamic. For example, you could pass in one more argument, which could be the path/batch to execute and the other (your current one) could be the 'parameters'.
-craig

"You can never have too many knives" -- Logan Nine Fingers
JDionne
Participant
Posts: 342
Joined: Wed Aug 27, 2003 1:06 pm

Post by JDionne »

chulett wrote:
JDionne wrote:What exactly are you saying Ray? That the way that chulett helped me is not the best way to do this?
Sorta. :wink: Best is to only include the JOBCONTROL header if it needs to be included. $IFNDEF basically means "If Not Defined", so Ray is checking and only "defining" it if it needs to be defined - ie, isn't already defined. It will be fine in this case without it, he's showing you a way you could always throw it in when doing 'Job Control Stuff' and not having to worry about whether it is being doubled-up or not. That help?

And yes, you can make it more dynamic. For example, you could pass in one more argument, which could be the path/batch to execute and the other (your current one) could be the 'parameters'.
Riddle me this Batman:

my code:
$INCLUDE DSINCLUDE JOBCONTROL.H
ErrorCode = 0 ;* set this to non-zero to stop the stage/job

FileName = Ereplace(Ereplace(DSJobStartTimestamp,":","_")," ","_")
Path = "\\scrbbususcnc04\ETL_Processes\456msg\Batch_files\456Move.bat "
CmdString = Path:FileName
Call DSExecute("NT",CmdString,ScreenOutput,CmdReturnCode)
*If CmdReturnCode <> 0 Then
*Ans = "ERROR" : CmdReturnCode
*else Ans = 0
*End


the dynaic path name is sorat right....its almost dynamic. This routne is set up as a before/after subroutine. I cant see where to add another paramiter so that when i am using a Routne Activity stage in a sequencer I can add the correct path as a variable........now how do i get around that?
Jim
Sure I need help....But who dosent?
JDionne
Participant
Posts: 342
Joined: Wed Aug 27, 2003 1:06 pm

Post by JDionne »

I realized that I wasnt actualy using the parramiter that I had available to me so I did, but I would still like to know how to add a paramiter to a before/after routne
Jim
Sure I need help....But who dosent?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

When you originally define a Routine, it defaults to having one input parameter called 'Arg1'. In the 'Arguments' tab, you can add and rename the parameters listed there, much like you can do the same thing in a Transform or any other grid like that.

It is helpful to name them something meaningful as it's easier to know what to put into the 'StartDate' parameter, for instance, than when you are prompted for something called 'Arg3'. :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
JDionne
Participant
Posts: 342
Joined: Wed Aug 27, 2003 1:06 pm

Post by JDionne »

chulett wrote:When you originally define a Routine, it defaults to having one input parameter called 'Arg1'. In the 'Arguments' tab, you can add and rename the parameters listed there, much like you can do the same thing in a Transform or any other grid like that.

It is helpful to name them something meaningful as it's easier to know what to put into the 'StartDate' parameter, for instance, than when you are prompted for something called 'Arg3'. :?
True True, but when you change the type of routen to Before/After u suddenly dont have the option to add any more to the bottom of the list
Give it a go and see.
Jim
Sure I need help....But who dosent?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Sorry, forgot about that little 'feature' for Before/Afters. What we do is pass in delimited strings as the 'InputArg' and then use FIELD to hack it up into individual parameters inside the routine. Could be whitespace or pipe delimited, or whatever works with the nature of the data being passed in.
-craig

"You can never have too many knives" -- Logan Nine Fingers
JDionne
Participant
Posts: 342
Joined: Wed Aug 27, 2003 1:06 pm

Post by JDionne »

chulett wrote:Sorry, forgot about that little 'feature' for Before/Afters. What we do is pass in delimited strings as the 'InputArg' and then use FIELD to hack it up into individual parameters inside the routine. Could be whitespace or pipe delimited, or whatever works with the nature of the data being passed in.
Ugg there is a nasty work around
ohh well
thanx for the input
Jim
Sure I need help....But who dosent?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

JDionne wrote:I realized that I wasnt actualy using the parramiter that I had available to me so I did, but I would still like to know how to add a paramiter to a before/after routne
Jim
If you want to use a job parameter in a before/after subroutine, you can do it the same way as in a job control routine. That is, interrogate its value from the job using

Code: Select all

ParamValue = DSGetParamInfo(DSJ.ME, parameter_name, DSJ.PARAMVALUE)
You should check that this was successful - if it was not, the value assigned to your variable is a negative number.

Code: Select all

If ParamValue Matches "'-'1N0N"
Then
   * code to handle unable to retrieve parameter value
End
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
JDionne
Participant
Posts: 342
Joined: Wed Aug 27, 2003 1:06 pm

Post by JDionne »

WOOHOO I got circles around my trash can!!!
:)
Jim
Sure I need help....But who dosent?
Post Reply