on 09-14-2011 7:08 AM
Hi All,
I want to generate a empty value when the source field is missing ( UDF code is required). In the below example P19 segment is unbounded. IDNT file may or may not occur. When the IDNT file is not existing in the source idoc, I want to have as empty value in the output
I have an input structure as
IDOC
PO1 u2013 Parent Segment
P19 u2013 child segment
Qual u2013 field 1
IDNT u2013 field 2
Target structure as
PO1
D34 u2013 field name
I want to add a empty value when there is no IDNT field in the source structure. For example
<PO1> u2013 Parent Segment
<P19> u2013 child segment
<Qual> 001 <\Qual>
<IDNT> ATN <\IDNT>
<\P19>
<P19> u2013 child segment
<Qual> 002 <\Qual>
<\P19>
<P19> u2013 child segment
<Qual> 003 <\Qual>
<IDNT> ATN 3<\IDNT>
<\P19>
</PO1>
Output should be
<PO1>
<D34> ATN </D34>
<D34> </D34>
<D34> ATN3 </D34>
</PO1>
Can some help me to write a udf for this requirement?
Thanks in advance.
Regards
Sarkar
Hi,
Use mapwith default and pass an empty value.
Regards
Priyanka
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Please follow the below logic.write a simple udf with execution type all values of queue.
idnt-->mapwithdefault[a]-->addEmptyValue-->remove context->D34
public void addemptyvalue(String[] var1, ResultList result, Container container) throws StreamTransformationException{
for(int i=0;i<var1.length;i++){
if(var1<i> == "a");
result.addValue(" ");
else
result.addValue(var1<i>);
}
}
Thanks
Priyanka
Hi Priyanka,
This will result either a empty value or values which IDNT has. But i am looking to add empty value at right context.
Let me explain, Lets say i have 4 IDNT in 4 PO1 segments and third PO1 segment is not having the IDNT field, then the udf should result as
IDNT1
IDNT2
[]
IDN4
UDF which you provided either result ONLY [] or
IDNT1
IDNT2
IDNT4.
My requiremtn is to get the [] value after IDNT2 value.
I hope iam clear.
thanks again .
Regards
Sarak
>>Lets say i have 4 IDNT in 4 PO1 segments
by looking ur query it seems that u are having multiple PO1 as well as multiple P19 segments???
If yes then do ur mapping like this:
P01 ---> P01
IDNT---Mapwithdefault---
------------formatby example-----D34
P19---------------------
Input:
<PO1>
<P19>
<IDNT> ATN1<\IDNT>
<\P19>
<P19>
<\P19>
<P19>
<IDNT> ATN 3<\IDNT>
<\P19>
</PO1>
<PO1>
<P19>
<IDNT>ATN4<\IDNT>
<\P19>
<IDNT>ATN5<\IDNT>
<P19>
<\P19>
<P19>
<\P19>
</PO1>
ur output will be something like this:
<PO1>
<D34>ATN1</D34>
<D34> </D34>
<D34> ATN3 </D34>
</PO1>
<PO1>
<D34>ATN4 </D34>
<D34>ATN5 </D34>
<D34> </D34>
</PO1>
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
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.