on 03-16-2015 9:52 PM
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Can you please share your source and target structure for better understanding ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.