cancel
Showing results for 
Search instead for 
Did you mean: 

source field split in to 2 fields at target side

ravi_reddy1
Participant
0 Kudos

Hi experts

my requirement is one source field is split in to two fields

the source field is not fixed..

ex :

1)Source field :  FLE-BPO

Target filed 1 :  FLE

Target filed  2 :  BPO



2)

Source field :  FLE-FEAO

Target filed 1 :  FLE

Target filed  2 :  FEAO


plese tell me how to solve this .......


1) suppose fixed length what is the solution?

2) suppose length is vary what is the solution?



Thanks & Regards

E. Ravi Chandra Reddy

Accepted Solutions (1)

Accepted Solutions (1)

Muniyappan
Active Contributor
0 Kudos

Hi Ravi,

in simple create two udf.

1.getting first string :

String[] output = new String[2];

  output = var1.split("-");

return output[0];

2. getting first string :

String[] output = new String[2];

  output = var1.split("-");

return output[1];

you can also think of putting exception handling in this part.

Regards,

Muni

ravi_reddy1
Participant
0 Kudos

Hi muni,

Based on your answer i taken simple udf..

but whenever testing it will display fallowing error..

Please help me on this...

Regards,

E.Ravi chandra reddy

Muniyappan
Active Contributor
0 Kudos

Hi,

Can you share your udf and mapping screen shots?

Regards,

Muni.

ravi_reddy1
Participant
0 Kudos

hi muni,

UDF i written is:

Mapping:

Testing:

while testing i get whatever i given in input same as it is in out put.......please check once..

Regards

E. Ravi chandra reddy

Muniyappan
Active Contributor
0 Kudos

Hi,

in your first post you have input FLE-BPO

now your input looks like this fsa_hod. it wont work with   output = var1.split("-");

change the code like below

  output = var1.split("_");

Regards,

Muni.

ravi_reddy1
Participant
0 Kudos

Hi muni

its working fine..

thanks for ur consistent help...

is it solved using standard mapping functions(with out udf's)?

if yes tell me the procedure

Regards,

E.Ravi chandra reddy

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Ravi,

You can simply Split the string by using below code;

  • Data : a type char20,
  •           b type char 20.

      data : v_str type char50.

v_str  =  'FLE-FEAO'.

split v_str at '-' into a b.

write 😕 a.

write : /b.

Please try in this way.

-Regards

Rohit

Harish
Active Contributor
0 Kudos

Hi Ravi,

you can use the below code to create generic UDF.

you need to take two input input field and index. Index is 1 for first value and 2 for second value. you can take any no of values.

If you gave index 2 and delimeter "-" is not present then UDF pass blank value.

String[] output = input.split("-");
int num = Integer.parseInt(index);
if (output.length>num-1)
{
return output[num-1];
}

return "";

mapping screenshot

regards,

Harish

ravi_reddy1
Participant
0 Kudos

Hi Harish,

thanks for urs replay...

can u elaborate this ( from scratch with screen shots ).......i didn't get u...please explain in detail......

thanks & Regards

E. Ravi chandra reddy

former_member191435
Contributor
0 Kudos

If you know the field length ... I mean if you know the "-" specified location then you can get it from substring...

Otherwise Please follow the UDF  Suggested By Muni...

Thanks,

Sreenivas