Skip to Content
0

IP Address Comparison

Jan 12 at 10:08 AM

46

avatar image

Dear Members,

I am trying to compare IP address using below logic.The requirement is that i want to check if the system host IP is in between the IP range starting value is in loc_ip_from and end value is in loc_ip_to.

{

IF loc_ip_from LE system_host_ip

and

loc_ip_to ge system_host_ip.

Then I am Good.

ENDIF.

}

But the logic fails.

Example:-

loc_ip_from = 10.167.0.0

loc_ip_to = 10.167.255.255

and system_host_ip = 10.167.208.32 . this fails because of '32' is 2 digit figure.

It works if I make it 10.167.208.032 . because '032' is 3 digit

But if the system_host_ip = 10.167.208.132 this is pass because '132' is 3 digit.

Can you suggest me better logic in abap.

thanks.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

avatar image
Former Member Jan 12 at 10:35 AM
1

(a) normalize the IP address to format ###.###.###.### for your string comparison or

(b) convert the IP address into binary representation and do number comparison

Share
10 |10000 characters needed characters left characters exceeded