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: 

IP Address Comparison

rahulvsaganeau
Explorer
0 Kudos

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.

1 REPLY 1

Former Member

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

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