on 07-06-2015 6:49 PM
Hi Experts,
I have a issue here and need your suggestion.
My scenario is, i have a source file like following
<source_msg>
<record>
a
b
c
</record>
<record>
1
2
3
</record>
<record>
4
5
6
</record>
<record>
7
8
9
</record>
<record>
11
12
13
</record>
.
.
.
.
</source_msg>
Now what the output should be, 1st there should be a new idoc (context change) for every 2 records, and the first record, containing alphabets, should not be created.
I created following udf to handle context change but couldn't remove the first context
int j=0;
for(int i=0; i<record.length; i++
{
result.addValue(record[i]);
if (j==2)
{
result.addContextChange();
j=0;
}
j++
}
Thanks for your reply...
Hi Debtirtha,
Please use the below udf code for splitting per 2 records.
int a =0, b=0;
a = (record.length)/(Integer.parseInt(num[0]));
b = (record.length)%(Integer.parseInt(num[0]));
if(b>0)
a = a+1;
for(;a>0;a--)
result.addValue("");
This is generic udf to split the messages as per num number, in your case 2.
Map the output of this udf to the target IDOC node, which would solve your requirement of creating IDOC's per 2 records.
Regarding your another query of suppressing the records having alphabets, can you be more specific by exactly what you mean by alphabets.
Regards
Vishnu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Debritha,
Can you please reward points to the helpful replies..
Regards
Vishnu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Santhi and Vishnu,
Thanks for your quick reply. It has been resolved now, i used following code
int j=0;
int k=0;
for (int i=0; i<=record.length-1;i++)
{
k++;
if (k==1)
{
result.addValue(ResultList.SUPPRESS);
}
else
result.addValue(record[i]);
if (j==2)
{
result.addContextChange();
j=0;
}
j++;
}
to create the idoc i used a different udf connected to idoc node.
thanks for your reply guys. really appreciate.
regards,
Debtirtha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Debtirtha,
try below code.
int j = 0;
for (int i=1, i<record.length; i++)
{
if (j==1)
{
result.addContextChange();
j = 0;
}
result.addValue(record[i])
j ++
}
Regards,
SAnthi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.