on 11-22-2007 4:36 PM
Hi All,
I am getting in receiver file adapter due to content conversion setting. Problem is that all the fields coming in file adapter are optional. In content conversion , i have specified fieldfixedlengths. So whenever any optional field is not present , it fails . How should we handle it? is there any option to declare fields as optional, I know that is the there for sender adapter. But no. of fields is also very large, so putting each and every field as optional is very time consuming.
What should i do?
Ranjeet Singh.
Ranjith,
Note that fixedfieldlength will fail if a particular field will not come/be empty in the target xml. to avoid this you will have to handle a check for all optional fields.
The following will be a typical implemetation if the field is empty (handle this in your mapping). Confirm with the customer on the following and you can take a approach;
1. for string fields - map a constant of N spaces where N is the length
2. for numeric fields - map a constant of N 0's where N is the length.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi All,
Thanks for reply. To tackle the situation I created a UDF where I am checking that if source field is blank, I put a contact value . The mapping is working fine locally. But when i am doing interface testing..somehow contact value is not getting populated. Instead if source is blank that element is not apprearing on target xml..
What could the reason. Looks very weird.
Hi,
that's because you are not doing anything if the source element doesn't exist.
The standard function MapWithDefault solves exactly that problem. It is enough for you to generate every output field (no matter if the content is just an empty string, the fixedLength option in the adapter will automatically fill it with a suitable number of spaces).
try it and let us know
best,
Daniele
Hi Daniele,
Instead of using the standard funciton , i created a UDF for handling this situation.
My logic is UDF is like
//write your code here
int Size = Integer.parseInt(Truncate_Size);
String Return_Value = "";
if (!("".equals(Input)) )
{
if (Input.length() > Size )
Return_Value = Input.substring(0,Size);
else
Return_Value = Input.substring(0, Input.length());
}
else
{
for(int i = 0; i< Size ; i++)
{
Return_Value = Return_Value + " " ;
}
}
return Return_Value;
SO in this case also , it should be able to handle empy source element. But it is not working.
Hi,
your code needs the source element to <i>exist</i> to work fine.
Try the following: in the test tab of you mapping, remove a node and then test your UDF on that node with the "display queue" tool. You should see an empty context as result.
In that case no output will be produced and your message will fail.
Check the difference with the MapWithDefault function.
Hi All,
Problem is solved now. I used combination of exits,MapwithDefault,if and UDF function to first check whether node exit or not. if node exits, i am using my UDF function to truncate the string to a desired level else i am using MapwithDefualt to populate the element with blank value.
Ranjeet Singh.
Hi,
well done, you are very welcome.
I'd say in addition that there is no need to use the UDF.
You don't have to truncate values that are too long, just let the adapter do it through the option <i>fixedLengthTooShortHandling</i> set to <i>Cut</i>.
Check <a href="http://help.sap.com/saphelp_nw04/helpdata/en/d2/bab440c97f3716e10000000a155106/frameset.htm">this link</a> out for more information.
best,
Daniele
> Hi All,
>
>
> Problem is solved now. I used combination of
> exits,MapwithDefault,if and UDF function to first
> check whether node exit or not. if node exits, i am
> using my UDF function to truncate the string to a
> desired level else i am using MapwithDefualt to
> populate the element with blank value.
>
>
> Ranjeet Singh.
hi ranjeet,
You can map the all the optional fields to Constant " "[space number of character] meaning if the fixed length is 4 then give 4 spaces default and hence if the value doesn't come the spaces take in charge.
Hope this helps
regards
Ramesh P
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ranjeet,
you should always create every xml field in your mapping, even if they contain no values.
To achieve this, put a MapWithDefault[] standard function right before each target field in your graphical mapping.
best,
Daniele
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
9 | |
8 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.