cancel
Showing results for 
Search instead for 
Did you mean: 

UDF question - how detect a non existing sender element

michael_buchli
Participant
0 Kudos

Hi all,

i have a question according UDF. I have a sender message that contains a field, that sometimes has a content ans some time not. If no content then als the element doesn't exists (occurrence 0...1). The target element of this one has the occurrence status 1.

So i have to create a function, that writes an empty string in case of no sender element. I know that i can configure this function with the MM Blocks (if exists ...). But for re-using reasons i'd like to create a UDF for this function.

Now my question, how can i detect if no data in the sender (src) file?

Here my try, which doesn't works:

AbstractTrace trace = container.getTrace();

trace.addInfo("container: "container);+

trace.addInfo("iData: "iData);+

if(iData == null){

+ trace.addInfo("NO ELEMENT found!");+

}

if(container == null){

+ trace.addInfo("NO container found!");+

}

if(iData.length() < 1){

+ trace.addInfo("Empty or No element found - insert empty entry (space)");+

+ return " ";+

}

return iData;

Thanks in advance

Michael

Accepted Solutions (0)

Answers (3)

Answers (3)

michael_buchli
Participant
0 Kudos

no answer found!

Former Member
0 Kudos

Hi Michael,

Create a UDF of type value,

Suppose in is the input and out is output of UDF..

Then Code as follows:

if(in==null)

{

out = " Empty String Found ";

}

else

{

out = in ;

}

return out;

Use this code...and get ur problem solved!!!

Regards,

AshwinM

[Dont forget to mark the answer]

michael_buchli
Participant
0 Kudos

Hi Ashwin,

that was exactly my solution. Unfortunately this one doesn't work.

The UDF neighter detect an empty paramter as null nor as String.lenght() < 1.

Former Member
0 Kudos

Hi,

> But for re-using reasons i'd like to create a UDF

UDF could only be reused inside of one message mapping.

Maybe you could use the mentioned standard function and put them in a message template:

http://help.sap.com/saphelp_nw04/helpdata/en/79/2835b7848c458bb42cf8de0bcc1ace/frameset.htm

Regards

Patrick