Macro

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
thurmy34
Premium Member
Premium Member
Posts: 198
Joined: Fri Mar 31, 2006 8:27 am
Location: Paris

Macro

Post by thurmy34 »

Hi All

Is there a macro like the dsjobname for the routine ?

Thanks
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

What do you want the routine name? Or are you asking does DSJobName work in a routine?
Mamu Kim
thurmy34
Premium Member
Premium Member
Posts: 198
Joined: Fri Mar 31, 2006 8:27 am
Location: Paris

Post by thurmy34 »

I want the routine name.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

If you write a routine called "MyRoutine" then do you want some sort of a DS function call which will return "DSU.MyRoutine"? If that is what you are asking then I think it might be possible, but I'm not sure it can be done. It might depend upon how the routine was called.
thurmy34
Premium Member
Premium Member
Posts: 198
Joined: Fri Mar 31, 2006 8:27 am
Location: Paris

Post by thurmy34 »

Here is exactly what i want to do

Code: Select all

 if len(trim(Zone))=0 or isnull(Zone) then
         Begin Case
            case Type='A'
               Ans=" "
            case Type='N'
               Ans="0"
            case @TRUE
               Call DSTransformError("Valeur de parametre iconnue ":Type,"ZoneNull")
               Ans=@NULL
         end case
      end Else
         Ans=Zone
      end
I want to replace "ZoneNull" witch it's the actual name of my routine by a macro.
So i don't have to tkink to change the name when i'll reuse the code.
Thanks
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

It's not possible.

What I do as standard practice is to place an EQUATE declaration at the beginning of every routine.

Code: Select all

Equate RoutineName To "MyRoutine"
This behaves like the macro you seek. Because it's at the top of the code, it's obviously there needing to be changed when the code is copied.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Just as Ray stated, I always have my first code line in every program

Code: Select all

EQUATE ProgramName TO "name-of-routine"
, and usually the second line is

Code: Select all

EQUATE Version TO "x.x.x"
.

I thought the stack might contain an easily accessible name of the current routine, but I've done some checking and this value isn't available.
thurmy34
Premium Member
Premium Member
Posts: 198
Joined: Fri Mar 31, 2006 8:27 am
Location: Paris

Post by thurmy34 »

so my code will be

Code: Select all

Equate RoutineName to "ZoneNull"
Equate Version to "1.0"
if len(trim(Zone))=0 or isnull(Zone) then 
         Begin Case 
            case Type='A' 
               Ans=" " 
            case Type='N' 
               Ans="0" 
            case @TRUE 
               Call DSTransformError("Valeur de parametre iconnue ":Type,RoutineName:Version) 
               Ans=@NULL 
         end case 
      end Else 
         Ans=Zone 
      end 
am i right ?
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Yes.
thurmy34
Premium Member
Premium Member
Posts: 198
Joined: Fri Mar 31, 2006 8:27 am
Location: Paris

Post by thurmy34 »

I will do that.
Do you do the same in the jobcontrol or do you use dsjobname ?
Thank you all.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

In JobControl you can use DSGetJobInfo(DSJ.ME,DSJ.JOBNAME)
thurmy34
Premium Member
Premium Member
Posts: 198
Joined: Fri Mar 31, 2006 8:27 am
Location: Paris

Post by thurmy34 »

I have all my answers.
Thank you all
Post Reply