on 09-05-2006 8:13 PM
I have to concat 14 Idoc text fields into a string at a varying position. Mostly some of the fields are not assigned, a normal concat does not work(no output if one field is missing). I created a workaround with the exists function (graphical) which is about 25 meter long (my colleague imediately started to cry). It works but it is ugly.
Does anybody know how the exists function works. If one of the IDoc fields is missing I do not get <b>any</b> output of my udf whatever I do inside. How can I change this.
Regards, Thomas
Hi Thomas,
You can handle the absence of values in two ways.
1. Using <b>MapWithDefault</b> Standard function.
Field1- MapWithDefault(Default value single space)->
->Concat/UDF -> TargetField
Field2- MapWithDefault(Default value single space)->
2. In UDF check for SUPPRESS value like this:
public String UDF_Name(String StrVal1,String StrVal2,Container container){
if((!StrVal1.equals(ResultList.SUPPRESS)) && (!StrVal1.equals(ResultList.SUPPRESS)) ){
//concat...
}
}
Hope this helps.
Regards,
Ananth
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thomas,
<b>Use MAPWITHDEFAULT</b> .
<i>Source Fields --> MAPWITHDEFAULT --> CONCAT.</i>
MAPWITHDEFAULT will allow you to give a default value if the field is not found in the source.
Map with default --> EXISTS + DEFAULT VALUE.
Regards,
Bhavesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi thomas,
U can use a alternative method. U can write 2 UDFs. One for concatinating the strings as u require.
The other one takes the inputs as the 14 fields with a "exists" function in front of them. So in the UDF u can check whether the values are "true" or "false". If atleast one is false then u can return "false" from the second UDF.
Give the output of two UDF's to an if - then - else function to get the required correct mapping.
This is just a work around.
Hope this helps.
Regards,
P.Venkat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can do the same exist functionality inside the UDF using this syntax
if(a.equals(null)) --> the value does not exist.
Thanks,
Prakash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Prakash,
that was the first I tried. But it does not work. In fact my udf does not do anything if "a" is not delivered. I still cannot determine if "a" is delivered.
A good question is how function Exists or MapWithDefault works on the inside. How is it possible they process anything. How can I copy or modify them.
Regards,
Thomas
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
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.