cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert string values to integer?

Former Member
0 Kudos

Hello,

I am trying to compare (one less than or equal to other)

The source fields holds integer values but declared as String.

can I compare between these values without writing UDF?

when I use standard functions, its generating me error message

Are there any Standard functions in PI.7 to cast from string to Integer?

regards,

Nikhil.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Nikhil,

Using UDF u can easily acheive what u want..

Syntax:

amount=Integer.parseInt(g[k]);

where g[k] is kth element of a string array and amount is integer.

Regards,

Pooja

Answers (3)

Answers (3)

krushii
Explorer
0 Kudos

how can i convert string in to integer??

convert string in to integer + only one value is showing when click on a button supposed i want 22 number but it does not showing it shows only 2

sap.ui.define([ "root/controller/BaseController", "sap/m/MessageToast"], function (BaseController, MessageToast) { "use strict"; return BaseController.extend("root.controller.View1", { onInit: function () { }, onNext: function () { var oRouter = sap.ui.core.UIComponent.getRouterFor(this); oRouter.navTo("View2"); }, btnPress: function (oEvent) { //MessageToast.show(oEvent.getSource().getId() + " Pressed"); var element = oEvent.getSource().getText(); MessageToast.show(element ); this.getView().byId("txtInput").setValue(element); }, function() { alert("2!") } });});

Former Member
0 Kudos

Hi Nikhil,

To the best of my knowledge there are no standard functions that cast string to integer . If it would have been equal you could have used EQUALS but less and greater need arithmetic value hece udf is your only option.

Thanks,

Sidhvin

Edited by: sidhvin ,mada on Dec 20, 2007 7:12 AM

Former Member
0 Kudos

thanks all

I wrote a UDF

thanks again

nikhil.

Former Member
0 Kudos

Hi Nikhil,

Integer.pareseInt(X): to convert a sting to integer

(X is the string value u need to convert)

new Integer(x).toString(): to convert an integer to string

u can also try these for float values as well, by replacing integer with float.

reward points if useful

Thanks

Hari.

Former Member
0 Kudos

thanks for the posts

actually I have used the same way in my previous scenario.

Just checking with u if theres any standarand function to serve this purpose

Is there any standard function that converts string values to integer values?

Former Member
0 Kudos

Hi,

these things becomes simple with UDF's.

by standard methods, did you mean by graphical mapping?

i dont think this can be done without UDF.

or u can directly select the type as integer while creating your data type.

thanks.

nikhil_bose
Active Contributor
0 Kudos

There is no standard functions that does casting a String to an Integer.

Instead you can use compare ( std: text) to compare the values if both are of string type which will return '0' if both are same, else '1'.

nikhil