cancel
Showing results for 
Search instead for 
Did you mean: 

Receiver File Adapter Content Conversion Problem.

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

Shabarish_Nair
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.

Former Member
0 Kudos

Hi Daniele,

yup.I observed something..

I deleted the node , and found that i am not getting that element in target xml using the UDF.

Let me try to use the standard function and see if i am able to solve the problem.

I will get back to you .

Ranjeet Singh.

Former Member
0 Kudos

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.

Former Member
0 Kudos

Thanks Daniele for your suggestion.

Former Member
0 Kudos

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.

Answers (3)

Answers (3)

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Ranjeet,

Please go through this thread:

According to this thread,you will have to do lots of mapping.

As all the fields you have are optional,it will consume time for mapping each and every field.But I guess there is no other option.Do let us know if there is any other way.

Regards,

Manju.

Former Member
0 Kudos

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