Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

function module on string

Former Member
0 Likes
535

hi friends,

i have a parameter (var1) which is declared as String .now i want a function module which will not allow any other datatype otherthan number (type N) to be entered in that variable.is there any function module like that?would appreciate if u help me.

thanks and regards,

kanti

3 REPLIES 3
Read only

Former Member
0 Likes
410

I think this should be done as validation after input only. But, no matter what data you enter, since it will be compatible with String type, ti will not throw an error. You can do this validation for other data types maybe, but I doubt if it will work on a string.

Read only

Faaiez
Product and Topic Expert
Product and Topic Expert
0 Likes
410

Hi Kanti

You don't need a function module.

You can do this by using the following statement:

if var1 ca '0123456789'.

...

endif.

<b>CA</b> Contains Any: True, if operand1 contains at least one character from operand2. Upper/lower case and trailing blanks are taken into account for both operands. If operand1 or operand2 is of type string and initial, the logical expression is always false. If result of the comparison is positive, sy-fdpos contains the offset of the first character in operand1 that is also contained in operand2. If the result of the comparison is negative, sy-fdpos contains the length of operand1.

Regards

Read only

Former Member
0 Likes
410

Hi Kanti,

Take help from this code:

Data : Str_num TYPE string.

str_num = ' 0123456789'.

IF number CO str_mob.

.......................

ELSE.

Eroor Message.................

ENDIF.

Regards,

Sandeep kaushik