cancel
Showing results for 
Search instead for 
Did you mean: 

How to make value help input field case insensitive

Former Member
0 Kudos

Hello Everybody,

I have provided value help for my one of the input fields in webdynpro application.

This value help has lots of records lets say around 100 records in it. I have generated this list using valueset. But, without opening value help if I directly enter correct value without maching the case it gives me error that this value doesnot exist in the list.

This is the problem due to case sensitivity only. So, how can i avoid case sensitivity for this value help?

Thanks in advance,

Bhavik

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi All,

I tried the link sent by Valery. It is not working for the EVS++ scenario. I tried implementing the source code but no clues.

Has any really tried this scenario?

Regards,

Balaji S

Former Member
0 Kudos

I am astonished....no body has ever come across such a scenario.....

Former Member
0 Kudos

Balaji,

<i>I tried the link sent by Valery. It is not working for the EVS++ scenario</i>

Hmmmm... This link describes EVS++ scenario itself. So I didn't understand your phrase.

Just to outline what I mean:

1. Original attribute is proxied with calculated attribute (with getter / setter methods) of same type

2. Getter is simple: return element.get<OriginalAttrName>;

3. In setter do the following: element.set<OriginalAttrName>( null == value ? null : value.toLowerCase() );

or value.toUpperCase();

That's all.

VS

Former Member
0 Kudos

Hi

Valery

Yes you are right there are two attributes one is orginal and other is proxy , if i see the getter and setter are as follows will you tell me where exactly i have to set the suggested code in setter and getter

===================

public java.lang.String getColorNameCalc(IPrivateMain.IContextElement element) <b>// (Proxy Attributes Getter)</b> {

//@@begin getColorNameCalc(IPrivateMain.IContextElement)

String attributeName = IPrivateMain.IContextElement.COLOR; <b>//(Original Attribute)</b>

IWDAttributeInfo attributeInfo =

element.node().getNodeInfo().getAttribute(attributeName);

ISimpleType simpleType = attributeInfo.getSimpleType();

ISimpleValueSet valueset = simpleType.getSVServices().getValues();

Object key = element.getAttributeValue(attributeName);

try {

simpleType.checkValid(key);

return valueset.getText(key);

} catch (DdCheckException e) {

// return "";

return ""; // (Cnange: return elemet.getColur(); with this i am not getting any error in EVS++ but still if i enter bl in EVS+ i am getting message String "bl" does not match the enumeration)

}

//@@end

}

===============================

public void setColorNameCalc(

IPrivateMain.IContextElement element,

java.lang.String value) {

//@@begin setColorNameCalc(IPrivateMain.IContextElement, java.lang.String)

// precondition: the roundtrip is based on a validating action. For non-validating actions the retrieved

// value may be invalid.

String attributeName = IPrivateMain.IContextElement.COLOR;

IWDAttributeInfo attributeInfo =

element.node().getNodeInfo().getAttribute(attributeName);

ISimpleType simpleType = attributeInfo.getSimpleType();

try {

simpleType.checkValid(value);

// value already is a valid key

element.setColor(value);

} catch (DdCheckException e) {

// value is not a key but a displaytext

// => lookup the key for the text, based on a first-in-first-out approach.

// Identical displaytexts for different keys are not handled.

Set entrySet = simpleType.getEnumerationTexts().entrySet();

for (Iterator iter = entrySet.iterator(); iter.hasNext();) {

Map.Entry entry = (Map.Entry) iter.next();

if (entry.getValue().equals(value)) {

element.setColor((String) entry.getKey());

break;

}

}

}

//@@end

}

Thanks in Advance

Murali

Message was edited by: Murali Manohar

Message was edited by: Murali Manohar

Former Member
0 Kudos

Murali,

In your version there are 2 places in setter method

(assuming your keys are all uppercase or lowercase)

1. In the beginning of method:


if ( null == value ) 
{
  element.setColor(null);
  return;
} 
value = value.toLowerCase();
...

2. In for loop:


...
if ( value.equalsIgnoreCase( (String)entry.getValue() ) ) 
...

VS

Message was edited by: Valery Silaev

Former Member
0 Kudos

Valery,

My keys are Upper case

I am bit confused, there is one setter and one getter method only.

This what i did

public void setColorNameCalc(IPrivateMain.IContextElement element, java.lang.String value)

{

//@@begin setColorNameCalc(IPrivateMain.IContextElement, java.lang.String)

// precondition: the roundtrip is based on a validating action. For non-validating actions the retrieved

// value may be invalid.

// element.setColor(value);

String attributeName = IPrivateMain.IContextElement.COLOR;

IWDAttributeInfo attributeInfo = element.node().getNodeInfo().getAttribute(attributeName);

ISimpleType simpleType = attributeInfo.getSimpleType();

if ( null == value )

{

element.setColor(null);

return;

}

value = value.toLowerCase();

try {

simpleType.checkValid(value);

// value already is a valid key

element.setColor(value);

} catch (DdCheckException e) {

// value is not a key but a displaytext

// => lookup the key for the text, based on a first-in-first-out approach.

// Identical displaytexts for different keys are not handled.

Set entrySet = simpleType.getEnumerationTexts().entrySet();

for (Iterator iter = entrySet.iterator(); iter.hasNext();) {

Map.Entry entry = (Map.Entry)iter.next();

// if (entry.getValue().equals(value)) {

if (value.equalsIgnoreCase( (String)entry.getValue() )) {

element.setColor((String)entry.getKey());

break;

}

}

}

//@@end

}

Still i am getting same error, any suggestions

Former Member
0 Kudos

Even i tried this. but it is not working. i have set the value to upper case, always, but then it doesn't work. In the debugger i saw that it perfectly converts the value to upper cases and sets it to "element" without any error but after coming out of the setXXXX() method it again give the same error.

I entered the value "fu" in small letters instead of "FU" in capital letters....it says; "fu" doesn't match the enumeration.

Here is my code in setXXX method;

if(null == value){

element.setColor(null);

return;

}else{

element.setColor(value.toUpperCase());

}

String attributeName = IPrivateMain.IContextElement.COLOR;

IWDAttributeInfo attributeInfo =

element.node().getNodeInfo().getAttribute(attributeName);

ISimpleType simpleType = attributeInfo.getSimpleType();

try {

String newValue = value.toUpperCase();

simpleType.checkValid(newValue);

} catch (DdCheckException e) {

Set entrySet = simpleType.getEnumerationTexts().entrySet();

for (Iterator iter = entrySet.iterator(); iter.hasNext();) {

Map.Entry entry = (Map.Entry) iter.next();

if (value.equalsIgnoreCase( (String)entry.getValue() ) {

break;

}

}

}

The call to simpleType.checkValid(newValue) doesn't fail and go to the catchblock at all....but still i am getting the error message.

VS: Any thoughts?

Message was edited by: Aditya Atluri

Message was edited by: Aditya Atluri

Former Member
0 Kudos

Murali,

If your keys are in upper case, then use

value = value.toUpperCase();

VS

Former Member
0 Kudos

Aditya,

Error is here:


if(null == value){

element.setColor(null);
return;

}else{ 
/* WRONG!!! */
/* element.setColor(value.toUpperCase()); */
value = value.toUpperCase();
}

Former Member
0 Kudos

VS,

But this value = value.toUpperCase() i have done it in the subsequent statement. Anyway, i have checked by doing this but still it doesn't work.

Former Member
0 Kudos

But the problem is

<b>element.setColor</b>(value.toUpperCase());

I commented it out, actually it should be placed in "try" block after checkValid.

VS

Former Member
0 Kudos

HI

VS

I just followed the EVS++ tutorial given in sdn

here is the code for setter

public void setColorNameCalc(IPrivateMain.IContextElement element, java.lang.String value)

{

//@@begin setColorNameCalc(IPrivateMain.IContextElement, java.lang.String)

// precondition: the roundtrip is based on a validating action. For non-validating actions the retrieved

// value may be invalid.

// element.setColor(value);

if (null == value) {

//element.setColor(null);

element.setColor(null);

return;

} else {

value = value.toUpperCase();

}

String attributeName = IPrivateMain.IContextElement.COLOR;

IWDAttributeInfo attributeInfo =

element.node().getNodeInfo().getAttribute(attributeName);

ISimpleType simpleType = attributeInfo.getSimpleType();

try {

simpleType.checkValid(value);

// value already is a valid key

//element.setColor(value);

element.setColor(value.toUpperCase());

} catch (DdCheckException e) {

// value is not a key but a displaytext

// => lookup the key for the text, based on a first-in-first-out approach.

// Identical displaytexts for different keys are not handled.

Set entrySet = simpleType.getEnumerationTexts().entrySet();

for (Iterator iter = entrySet.iterator(); iter.hasNext();) {

Map.Entry entry = (Map.Entry) iter.next();

// if (entry.getValue().equals(value)) {

if (value.equalsIgnoreCase((String) entry.getValue())) {

element.setColor((String) entry.getKey());

break;

}

}

}

//@@end

}

Still unable to resolve the error,

By default key is Upper case

BL BLUE

RE RED

now if enter say bl EVS++ throws an error as mentioned erlier.

how can i resolve this..

Former Member
0 Kudos

Murali,

You are right -- WD generates and error, however setter method is executed successfully (my server is NW04s, btw, what is yours?).

Now I'm wondering how original EVS++ works...

I found a workaround -- I will post a solution on Thu.

VS

Former Member
0 Kudos

VS,

My server is NW04,

Fine i will wait till Thu..

Regards,

Murali

Former Member
0 Kudos

Hi All,

I facing this similar problem.

What i did is;

In the view implementation convert the value to the uppercase. This will make sure that on any action your value is converted to the uppercase. But then after this it is again checks some internal code and displays the error message. So, for once you cannot avoid the error statement; String XXX doesn't match the enumeration. On subsequent actions, since the value is already converted to the required upper case there will not be any error.

Any suggestions to avoid displaying this standard error message?

There should be a decent way of handling this.

Message was edited by: Kumar Kasavaraju

Former Member
0 Kudos

Murali (et al),

The solution deserves blog post or article, I plan to publish an entry in my blog later. You'll be able to download the code sample from there!

Some keys:

1. Calculated attribute may not have EVS, so it should be of simple "string" type.

2. EVS is emulated completely using OVS (ok, UI is a bit different, but functionality preserved and enhanced).

3. See only ColorCalcOVS related stuff, wdDoInit and second line of UI controls. First line is my initial attempt, you may make a guess why I abandon it (hint: view application with Mozilla)

4. You may also type case-insensitive key/display-text in input field directly -- it would be applied.

Good luck.

Message was edited by: Craig Cmehil

Former Member
0 Kudos

VS,

Can you please tell me how to get this EVSQueryBinder into my project? I need to implement this scenario in my project and when i am trying to do the same thing in my init, getColor and seColor methods, it gives me this error EVSQueryBinder.IHelper cannot be resolved

Message was edited by: Aditya Atluri

Former Member
0 Kudos

VS,

Please let me know. Its Urgent.

Former Member
0 Kudos

Published to my blog:

/people/valery.silaev/blog/2006/03/10/minus-evs-plus-ovs-value-help-smart-input

Download link for sample project is at the end of post.

VS

Former Member
0 Kudos

Hmmm....Pretty huge. My requirement is, i have a input field to which i am attaching a context attribute. I am populating this context attribute with data from the BAPI. I dont require OVS.....If possible can you pls help me with a code snipped for this scenario?

Below is my code...

ISimpleTypeModifiable regionType =

wdContext

.getNodeInfo()

.getAttribute("Region")

.getModifiableSimpleType();

IModifiableSimpleValueSet regionSet =

regionType.getSVServices().getModifiableSimpleValueSet();

regionSet.clear();

if (!(wdContext

.node<BAPI>()

.node<Output>()

.node<Tablenode>()

.size()

== 0)) {

I<TableNode>Node node =

wdContext

.node<BAPI>()

.node<Output>()

.node<TableNode>();

for (int i = 0; i < node.size(); i++) {

IWDNodeElement elem = node.getElementAt(i);

regionSet.put(

elem.getAttributeAsText("Bland"),

elem.getAttributeAsText("Bezei"));

Also, i tried to write the code you gave in your weblog by creating a Java class file in my project. -

package com.sap.sdn.samples.evspp.ovs;

import java.util.Locale;

import java.util.Collection;

import java.util.Comparator;

import java.util.Iterator;

import java.util.Map;

import java.util.ArrayLis............

Here i couldn't understand where from should i get the below packages

import com.sap.sdn.samples.cmi.CMIBean;

import com.sap.sdn.samples.cmi.CMIInfo;

import com.sap.sdn.samples.cmi.DictionaryTypes;

Can you please let me know a step by step approach for this?

Former Member
0 Kudos

Aditya,

<i>Hmmm....Pretty huge.</i>

Yep, sometimes it takes certain effort to get what you want.

<i>...I dont require OVS.....</i>

Me either. But OVS is not a result or value per se, it is a tool to achieve result and get work done.

I didn't find other way to implement this functionality. Btw, if you <b>read</b> a post, you would undertand why OVS was used and EVS was discarded.

<i>

Here i couldn't understand where from should i get the below packages

import com.sap.sdn.samples.cmi.CMIBean;

import com.sap.sdn.samples.cmi.CMIInfo;

import com.sap.sdn.samples.cmi.DictionaryTypes;

</i>

I don't understand you. Do you expiriencing problems with re-naming *.jar file to *.zip file and extracting necessary sources? Zip is broken? Or sources are missing? I verified that everything ok twice...

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com

Former Member
0 Kudos

VS,

I could import your project successfully and checked the same. Its good to see that you have solved the problem. Renamed the .jar to .zip. Extracted the same. Copied into my workspace.

But then when i try to implement the same in my project, i am facing these difficulties.

I wrote the same code which you did in your project. Init method, Getter methods, Setter methods.

Here it says EVSQueryBinder.IHelper cannot be resolved. I understand i need to do;

import com.sap.sdn.samples.evspp.ovs.EVSQueryBinder;

In your weblog you have given the code for OVS4EVS and EVSQuery which when imported should allow me to achieve the result . For this, i created a java file and pasted your code. Here it says, unable to interpret CMIBean, CMIINfo, DictionaryTypes. Now, i have to import

import com.sap.sdn.samples.cmi.CMIBean;

import com.sap.sdn.samples.cmi.CMIInfo;

import com.sap.sdn.samples.cmi.DictionaryTypes;

Here i am stuck again. Where these packages are available. If all the above are available in the same project given by you, Probably i dont know how to use/import them.

I went to Navigation explorer. Navigated to SDN_EVS=>SRC=>Packages=>Com.sap.sdn.samples. exported both cmi and evspp . Imported the same into my project. Let me know if i am doing this wrong.

Please suggest.

Former Member
0 Kudos

Aditya,

From original project structure via path ./src/packages, copy the following packages to the same path in your own project:

com.sap.sdn.samples.cmi

com.sap.sdn.samples.cmi.evspp.ovs

com.sap.sdn.samples.cmi.evspp.types

VS

Former Member
0 Kudos

Thanks VS.

I tried to do a replica of your project. Now only OVS is working but not EVS. No values are getting populated. Any suggestions where i am going wrong?

I am doing exactly the same thing as you were doing. No idea why the values are not populated into EVS here. My bad day.

Message was edited by: Aditya Atluri

Former Member
0 Kudos

<i>No values are getting populated</i>

One of the following rules is not satisfied:

1. Your "real" attribute must be of type with enumeration (your calculated attribute must have no enumeration)

2. You have to bind OVS to calculated attribute, not to "real" one.

3. Parameters for bind is calculated attribute first, "real" attribute second.

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com

P.S. Please post any other questions directly as weblog comments.

Former Member
0 Kudos

Hi Bhavik,

was the answer the solution? If yes: could you briefly explain how? If not: Could you briefly explain, what else you did?

Thanks and regards,

Simon

Former Member
0 Kudos

Bhavik,

I guess EVS++ technique should solve this issue.

See https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/webdynpro/ye... another evs valuehelp - showing display texts for keys.article

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com

Former Member
0 Kudos

Valery,

Can you please explain how this can be done. I am stuck here.

Regards,

Aditya

Former Member
0 Kudos

Hi

Valery,

With EVS++ also it's not possible,i checked it is there any way..

Regards,

Murali

Former Member
0 Kudos

Murali,

Funny -- it works for me.

Key trick here is calculated attribute: if you expose calculated atribute via UI control (but not original attribute) you may pre-format oroginal value before display and post-parse entered value after change.

I'd even described far more complex example here /people/valery.silaev/blog/2005/11/29/800format-your-way (without EVS, thought)

How it fails for you? What steps did you perform?

VS