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: 

Internet with SAP

Former Member
0 Kudos
483

1.how to connect sap to internet.How to configure that?

parameters:pmail(100) lower case.

data:dummy(100).

data:http_client type ref to if_http_client.

data:w_string type string,

w_result type string,

r_str type string.

data:result_tab type table of string.

data:cl_http_client type ref to cl_abap_char_utilities.

start-of-selection.

clear w_string.

CONCATENATE

'http://www.webservicex.net/ValidateEmail.asmx/IsValidEmail?Email='

pmail

INTO

w_string .

CALL METHOD CL_HTTP_CLIENT=>CREATE_BY_URL

EXPORTING

URL = w_string

  • PROXY_HOST =

  • PROXY_SERVICE =

  • SSL_ID =

IMPORTING

CLIENT = http_client

  • EXCEPTIONS

  • ARGUMENT_NOT_FOUND = 1

  • PLUGIN_NOT_ACTIVE = 2

  • INTERNAL_ERROR = 3

  • others = 4

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL METHOD http_client->SEND

  • EXPORTING

  • TIMEOUT = CO_TIMEOUT_DEFAULT

  • EXCEPTIONS

  • HTTP_COMMUNICATION_FAILURE = 1

  • HTTP_INVALID_STATE = 2

  • HTTP_PROCESSING_FAILED = 3

  • HTTP_INVALID_TIMEOUT = 4

  • others = 5

.

IF SY-SUBRC <> 0.

The above program says a run time error

Exception condition "HTTP_COMMUNICATION_FAILURE" raised.

Note:I have netconnection in another OS ie XP

1 REPLY 1

former_member387317
Active Contributor
0 Kudos
47

Hi Gopi,

Internet connection should be on the current operating System on which you are running the program which contains the webservice you waana execute.

so first set up the internet connection in ur OS nd then execute the program..

For validating email address use below FM..

SX_INTERNET_ADDRESS_TO_NORMAL to validate the email address.

TYP ADDRESS

INT ====>ur emil addres ex . title@yahoo.com

Chk this solution from other thread

llen = strlen( lemail ).

do llen times.

lchr = lemail(1).

case lchr

when '@'.

lasterix = lasterix + 1.

when '.'

ldot = ldot + 1.

when others.

*checking for any wierd char apart from alphanumeric.

if lchr na sy-abcde and lchr na '0123456789'.

lerror = 'Y'.

exit.

endif.

endcase.

shift lemail.

enddo.

if ldot ne 2 or lasterix ne 1.

lerror = 'Y'.

endif.

============================

OR

check FMs

ISA_CONTACT_PERSON_FROM_EMAIL

================================

see the below code for reference..

REPORT zilesh.

DATA: http_client TYPE REF TO if_http_client .

DATA: wf_string TYPE string ,

result TYPE string ,

r_str TYPE string .

DATA: result_tab TYPE TABLE OF string.

SELECTION-SCREEN: BEGIN OF BLOCK a WITH FRAME .

PARAMETERS: pmail(100) LOWER CASE.

SELECTION-SCREEN: END OF BLOCK a .

START-OF-SELECTION .

CLEAR wf_string .

CONCATENATE

'http://www.webservicex.net/ValidateEmail.asmx/IsValidEmail?Email='

pmail

INTO

wf_string .

CALL METHOD cl_http_client=>create_by_url

EXPORTING

url = wf_string

IMPORTING

client = http_client

EXCEPTIONS

argument_not_found = 1

plugin_not_active = 2

internal_error = 3

OTHERS = 4.

CALL METHOD http_client->send

EXCEPTIONS

http_communication_failure = 1

http_invalid_state = 2.

CALL METHOD http_client->receive

EXCEPTIONS

http_communication_failure = 1

http_invalid_state = 2

http_processing_failed = 3.

CLEAR result .

result = http_client->response->get_cdata( ).

REFRESH result_tab .

SPLIT result AT cl_abap_char_utilities=>cr_lf INTO TABLE result_tab .

LOOP AT result_tab INTO r_str.

WRITE:/ r_str .

ENDLOOP .

[/code]

Hope it will solve your problem.

Reward points if useful...

Thanks & Regards

ilesh 24x7