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: 

check if URL is valid or not possible ?

Former Member
0 Kudos

hi,

is it somehow possible via function module or class/method to check if a given URL is valid ?

Problem is:

in MSS i display photos of employees from intranet-server of customer:

for example:http://www.intranetserver.com/Employees/12345678.jpg -> 12345678 stands for the personnell number.

Some employees don't have a photo, so the url can't be found as there is no photo on intranet-server. When put the URL into browser i get error 404 (page not found) back.

but  how can i check if this URL is valid inside abap-coding ? i have to do some other coding when  url does not exist, and i need this before.

br Martin

1 REPLY 1

larshp
Active Contributor
0 Kudos

try using cl_http_client, something like the following ABAP code should do the trick,

DATA: li_client TYPE REF TO if_http_client.

DATA: lv_code TYPE i.

cl_http_client=>create_by_url(

  EXPORTING

    url    = 'http://www.intranetserver.com/Employees/12345678.jpg'

  IMPORTING

    client = li_client ).

li_client->send( ).

li_client->receive( ).

li_client->response->get_status(

      IMPORTING

        code   = lv_code ).