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

Compare value with characters

Former Member
0 Likes
1,100

Hi all,

how can I write this correctly?

if     order >= '0003A0000'

and order <= '0003Z9999'.

so in other words if the order is something like '0003B0000' then the it would do the processing.

Now when I write this, program runs into an error.

Thanks,

Tim

1 ACCEPTED SOLUTION
Read only

arivazhagan_sivasamy
Active Contributor
0 Likes
1,060

Hi,

Try below this.

if order BETWEEN '0003A0000' and  '0003Z9999'.

Regards,

Arivazhagan S

8 REPLIES 8
Read only

arivazhagan_sivasamy
Active Contributor
0 Likes
1,061

Hi,

Try below this.

if order BETWEEN '0003A0000' and  '0003Z9999'.

Regards,

Arivazhagan S

Read only

Former Member
0 Likes
1,060

Hello Tim,

That should work perfectly fine. Problably is the type of the order variable that is wrong?

Try using a Char type.

This works:

data: order type vbeln.

order = '0003B0000'.

if order >= '0003A0000'and order <= '0003Z9999'.

   write 'ok'.

endif.

Read only

Former Member
0 Likes
1,060

Did u try LE (instead of <= ) and GE (instead of >= )

Read only

Former Member
0 Likes
1,060

What is the data type of order?

For data type String and character (c), it should work.

DATA: l_one(15) type c,

       l_two(15) TYPE c,

       l_find(15) TYPE c.

l_one = '0003A0000'.

l_two '0003Z9999'.

l_find '0003B0000'.

IF l_find >= l_one

   AND l_find <= l_two.

   WRITE 'ok'.

else.

   write 'not found'.

ENDIF.

Read only

Former Member
0 Likes
1,060

Hi Tim,

You code is working fine for me.. What is the error that you get? Make sure order is a character field.

data : aufnr_l like vbrp-aufnr VALUE '0003A0000'.
data : aufnr_h like vbrp-aufnr VALUE '0003Z9999'.

PARAMETERS p_aufnr LIKE vbrp-aufnr.

if p_aufnr LT aufnr_h and p_aufnr GT aufnr_l.
*if p_aufnr <= '0003Z9999' and p_aufnr => '0003A0000'.
   write : 'Within limit'.
else.
   write : 'Outside limit'.
endif.

Read only

former_member188219
Participant
0 Likes
1,060

if wa_datatab1-row >= '11' and   wa_datatab1-row >= '12'.

     ENDIF.

Read only

Former Member
0 Likes
1,060

Thanks for all your quick answers. The program actually worked fine in that part, exception was raised because of a different error and I assumed it is because of the above.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,060

Perform some search on Abap online documentation : log_exp - Comparison Operators for Character-Like Data Types

Also check the actual internal format of the order number

Regards,

Raymond

PS: hint : look for "CP" and "wildcard".

PPS: hint : leading zeroes and actual length (or define constants with correct type)