Skip to Content

Sending SMS from coding

Dear SDNers,

I worte the below code to send an sms.

REPORT  zsend_sms.
DATA: W_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: mail(100) LOWER CASE,
            m_no(20) LOWER CASE ,
            m_mss(120) LOWER CASE.
SELECTION-SCREEN: END OF BLOCK a .

START-OF-SELECTION .

  CLEAR wf_string .
  CONCATENATE  'http://102.175.33.18:4567/pushurl/?user=abapuser&pwd=abap123&src=045670&dest='m_no'&msg='m_mss
 INTO wf_string .

  CALL METHOD cl_http_client=>create_by_url
    EXPORTING
      url                = wf_string
    IMPORTING
      client             = W_http_client
    EXCEPTIONS
      argument_not_found = 1
      plugin_not_active  = 2
      internal_error     = 3
      OTHERS             = 4.
******************************************************************
DATA: EMPTYBUFFER TYPE XSTRING.

      EMPTYBUFFER = ''.
  CALL METHOD W_HTTP_CLIENT->REQUEST->SET_DATA
        EXPORTING DATA = EMPTYBUFFER.


CALL METHOD W_HTTP_CLIENT->AUTHENTICATE
  EXPORTING
    USERNAME             = 'abapuser'
    PASSWORD             = 'abap123'.
    "LANGUAGE             = SY-LANGU

CALL METHOD W_HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
     EXPORTING NAME  = '~request_method'
               VALUE = 'GET'
                .

 CALL METHOD W_HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
      EXPORTING NAME  = 'Content-Type'
                VALUE = 'text/xml; charset=utf-8'.

 CALL METHOD W_HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
      EXPORTING NAME  = 'Accept'
                VALUE = 'text/xml, text/html'.
data:SOAP_ACTION TYPE STRING.
 CONCATENATE wf_string '#' INTO SOAP_ACTION.
 CALL METHOD W_HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
      EXPORTING NAME  = 'SOAPAction'
                VALUE = SOAP_ACTION.

************************************************************************
  CALL METHOD W_http_client->send
    EXCEPTIONS
      http_communication_failure = 1
      http_invalid_state         = 2.

  CALL METHOD W_http_client->receive
    EXCEPTIONS
      http_communication_failure = 1
      http_invalid_state         = 2
      http_processing_failed     = 3.


****************************************************************************
DATA: HTTP_STATUS_CODE TYPE I,
      STATUS_TEXT TYPE STRING.
CALL METHOD W_HTTP_CLIENT->RESPONSE->GET_STATUS
    IMPORTING
      CODE = HTTP_STATUS_CODE
      REASON = STATUS_TEXT
      .
  WRITE: / 'HTTP_STATUS_CODE = ',
          HTTP_STATUS_CODE,
         / 'STATUS_TEXT = ',
         STATUS_TEXT
         .
DATA:W_RESULT TYPE STRING.
"STEP-6 :  READ RESPONSE DATA
 CALL METHOD W_HTTP_CLIENT->RESPONSE->GET_CDATA
        RECEIVING DATA = W_RESULT .

****************************************************************************

I am getting below response.

HTTP_STATUS_CODE = 404

STATUS_TEXT = conn failed

But If i use the above url in a browser, I m succeeded. Only from SAP its not working. Kindly put some light on this.

Thanks,

Venkat

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2011 at 06:46 AM

    Hi

    <Link removed by moderator>

    Thanks & regards,

    Edited by: Vinod Kumar on Nov 30, 2011 12:17 PM

    Add a comment
    10|10000 characters needed characters exceeded

    • Dear Khush,

      Here is the error.

      Application Server Error

      404 Resource Not Found

      Partner not Reached

      But if I try the same url with broswer,its working fine.

      Regaards,

      Venkat

      Thanks to everyone, after opeining the ports, the above code is working fine for me. I m closing this thread.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.