on 02-04-2014 9:28 AM
Hi,
I have a requirement that I have to populate the Header and LineItem based on the LineId.
example :
<Header>
<Id> 1 </Id>
<Desc>T12</Desc>
<LineItem>
<LineId>001</LineId>
<Value>123</LineId>
</LineItem>
<LineItem>
<LineId>002</LineId>
<Value>456</LineId>
</LineItem>
<LineItem>
<LineId>003</LineId>
<Value>789</LineId>
</LineItem>
....
....
<LineItem>
<LineId>050</LineId>
<Value>123</LineId>
</LineItem>
</Header>
<Header>
<Id> 1 </Id>
<Desc>T12</Desc>
<LineItem>
<LineId>051</LineId>
<Value>223</LineId>
</LineItem>
<LineItem>
<LineId>052</LineId>
<Value>451</LineId>
</LineItem>
<LineItem>
<LineId>053</LineId>
<Value>872</LineId>
</LineItem>
....
....
<LineItem>
<LineId>100</LineId>
<Value>120</LineId>
</LineItem>
</Header>
In the above sttrucure, I should populate Header again after the LineId reaches to 50.
Can some one please suggest on how we can achieve this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can right a UDF which add The context change after 50
you can use following logic
len= LineId.lenght;
j=0;
for(i=0;i<len;i++)
{
If(j==50)
{
add vaulue
add context change
j=0;
}
else
add vaulue
j++;
}
Regard
GB
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi GB,
I dont understand the above UDF..it looks like we are capturing the length of the LineId? but I am generating this value using counter.
If i dont need to use the counter, let me know if I can write a UDF where in I can store the sequence or LineId for whole mapping and populate based on the value of the same?
.
Hi GB,
below is the structure:
<Details>
<Type>abc</Type>
<amount>123</amount>
</Details>
<Details>
<Type>abc</Type>
<amount>456</amount>
</Details>
<Details>
<Type>abc</Type>
<amount>789</amount>
</Details>
<Details>
<Type>abc</Type>
<amount>281</amount>
</Details>
.
.
.
.
<Details>
<Type>abc</Type>
<amount>123</amount>
</Details>
<Details>
<Type>abc</Type>
<amount>223</amount>
</Details>
<Details>
<Type>abc</Type>
<amount>451</amount>
</Details>
<Details>
<Type>abc</Type>
<amount>872</amount>
</Details>
Here we are populating the Header based on Type and LineTem-Value is being populated from amount field.My requirement is I have to populate one Header for every 50 line items and another heder for every 50 items and so on...based on the number of the Type = abc.
can you please suggest on this.
Hello,
If i understood u corectly, u want to create multiple header and its corresponding line items if type = abc??
iF YES, then check below mapping (u can ignore Record node under LineItem):
Note - In ur case change the context of Type and Amount and set it to "MT***" Name.
UDF:
Exceution type all values of a context
Input: var1 and var2
int k=0;
int j = 0;
int len = var1.length;
for(int i=0;i<len;i++)
{
if(var1[i].equals("abc"))
{
if(j==50 && k>=50)
{
j=0;
result.addContextChange();
}
result.addValue(var2[i]);
j=j+1;
k=k+1;
}
}
output of UDF: For testing purpose i am splitting header after every 2 line items.
Thanks
Amit Srivastava
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
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.