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

URL check

Former Member
0 Likes
3,974

Hey Experts,

i got a requirement where i have to check if an URL is available.

I alredy used

CL_GUI_FRONTEND_SERVICES=>EXECUTE

CL_GUI_FRONTEND_SERVICES=>FILE_EXIS

CL_GUI_CFW=>FLUSH

but without any success....

p.s. it is no problem to open the file, but to check if the URL is there...!

Any Idea?

Thanks,..

19 REPLIES 19
Read only

Former Member
0 Likes
3,593

This message was moderated.

Read only

Former Member
0 Likes
3,593

This message was moderated.

Read only

ThangaPrakash
Active Contributor
0 Likes
3,593

Hello Luis,

Use the class CL_HTTP_CLIENT to  create URL, SEND and receive the return code.based on the return code you can confirm on the URL existence. Check below links for reference.

http://scn.sap.com/thread/3213468

http://scn.sap.com/thread/1903058

Regards,

TP

Read only

Former Member
0 Likes
3,593

This message was moderated.

Read only

0 Likes
3,593

Hi Ankit,

i tryed it now.

But it dosent matter if i type www.google.de or www.googlekjdjsjkjdk.de

The one Url exists the other one not. But i all time get the same returncode.

dataclient      type ref to if_http_client,

          url       type string,

          returncode TYPE sy-subrc.

url = 'http://www.google.de'.





****Create the HTTP client

   call method cl_http_client=>create_by_url

     exporting

       url    = url

*      ssl_id = page_srv-ssl_id                         for https

     importing

       client = client

     exceptions

       others = 1.


sy-subrc = returncode.




****Make the call

   client->send( ).




call method client->receive

     exceptions

       http_communication_failure = 1

       http_invalid_state         = 2

       http_processing_failed     = 3

       others                     = 4.

write:/ returncode, sy-subrc.

Read only

0 Likes
3,593

Hi Luis,

You are almost there. The returncode value is coming as 0 in both cases but sy-subrc comes as 1 in case URL is wrong.

You can use sy-subrc value and proceed.

BR.

Read only

0 Likes
3,593

Sorry? I dont understand what you mean.... 🙂

My returncode here

call method cl_http_client=>create_by_ur

is always 0.

And my returncode here

call method client->receive

is always 1.

If i put a wrong or a right url, all the same...

What do you mean with ''You can use sy-subrc value and proceed''?.

Read only

0 Likes
3,593

Hi Luis,

Using wrong URL like -  url = 'http://www.googleq1.com'.

Output is -

and using correct URL like  url = 'http://www.google.com'.

Output is -

Since Sy-subrc value is changing you can use the same in further logic.

BR.

Read only

0 Likes
3,593

I am Sorry, but not with my Code. But it is exact the same as yours.

Maybe the Problem is somewhere als, like the Browser or javascript?

Read only

0 Likes
3,593

Maybe i have to change something in the Gui Options?

Read only

0 Likes
3,593

Hello Luis,

Did you refer to the links which I have provided where Thomas has explained it clearly.

Regards,

TP

Read only

0 Likes
3,593

This message was moderated.

Read only

0 Likes
3,593

Yes, i took his Code.

He also was writing thet WebAS 610 and higher is needed.

Whrere can i proof if i got this level of WebAS?

Read only

0 Likes
3,593

Hi,

i created a RFC. But thats not the Problem.

So i dont know what to try next...

Any Idea?

Read only

0 Likes
3,593

Hi Luis,

I am short of reasons, wait for other mentors to answer.

BR.

Read only

Former Member
0 Likes
3,593

Maybe the problem is solved with transaction SMICM?

Read only

0 Likes
3,593

This message was moderated.

Read only

0 Likes
3,593

To your Code:

Sorry, but i get this when i test with a right URL ore wrong. No Diffrence.

To cl_http_client:

I alredy work with this CL.

I think the problem is the interface between http and SAP.

Thanks

Read only

Former Member
0 Likes
3,593

Ok, now i got an answer of an sap basis administrator.

Oure SAP System does not allow URL Requests.

So I have to work with an Method where i give the IP, Port and URL with.

Is there a Method for this requirements?