on 02-06-2014 2:30 PM
Hi,
I am recieveing a file and would need to populate Header and Detail fields based on count of 15.
ex: if I recieve a file with 100 records, then first 15 records should be in One Header and 1 to 15 details, Second Header with 16 to30 details records .....
Like the above I have to pouplate. can some one please guide me n this.
Thank you.
John
Hello,
Could u share ur sample input and expected output file?
Thanks
Amit Srivastava
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
I am providing u mapping for Header and Detail nodes and for rest u can do one to one mapping
Create 2 UDFs
UDF1: Header
Execution type: all values of a context
Input: input of type int
if(input[0]%15==0)
{
for (int i=0;i<input[0]/15;i++)
{
result.addValue("");
}
}
else
{
for (int i=0;i<input[0]/15+1;i++)
{
result.addValue("");
}
}
UDF2: Detail
Execution type: all values of a context
Input: var1 of type string
int j = 0;
int len = var1[0];
for(int i=0;i<len;i++)
{
if(j==15)
{
j=0;
result.addContextChange();
}
result.addValue("");
j=j+1;
}
Mapping:
Thanks
Amit Srivastava
Hi Amit,
Thanks you..your help has given me hopes on this.
BUt here If I get same values in the queue i should consider them as single value.
ex:
Input:
123 abc
456 xyz
190 abc
:
:
918 opu
In the above sructure I have added 190 abc , but in target side the count should be same based on abc values should be 123+190 = 313.
Can you please help in this case also.
Hello,
I think Hareesh's reply will help u in clubbing values of same type, but in case u face any issues then u can get back here.
BTW, i think there is no need to use 2 different UDFs, so u can remove Header UDF and use only Detail UDF (u can rename it also) for creating Header and Detail nodes as below:
Thanks
Amit Srivastava
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.