on ‎2019 May 28 7:55 AM

Hello Experts,
I have a csv file where there is a header,line and multiple line segments
There is a mapping condition where for value of a particular field in header value from a field in line segment should go in output.This works with single header and multiple line segments.But the same fails if i have multiple headers in the csv file.Request your suggestion on this mapping issue.Just like all values of context and queues functionality in ESR(PI) UDF is there any similar functionality in HCI ? Attached is the CSV file,mapping and groovy script..

import com.sap.it.api.mapping.*;
/*Add MappingContext parameter to read or set headers and properties
def String customFunc1(String P1,String P2,MappingContext context) {
String value1 = context.getHeader(P1);
String value2 = context.getProperty(P2);
return value1+value2;
}
Add Output parameter to assign the output value.
def void custFunc2(String[] is,String[] ps, Output output, MappingContext context) {
String value1 = context.getHeader(is[0]);
String value2 = context.getProperty(ps[0]);
output.addValue(value1);
output.addValue(value2);
}*/
def void customFunc2(String[] input1, String[] input2, Output output)
{
def str = "";
if(input1.length>0 && input2.length>0)
{
for(int i=0;i<input1.length;i++)
{
if(input1[i].equals("true"))
{
for(int j=0;j<input2.length;j++)
{
output.addValue(input2[j]);
}
}
else
{
for(int x=0;x<input2.length;x++)
{
output.addValue(str);
}
}
}
}
}
Request clarification before answering.
| User | Count |
|---|---|
| 15 | |
| 9 | |
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.