cancel
Showing results for 
Search instead for 
Did you mean: 

Checking for # in Text Edit

Former Member
0 Kudos

Hi All,

I have a textedit in a view. On submitting of the page, when no data is entered , and if I check the value of this variable in my controller, I get a # assigned as the value.

I understand that this is some hex value but not against which value it should be checked. I tried to check as

IF model->text_value EQ CL_ABAP_CHAR_UTILITIES=>NEWLINE.

CLEAR model->text_value.

ENDIF.

Also,I checked it against CL_ABAP_CHAR_UTILITIES=>NEWLINE

but no use.

The model->text_value variable is of type CHAR255.

I need to enforce mandatory check for this field in my function module but since it has some hex value, even though user has not entered any value, the mandatory check fails in the function module.

Please help.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

I'd try the other constants in that class like CL_ABAP_CHAR_UTILITIES=>CR_LF, HORIZONTAL_TAB, etc., if you're not positive that this hex# is a NEWLINE.

I've had problems checking for these values with EQ, try a different string relational operator like CN, I'd need to review the documentation for the right one.

eddy_declercq
Active Contributor
0 Kudos

Hi,

Try debugging your code. Double click on the name of the field, you'll see the content. Next to it, you have a magnifying glass wit a plus in it. CLick on that and you'll see the hex value. Then you can see if it's one of the usual suspects.

Eddy

Former Member
0 Kudos

You are right. EQ comparison does not work.

I put this code

IF model->value CN CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.

CLEAR model->value.

ENDIF.

It worked and model->value got cleared when user does not enter value.

BUt this works even if the user enters some value in the textedit field which should not happen.

How do I trap this?

Former Member
0 Kudos

Hi Eddy,

I checked in teh debugger and found that the value is something like this:

002020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020

Former Member
0 Kudos

Trap it by checking the string size...

data len type i.

len = strlen( p_string ).

if len > 0

clear

end

Or, shift the string left one position...

Message was edited by: Matt Herzog

Former Member
0 Kudos

Hi Matt,

If I do this, then even when user enters data, it will be cleared and data will be lost.

I need to do this only when there is no user data entered and

model->value CN CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.

eddy_declercq
Active Contributor
0 Kudos

Hi,

That's a NULL, followed by spaces.

Doesn't SPACE_STR within CL_ABAP_CHAR_UTILITIES do anything?

Eddy

Former Member
0 Kudos

OK,

I still don't understand why you couldn't check the size of the string and SHIFT str LEFT BY 1 PLACES?

Or if the hex# is there in all cases, try doing the shift all the time...

Former Member
0 Kudos

Hi Eddy,

How do I compare it against SPACE_STR OF CL_ABAP_CHAR_UTILITIES coz this is a private attribute and I get an error in my controller when I put this code.

IF model->value CN CL_ABAP_CHAR_UTILITIES=>SPACE_STR.

Is there a way where I can trim the spaces and or remove the null value?

eddy_declercq
Active Contributor
0 Kudos

Hi, removing the space can be done with

condense ... no-gaps.

Have a look at http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb33e6358411d1829f0000e829fbfe/frameset.htm

for examples.

Eddy

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

It could be a horizontal tab?

Regards,

Rich Heilman