cancel
Showing results for 
Search instead for 
Did you mean: 

data conversion from integer to string

Former Member
0 Kudos

hi,

I have converted an integer data type to string.Now at run time the input field which is mapped to this integer bata type is showing a 0 and becoze of this iam not able to run a validation which says "that if the input field is empty then approve button cannot be clicked"

my code:

String text=String.valueOf(wdContext.currentVn_STl_PAapprovElement().getVa_amtwaived());

wdComponentAPI.getMessageManager().reportSuccess("text"+text);

if(doctype.equalsIgnoreCase("DA")&& (text==null)&&(text=="0"))

{

wdContext.currentVn_inactivenableElement().setVa_approvebtn(false);

}

what change ai have to make it look empty at run time

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

What is the exact DDIC (data dictionary) type of your context attribute? Is it "integer" or "integerObject"? See also

http://help.sap.com/saphelp_nw70/helpdata/EN/42/c04c950ad21d65e10000000a1553f6/content.htm

http://help.sap.com/saphelp_nw70/helpdata/EN/4c/40ba420db1cc66e10000000a1550b0/frameset.htm

If it is has DDIC type "integer" then the runtime type is "int" and you just cannot check if no value is set, because it always has a value.

If it has DDIC type "integerObject", the runtime type is "Integer" and it can also have a NULL value. To check if the value is not set, compare the attribute value with NULL, no need to convert to string etc.

Just forget all these proposals with accessing the input field in wdDoModifyView() and using setText() etc..

Armin

Former Member
0 Kudos

Hello Nisha,

Try this code;


String text = wdContext.currentVn_STl_PAapprovElement().getVa_amtwaived().toString();
wdComponentAPI.getMessageManager().reportSuccess("As String " + text );
if( doctype.equalsIgnoreCase( "DA") && ( text == null) && ( text.equals( "0")))
{
wdContext.currentVn_inactivenableElement().setVa_approvebtn( false);
}

Here the value of text will be pure string and now try this code.

One more thing; i don't find any logic in using && for testing text as null or 0.

I hope this is what you were trying for.


if( doctype.equalsIgnoreCase( "DA") && ( ( text == null) || ( text.equals( "0"))))
{
  //Statements
}

Regards

- Vinod V Pillai

*

Former Member
0 Kudos

Hi,

As your input field is of datatype int why dont you try as follows



int x = wdContext.currentVn_STl_PAapprovElement().getVa_amtwaived();
	  if(wdContext.currentVn_STl_PAapprovElement().getVa_amtwaived() == 0 )
	  {
		  wdContext.currentVn_inactivenableElement().setVa_approvebtn(false);
	  }


Regards

Ayyapparaj

nikhil_bose
Active Contributor
0 Kudos

dont' type cast it for comparison;

you can use following code for comparison.

if(doctype.equalsIgnoreCase("DA"))

{

if ( wdContext.currentVn_STl_PAapprovElement().getVa_amtwaived()==0 )

{

// put your code here..

}

}

regards,

nikhil

Edited by: Nikhil Bos on Apr 4, 2008 6:17 PM

Former Member
0 Kudos

Hi,

Can be more clear....

1) u have a input field - datatype mapped to integer.

2) u have doctype -- string

3) now u have to check ..if the input field is 0 or null , and doctype if equals "DA" then u want to make the button disable ... Is that u want , If any other thing pls mention.

Also can say what is the output for this ...

String text=String.valueOf(wdContext.currentVn_STl_PAapprovElement().getVa_amtwaived());

wdComponentAPI.getMessageManager().reportSuccess("text"+text);

/*

if(doctype.equalsIgnoreCase("DA")&& (text==null)&&(text=="0"))

{

wdContext.currentVn_inactivenableElement().setVa_approvebtn(false);

}

*/

// what is the value it is printing for text.

Is it giving any runtime error ????

Thanks,

Srini

Former Member
0 Kudos

Also change code:

if(doctype.equalsIgnoreCase("DA")&& (text==null)&&(text=="0"))

to

if(doctype.equalsIgnoreCase("DA")&& ((text==null) || (text=="0")))

Regards,

Gopal

Former Member
0 Kudos

In wdModifyView Try following code:

if(firstTime){
    	IWDInputField text = (IWDInputField) view.getElement("InputFieldID");
    	text.setValue("");
    }

Instead of InputFieldID, give id of input fied you want empty.

Regards,

Gopal

Former Member
0 Kudos

actuyally i have to write the code in action of approve button so can't write it in wdmodify view.plz help

Former Member
0 Kudos

please explain the code in detail.

Former Member
0 Kudos

this code is not give any results

if(doctype.equalsIgnoreCase("DA")&& (text==null)||(text=="0"))

Former Member
0 Kudos

Hi ,

Check with this code

change

if(doctype.equalsIgnoreCase("DA")&& (text==null)||(text=="0"))

to

if(doctype.equalsIgnoreCase("DA")&& (text.lenght() <=0))

Regards,

Sunitha Hari

Former Member
0 Kudos

Try this ...

if(doctype.equalsIgnoreCase("DA"))

{

if (text==null || text.equals("0") )

{

// your code ....

}

}

// because you are comaparing string with == , use equals method .

Thanks ,

Srini

Edited by: srinivasa rao on Apr 4, 2008 12:41 PM

Edited by: srinivasa rao on Apr 4, 2008 12:42 PM

Former Member
0 Kudos

The issue is still not solved

Former Member
0 Kudos

Hi Nisha,

Sorry I was busy with some other work. So could not respond early.

Following code is used to make InputField llok empty at run time. Anybody can fill data in it afterwards:

Code have to be in wdModifyView

if(firstTime){

IWDInputField text = (IWDInputField) view.getElement("InputFieldID");

text.setValue("");

}

Following code is for making your code correct. Nothing related to what your requirement is:

Instead of code

if(doctype.equalsIgnoreCase("DA")&& (text==null)&&(text=="0"))

put

if(doctype.equalsIgnoreCase("DA")&& ((text==null)&&(text.equals("0"))))

[I have used equals as suggested by Srinivas]

Regards,

Gopal