cancel
Showing results for 
Search instead for 
Did you mean: 

UDF

Former Member
0 Kudos

Hi,

I want to use simple user defined function in xi to reverse a string .

I have written the java code :

public class StringRevChar {

public static void main(String[] argv) {

//+

String sh = "FCGDAEB";

System.out.println(sh + " -> " + new StringBuffer(sh).reverse());

//-

}

}

the code is working .

<b>But I dont know how to write this code in UDF portion of XI .</b>Pls help me .

Thanx & Regards,

somenath

Accepted Solutions (1)

Accepted Solutions (1)

justin_santhanam
Active Contributor
0 Kudos

Somenath,

Create simple UDF - Cache- Value ;

String sh ="FCGDAEB";

StringBuffer sb = new StringBuffer(sh);

sb.reverse();

return""sb.toString()"";

Best regards,

raj.

Answers (9)

Answers (9)

Former Member
0 Kudos

thanks Raj ............... ur answer is very helpful

justin_santhanam
Active Contributor
0 Kudos

U welcome,

Best Regards,

raj.

Former Member
0 Kudos

Hi,

I have done the mapping in mapping editor and the code is working , but i want to take the input from the user ...... but i dont know how to read it

former_member192892
Active Contributor
0 Kudos

Somenath

Do u wan2 take input from a user, like d case of a text box in an html page and you wan2 show him the output..Is it????

Former Member
0 Kudos

Hi Varun,

I have done this . I want to know how take the input in xi?

former_member192892
Active Contributor
0 Kudos

You wan2 test the mapping or do u wan2 run a scenario?????

justin_santhanam
Active Contributor
0 Kudos

Somenath,

Refer the link http://flickr.com/photo_zoom.gne?id=976271330&size=o

Describing accorning to the URL

Cache : Value.

Argument : input_name

<b>//Code:</b>

StringBuffer sb = new StringBuffer(input_name);

sb.reverse();

return""sb.toString()"";

Best regards,

raj.

Former Member
0 Kudos

thanx everybody 4 reply the code(sample code of raj) is working in XI. But what is the procedure to take the i/p from user? suppose i want to take the string from the user

thanx ,

somenath

former_member192892
Active Contributor
0 Kudos

First double click on your target node which u wan2 assign the value,

Then double click on the source node

Drag your UDF in the Mapping editor area,

Then click and drag the arrow from source 2 UDF and UDF 2 target

Thanks

Varun

Shabarish_Nair
Active Contributor
0 Kudos

http://help.sap.com/saphelp_nw04/helpdata/en/22/e127f28b572243b4324879c6bf05a0/content.htm

take a look into that link on how to create a UDF, and then try to implement the code that was provided in the above suggestion.

Former Member
0 Kudos

You don't need to use the Class name and Main methods in UDF. Just create a function with input parameter as the source string, and work on that string in order to get the output in reverse.

You can just use the logice which you have specified.

Thanks

Krishna.

Former Member
0 Kudos

Hi

In the left hand side of Message Mapping Editor, there is an option User Defined.Use this and map it to the source and target.you will be successful in achieving your goal.

Thanks

Former Member
0 Kudos

Hi Somenath,

The same code will work in XI also. Just few modification required.

1. take the your string as the input to the UDF and UDF type as value

2. Your input varible name is "sh"

3. Write the following logic

return( new StringBuffer(sh).reverse() );

This will work fine in XI. I hope you understand clearn.

Warm Regards,

Vijay

former_member192892
Active Contributor
0 Kudos

Please give your input tag as an argument to the UDF

Then in your udf do this

function(String arg, Container container)

{

String output = (new StringBuffer(arg).reverse()).toString();

return output;

}