Substring from rear

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
eldonp
Participant
Posts: 47
Joined: Thu Jun 19, 2003 3:49 am

Substring from rear

Post by eldonp »

I have 2 jobs, xxxparams and qwertyparams. In a transformer, I create a stage variable, var1 = DSJ.ME and get the name of the jobs - ie xxxparams and qwertyparams.

I need a function that will clip off the 'params' part from the end of the jobname dynamically. Any ideas?

Just to make it clear, I need

var2 = funtion(DSJ.ME,clip off 'params' dynamically) that gives xxx and qwerty respectively.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

You can use something like this, provided the params always is the suffix and not prefix

Code: Select all


funtion(DSJ.ME,Left(jobname,Index(jobname,"params",1)-1))

I bet others will have a far better solution than me. But try it out.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Var2 = DSJ.ME[1,LEN(DSJ.ME)-7]
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Nice ArndW. :P
They should have a thumbs up icon :wink:
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Umm... isn't DSJ.ME always set to 1 ?

You would need the DSJobName macro or an appropriate function call in there. This is implied by the jobname reference in the first solution.
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 »

I just realized that it was a mnemonic. Use 2 stage variables, first call to get DSGetJobInfo(DSJ.ME,DSJ.JOBNAME) and second one to get the substring from it. Don't use normal derivations, just initial values so it only gets executed one time.
Post Reply