Application Development 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: 

How to validate charcter between number range

former_member459142
Participant
0 Kudos

Hi experts,

My number range is from 'AA00000001' to 'ZZ99999999'.

if i am passing number 'BB12131234' and this series exist in renge given above

SO according to my code its showing out of range.


 if number between 'AA00000001' and 'ZZ99999999'
*      NUMBER IS IN RANGE
      return-message = 'Customer Created Successfully'.
    ELSE.
*     NUMBER IS OUT OF RANGE
      return-message = msg.
    ENDIF.

So how i check my series in the range

thanks

1 ACCEPTED SOLUTION

sridhar_meesala
Active Contributor
0 Kudos

Hi,

number = 'BB12131234'.

 IF number between 'AA00000001' and 'ZZ99999998'.
    MESSAGE 'Customer Created Successfully' TYPE 'I'.
 ELSE.
    MESSAGE 'Out of range' TYPE 'I'.
 ENDIF.

is giving me the correct output only.

Thanks,

Sri.

7 REPLIES 7

former_member459142
Participant
0 Kudos

This message was moderated.

sridhar_meesala
Active Contributor
0 Kudos

Hi,

number = 'BB12131234'.

 IF number between 'AA00000001' and 'ZZ99999998'.
    MESSAGE 'Customer Created Successfully' TYPE 'I'.
 ELSE.
    MESSAGE 'Out of range' TYPE 'I'.
 ENDIF.

is giving me the correct output only.

Thanks,

Sri.

Former Member
0 Kudos

Hi,


 IF number(2) CO 'ABCDEFGHIJKLMNOPQRSTUVZX' 
   AND number+2(8) CO  '0123456789' 
   AND number+10(1) NE '0'.
*      NUMBER IS IN RANGE
      return-message = 'Customer Created Successfully'.
    ELSE.
*     NUMBER IS OUT OF RANGE
      return-message = msg.
    ENDIF.

Regards Marcel

Edited by: MarcelKucharek on Jan 29, 2010 10:47 AM

Former Member
0 Kudos

break ur no in two variable

var1 = BB

var2 = 12131234

now check them seperatly

if var1 between 'aa' to 'zz' and var2 between '00000001' to '99999999'

than show the message accordingly.

i dont have sap logon right now so u need to check if this logic works or not.

kesavadas_thekkillath
Active Contributor
0 Kudos

Declare it type N and check once.

Former Member
0 Kudos

Hi,

Your code itself will work..



PARAMETER: p_var(10) TYPE c. (or) PARAMETER: p_var(10) TYPE n. 

** Both Char and Numc data declaration will work correctly

START-OF-SELECTION.

  IF p_var BETWEEN 'AA00000001' AND 'ZZ99999998'.

    MESSAGE 'Customer Created Successfully' TYPE 'I'.

  ELSE.

    MESSAGE 'Out of range' TYPE 'I'.

  ENDIF.

former_member459142
Participant
0 Kudos

Thanks all