cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping

former_member329434
Participant
0 Kudos

Hi Friends,

I got struck with mapping issue and  require your valuable inputs:

my scenario is file to IDOC:

In one particular field from source file , input values are coming as : one! two! three!four!five!six.   count may increase or decrease....(dynamic)

What is expected is .. I have to read till the delimiter value and create segments accordingly. In above example , I have to generate six segments at target side.

source                                                                                                target

<key>abc</key>                                                                                 <key>abc</key>                 segment1

<text> one;two;three;four;five;six</text>                                           <text> one </text>

                                                                                                           <key> abc</key>

                                                                                                           <text> two</text>                segment2

                                                                                                            <key> abc</key>

                                                                                                            <text>three</three>            segment3

File provider is not ready to change his design. please share your thoughts.

Regards,

Suman

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello,

Use below UDF:

String [] a = var1[0].split("!");

for(int j=0;j<a.length;j++)

{

result1.addValue("");

result2.addValue(a[j]);

}

Ur mapping will be:

Thanks

Amit Srivastava

former_member329434
Participant
0 Kudos

Hi Amit,

Thank you.

I have replicated the same as you mentioned. Function is not creating multiple segments based on input field values ( delimeter). But, other values are coming proper in debug mode.

input provided : one!two!three   for testing

error :

Value missing in queue context, Target XSD requires a value for this element, but the target field mapping does not create one...

If you don't mine , can you share your function signature as well as test result...

Regards,

Suman

Former Member
0 Kudos

Hello,

Use display queue and then check ur mapping output

>>If you don't mine , can you share your function signature as well as test result...

I have tested this and it's perfectly working fine

Thanks

Amit Srivastava

Answers (2)

Answers (2)

former_member329434
Participant
0 Kudos

Hi Amit,

Thank you and appreciate your time.

It is working now..... small bug was due to one mandatory field missing from source file.

Points given.

Regards,

Suman

former_member329434
Participant
0 Kudos

Hi Amit/ Friends

I was under impression that there will be only one segment with values separated by delimiter(!). In that case, logic provided by you is working perfect .

There will be a case where I can get input as several segments; In this case, segments are not generating as expected.

eg;

FILE                                           IDOC

<root>                                       < target>

<key> abc </key>                      <key> abc </key>

<text> one </one>                      <text>one </one>

</root>                                        </target>

<root>                                         <root>

<key> def </key>                       <key> def</key>

<text> two!three </one>               <text>two </one>

                                                 <key> def</key>

                                                  <text>three</text>

</root>                                        </root>

As I have mapped based on keyword and text, segment repeation is ignoring for single based values. Is there any way I can enhance java function to accomodate both scenarios.

Thanks in Advance.

Regards,

Suman

Former Member
0 Kudos

Hello,

You have to slightly adjust your mapping and UDF.

UDF:

for(int i=0;i<var1.length;i++)

{

String [] a = var1[i].split("!");

for(int j=0;j<a.length;j++)

{

result1.addValue("");

result2.addValue(a[j]);

}

}

Thanks

Amit Srivastava

Former Member
0 Kudos

Hi Suman,

If its a FCC file then u should use  JAVA UDF to split the values.

Thanks

Vijay