Data extract from source

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
Tlam
Participant
Posts: 16
Joined: Thu Aug 23, 2007 12:56 am

Data extract from source

Post by Tlam »

Hi,

I need some advice on following data extract.

In the source there is a field with following data format

A12-ABCDEFG123456 ^ 12345678

Now I want only the part ABCDEFG123456

I have tried Field(Mystring, "-", 1) which will give me result = A12 if I use Field(Mystring, "-", 2) it will give me result = ABCDEFG123456 ^ 12345678

Please advice me how to get only ABCDEFG123456

Thanks.

Tlam
paddu
Premium Member
Premium Member
Posts: 232
Joined: Tue Feb 22, 2005 11:14 am
Location: California

Post by paddu »

how about

Step 1
A1= Field(Mystring,'^',1) which gives result=A12-ABCDEFG123456
then
A2=Field(A1,'-',2) which gives result=ABCDEFG123456

use stage variables to achieve this

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

Post by ray.wurlod »

For something that simple, you could nest the Field functions.

Code: Select all

Field(Field(InLink.MyString, "-", 2, 1), "^", 1, 1)
The MatchField() function can also be used here.

Code: Select all

MatchField(InLink.MyString, "0X'^'0X'-',0X",3)
Last edited by ray.wurlod on Wed Feb 06, 2008 7:47 pm, edited 1 time in total.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
paddu
Premium Member
Premium Member
Posts: 232
Joined: Tue Feb 22, 2005 11:14 am
Location: California

Post by paddu »

[quote="ray.wurlod"]For something that simple, you could nest the Field functions.

Code: Select all

Field(Field(InLink.MyString, "^", 2, 1), "-", 1, 1)
As Ray suggested nested field functions is good .

Ray's function is resulting 12345678

Probably below is the one you are looking ,which results ABCDEFG123456

Field(Field(InLink.MyString, "^", 1, 1), "-", 2, 1)
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Edited my previous post to correct typo.
:oops:
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Tlam
Participant
Posts: 16
Joined: Thu Aug 23, 2007 12:56 am

Post by Tlam »

Thanks guys for the advice :D
Post Reply