cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping UDF

Former Member
0 Kudos

Hey folks

I have a mapping issue:

It is IDOC to file scenario

A segment in IDOC repeats multiple times. I want to take a field of the first repeating segment and map it to a target field.

And i want to take afield of the last repeating segment and map to a target field.

Eg : E1EDPL1

GSB 100

E1EDPL1

GSB 200

E1EDPL1

GSB 300

Mapping logic 1 :

Take the first GSB ( Value: 100) and map to a target field.

Mapping logic 2 :

Take the last GSB(Value : 300) and map to a target field.

Guess we need to have a context java function which takes as an input an array of GSB and extract first and last GSB.

Need help with the java udf.

Thnx

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

A small correction

Here a is the GSB values.

cache parameter - context

1st udf


public void add(String[] a,ResultList result,Container container)
{
   //write your code here
 result.addValue(a[0]);
}

GSB ---> add -


> tgt1

2nd udf


public void add1(String[] a,ResultList result,Container container)
{
 //write your code here
 int len = a.length -1;
result.addValue(a[len]);
}

GSB---> add1 -


>tgt2

Former Member
0 Kudos

Hi

Whats the occurance for the fields.

use GSB ( 0 ) for the first field

and GSB ( GSB.length ) if it is a string or GSB ( GSB.length() ) for integer

and return these from UDF

Thanks

Gaurav

Former Member
0 Kudos

Thanks folks.

I am awarding points as I guess th solution both of you provided seems good.Else will open the thread again.

Regards

Former Member
0 Kudos

do you want to map these to same target field or different target fields??

if one target field then use below UDF.

Change the context of GSB to Header level;

int i =GSB.length();

result.addValue(GSB(0));

result.addValue(GSB(i));