cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping Issue - Urgent

Former Member
0 Kudos

Hello Guru's,

Input file format:

Item1, Item2, Item3 ..... Item N

Item1, Item2, Item3 ..... Item N

Item1, Item2, Item3 ..... Item N

Item1, Item2, Item3 ..... Item N

Item1, Item2, Item3 ..... Item N

Item1, Item2, Item3 ..... Item N



Sample file:


ABC,DEF,GHI, JKL

PQR,STU,WXY,ZAB,ABC,DEF,GHI, JKL

LKM,NOP,QRS,TUV,PQR,STU,WXY,ZAB,ABC,DEF,GHI, JKL

Target Needed:

a) Based on the no.of Items in the single record, that many number Item groups need to be generated. ( here "comma" as the delimiter)..for 1st record in the  above file 3 Item group segments need to be generated in the target structure

b) And for each target structure, the value also need to be captured. for ABC target structure...need to populate ABC as the value

-Stallin Xavier

Accepted Solutions (1)

Accepted Solutions (1)

former_member182412
Active Contributor
0 Kudos

Hi Stallin,

You can use below content conversion to read the entire line in a single field.

You will get below XML:


<?xml version="1.0" encoding="utf-8"?>

<ns:FileSenderData xmlns:ns="urn:ch:test:prototype">

   <ItemGroup>

      <ItemGroup>

         <item>ABC,DEF,GHI, JKL</item>

      </ItemGroup>

      <ItemGroup>

         <item>PQR,STU,WXY,ZAB,ABC,DEF,GHI, JKL</item>

      </ItemGroup>

      <ItemGroup>

         <item>LKM,NOP,QRS,TUV,PQR,STU,WXY,ZAB,ABC,DEF,GHI, JKL</item>

      </ItemGroup>

   </ItemGroup>

</ns:FileSenderData>

After that in the mapping you can use below UDF to generate the item groups in target structure.

Execution type for this UDF is "All values of contexts".


public void split(String[] input, ResultList result, Container container) throws StreamTransformationException { 

        String[] StrArray = input[0].split(","); 

        int len1 = StrArray.length; 

        for (int i = 0; i < len1; i++) { 

            result.addValue(StrArray[i]); 

        } 

    } 

You can enhance the UDF based on your requirement.

Regards,

Praveen.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Stallin,

Please go through the below link.

This contains many more links with example and certain ones match ur requirement. In case you have any queries, please post back,

Regards,

Sriram

sahithi_moparthi
Contributor
0 Kudos

Hi,

Can you please share your source and target structure for better understanding ?