cancel
Showing results for 
Search instead for 
Did you mean: 

Doubt in coding user defined functions

Former Member
0 Kudos

I am new to XI and I need some clariffications. While writing user defined functions, every argument is converted to string by default. Is it possible to convert the default string argument to integer value? If so how? Can any one plz tell me?

Accepted Solutions (0)

Answers (8)

Answers (8)

Former Member
0 Kudos

Thank you very much friends.. i got the answer

Former Member
0 Kudos

Hi Naresh,

Suppose say u want to convert the string to integer

String s= "123";

The exact format to convert it into integer:

int i = Integer.parseInt("123");

Now in XI the return type is String so integer to String the format is

String s = Integer.toString(i);

Thanks

Arijit

Former Member
0 Kudos

Hi,

Writing use defrined functions in XI is quite simple. Create a simple UDF, give the import parameters and then just go ahead with the logic coding and then return the output from the UDF.

Just remember that all inputs and outputs to an UDF are always Strings.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/be05e290-0201-0010-e997-b6e...

This link for User Defined Functions,

http://help.sap.com/saphelp_nw04/helpdata/en/d9/718e40496f6f1de10000000a1550b0/content.htm

please see the below blog for user-defined functions:

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

Just check these out.

http://help.sap.com/saphelp_erp2005/helpdata/en/45/244c40aa6a0272e10000000a155106/frameset.htm

In order to create UDFs, you need to have a basic idea about using Core Java. Also, based on the kind of functonality of the code, you will need to know if you require any extra jar files.

To create a UDF, all you need to do is click on LHS icon in the graphical mapping editor. Also, keep in min that the input and otput of a udf is always in strings.

To test your functions, you can either use the test tab present in the mapping editor or you can even use the following editor(blog by Sravya):-

I think info will be enough for you to start off with creating and using UDFs:)

Also, since you are an ABAPer, you might be interested in this blog which discusses how to use the ABAP editor to create, modify and test java programs!:-

Regards,

Suryanarayana

Former Member
0 Kudos

Hi,

In UDF, the import argument is always "String".

We can convert it to integer by using the parsing code.

int b = Integer.parseInt(a); where a is the input

Then, again we can convert it to string as

a = b.toString();

former_member192295
Active Contributor
0 Kudos

HI,

It is possible use this function return (Integer.parseInt(str_var))

prateek
Active Contributor
0 Kudos

String YourString = "XX";

int YourInt = Integer.parseInt(YourString);

Regards,

Prateek

Former Member
0 Kudos

Hi,

You can do like this

Receive String and convert it into Integer inside coding and use it.

In UDF of graphical mapping, u may use the following code:

String strName = "true";

int b = Integer.parseInt(strName);

Regards

Seshagiri

santhosh_kumarv
Active Contributor
0 Kudos

Hi,

You can do this using the parsing function of Java.

If a is a string input u can convert it to integer as

Int n = Integer.parseInt(a);

Thanks

SaNv...