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 alphanumeric value

Former Member
0 Likes
1,778

Hi All,

Can you please advise me , how can i compare alphanumeric value.

I have a table entry where postalcode-from = DA1 0AA  and postalcode-to =DA9 0ZZ. I want to select value in between these two value.For example i want to select DA2 0AA.

My select query below.

v_input = DA2 0AA.

SELECT SINGLE transpzone FROM yoet_tpzone_map

*                                 INTO x_tptzone-transpzone

*                                 WHERE country = <fs_country> AND ( POSTALCODE_FROM LE v_input AND POSTALCODE_TO GE v_input).

Here its selecting  for value DA2 0AA.

Please advise me some logic for this.

Thanks

Satya

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,230

Dear Satyaranjan Mohanty,

if  your table have any other(apart form postalcode-from and postalcode-to) field for postalcode if it is then given logic may work

V_INPUT = DA2 0AA.


SELECT SINGLE TRANSPZONE

               FROM YOET_TPZONE_MAP

               INTO X_TPTZONE-TRANSPZONE

           WHERE COUNTRY = <FS_COUNTRY>

                  AND  POSTALCODE between 'DA1 00A' and 'DA9 0ZZ'.

if you don't have that extra field POSTALCODE then the code you are write is the right one only .

if you not get output, in that case you have to fetch data related to country specific first and then you have break postal code and compare character and numeric fields seperatly.

6 REPLIES 6
Read only

Kartik2
Contributor
0 Likes
1,230

Dear Satyaranjan Mohanty,

Please read the documentation about select options and ranges and try to use them in your select query.

Define a select option without display or a range for your required variable, set the fields SIGN, OPTION, LOW and HIGH as required and then tuse in select query using th IN addition in where clause. In your case the following should be the values:

SIGN = 'I'

OPTION = 'BT'

LOW = DA1 0AA

HIGH = DA9 0ZZ

Regards,

Kartik

Read only

Former Member
0 Likes
1,230

Hi Satyaranjan,

Try this below statement

v_input_low = DA1 0AA.

v_input_high = DA9 0ZZ.

SELECT SINGLE transpzone FROM yoet_tpzone_map

                                 INTO x_tptzone-transpzone

                                 WHERE country = <fs_country> AND

                                ( POSTALCODE_FROM BETWEEN v_input_low AND v_input_high).

This query will select the values between range specified in v_input_low and v_input_high.

Read only

Former Member
0 Likes
1,230

Hi,

Please try this:

select single transpzone from yoet_tpzone_map

into....

where country = <fs_country> and postal code between 'DA1 00A' and 'DA9 0ZZ'.

Regards

Purnand

Read only

Former Member
0 Likes
1,231

Dear Satyaranjan Mohanty,

if  your table have any other(apart form postalcode-from and postalcode-to) field for postalcode if it is then given logic may work

V_INPUT = DA2 0AA.


SELECT SINGLE TRANSPZONE

               FROM YOET_TPZONE_MAP

               INTO X_TPTZONE-TRANSPZONE

           WHERE COUNTRY = <FS_COUNTRY>

                  AND  POSTALCODE between 'DA1 00A' and 'DA9 0ZZ'.

if you don't have that extra field POSTALCODE then the code you are write is the right one only .

if you not get output, in that case you have to fetch data related to country specific first and then you have break postal code and compare character and numeric fields seperatly.

Read only

Former Member
0 Likes
1,230

Hi,

You can write a select query using LIKE statement

SELECT SINGLE transpzone FROM yoet_tpzone_map

                                 INTO x_tptzone-transpzone

                                 WHERE country = <fs_country> AND

                                                POSTALCODE LIKE 'DA%'.

Hope this helps.

Thanks,

Tooshar Bendale

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,230

Just read again your code, and try to understand the effect of coding

POSTALCODE_FROM LE v_input AND POSTALCODE_TO GE v_input

very (very) similar to

POSTALCODE_EQ  LE v_input

As already written, either define two parameter / fields for low and high values or define a RANGE / SELECT-OPTIONS.

Regards,

Raymond