cancel
Showing results for 
Search instead for 
Did you mean: 

Seperating the fields from Source to Target

Former Member
0 Kudos

Hi,

From Source system i am getting the 4 fields Data in to single field diffrentiate with (/) like (SONO / Batch / Product / Quantity), but when i am sending it to Target system i need to send it to 4 diffrent fields ( SONO

BATCH

Product

Quantity)

I think for this we need to write UDF or any other functionality is available.

IF UDF is required, Pls let me know what coding is required for this...

Thanks in advance

Regards,

Pasi.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Chk this, create one UDF:

Input will be : a & b


String[] var = a[0].split("/");
int pos = Integer.parseInt(b[0]);
result.addValue(var[pos]);

mapping will be :

input -


-


UDF---SONO

constant(0)

input -


-


UDF---BATCH

constant(1)

input -


-


UDF----PRODUCT

constant(2)

input -


-


UDF----QUANTITY

constant(3)

Thanks

Amit

Former Member
0 Kudos

input - would be your source field

separator - "/"

index - 0 for SONO, 1 for Batch, 2 for Product, 3 for Quantity


public static String SeparatedTextByIndex(String input, String separator, String index){
		  int val = Integer.parseInt(index); // the index should start at 0 !
		   
		  if (separator.length() > 0){ //if there is a separator
						String[] splitted = input.split(Pattern.quote(separator)); // Pattern.quote is used to escape the separator so that it is taken as a literal and not as a regexp
						if (val < splitted.length)
							return splitted[val];
						return "";
					}
					else // if we didn't find a separator, add the entire string;
						return input;
					
				}

Former Member
0 Kudos

You can use an UDF with a split method:

String str = "SONO/Batch/Product/Quantity";

String[] strArray = str.split("|");

Then, just access the array as strArray[0], for "SONO", or strArray[3] for "Quantity".