Skip to Content
Author's profile photo Durairaj Athavan Raja

Send SMS to India from ABAP

Recently i cam across a webservice (available for free at http://www.webservicex.net/WS/WSDetails.aspx?CATID=4&WSID=59) which can send SMS to select GSM network phones in India. Just wanted to let the community know and get benefited from the same.

WSDL for this webservice is available at http://www.webservicex.net/SendSMS.asmx?WSDL

This webservice covers the following networks in India – Airtel, Idea Cellular, Skycell , RPG Cellular, Hutch, Celforce / Fascel, BPL Mobile, Escotel.

If you are on WAS6.4

Follow the steps explained in the weblog titled BSP a Developer’s Journal Part XIV – Consuming WebServices with ABAP by  Thomas Jung  (follow the method described under the subheading ‘Release 640‘) to create the client proxy and the program to execute the proxy to consume the webservice. Thomas has explained it well with screen shots on how to create the client proxy and also given a sample program to consume the same, and i don’t feel a need to re-explain the same here.

If you are on WAS6.20

Create a report program from se38 and copy/paste the code below.

REPORT y_sms_to_india620.
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: 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://www.webservicex.net/SendSMS.asmx/SendSMSToIndia?MobileNumber=
 m_no
 ‘&FromEmailAddress=’
 mail
‘&Message=’
 m_mss
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 .

 

I tried this from Saudi Arabia to a BPL mobile at Trichy/India and it works!

Assigned Tags

      44 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member
      Great job! Here we actually have an SMS gateway but for some companies this is not feasible and so alternatives like this can prove to be invaluable!!

      Excellent job!

      Author's profile photo Former Member
      Former Member
      Hi,
      It really works!
      Thank you.

      Nagarjuna.

      Author's profile photo Former Member
      Former Member
      Hi,
      How is it working for you now? Can you explain, where you went wrong before?Bcoz i got response in HTTP Client prog but i did not receive msg in my mobile.
      Thanks
      Author's profile photo Former Member
      Former Member
      Hello sir,
                   i tried the code  given by m.r athavan raja but i din't get any positive results kindly send me the document of sending  sms via abap code
      Author's profile photo Former Member
      Former Member
      kindly send me the document
      Author's profile photo Former Member
      Former Member
      This service is not working for the series 9866xxxxxx, Airtel numbers.
      🙁

      Nagarjuna

      Author's profile photo Former Member
      Former Member
      Hi,
      Iam doing HTML->Webservice scenario and am using HTTP Client prog for sending request.
      In my HTTP Client prog I got the response, the same response should be recived by my mobile as SMS, but it did not happen? What else needs to be done?
      Thanks a lot
      Author's profile photo Durairaj Athavan Raja
      Durairaj Athavan Raja
      Blog Post Author
      you are sending SMS from ABAP program, so the ABAP program will get the status message, if you want your mobile to receive the status message, use the same logic to send the status message to your mobile from the ABAP.

      Regards
      Raja

      Author's profile photo Former Member
      Former Member
      Hi Durairaj,
              I tried using the Web Service in ECC 6.0 with Web Dynpro ABAP as front end to get the inputs. When I execute the service I get the result as Message Sent Successfully for BPL Mobile Number but the SMS doesn't reach the recepient. Could help me with troubleshooting this problem?

      Regards,
      Supriya.

      Author's profile photo Former Member
      Former Member
      Hello Sir,
            this weblog is really helpful for me for understanding about consuming web services from abap. I am trying to execute the sample program given by you but received above exception in method http_client->receive. Please guide me and let me know if I am missing any required configuration.
            Thank you.  
      Author's profile photo Durairaj Athavan Raja
      Durairaj Athavan Raja
      Blog Post Author
      do you connect to internet via proxy? then you need to either code code the proxy authentication in the program or maintaint it at system level (SICF->Client=>Proxy Settings)

      Regards
      Raja

      Author's profile photo Former Member
      Former Member

      Hi Raja,

      Author's profile photo Durairaj Athavan Raja
      Durairaj Athavan Raja
      Blog Post Author
      Looks like there is a problem with the webservice. This has nothing to do with the program.
      Author's profile photo Former Member
      Former Member
      Thank you very much for this blog. It was very useful for one of my projects.
      Author's profile photo Pritam Kunal
      Pritam Kunal
      Hi
      I have tried doing code as you have mentioned. but i am still not able to configure the font size and all that you have mentioned. could you please tell me how to configure that? and where it need to configure it to.

      I have seen many replies that they are saying the code is working but i am not able to do so.

      Please help me for the same.

      Thanks in advance
      Pritam

      Author's profile photo Durairaj Athavan Raja
      Durairaj Athavan Raja
      Blog Post Author
      but i am still not able to configure the font size and all that you have mentioned

      That was due to some formatting issue , which has been fixed now.

      Author's profile photo Pritam Kunal
      Pritam Kunal
      That means if i will copy the code and execute it, it should work?
      Author's profile photo Durairaj Athavan Raja
      Durairaj Athavan Raja
      Blog Post Author
      Yes. provided ICF is configured in your system
      Author's profile photo Pritam Kunal
      Pritam Kunal
      I am sorry but i don't have any idea about ICF. What it is and how do i configure it in SAP system?

      Thanks
      Pritam

      Author's profile photo Former Member
      Former Member

      Dear Sir,Vishal

      Author's profile photo Former Member
      Former Member
      When U recd this mesage it meand There is problem in URL or website which U r usign for sending SMS
      Author's profile photo Former Member
      Former Member
      hello sir,
            i used the same code but i'm not getting error message but the message is not reaching the target phone as well.

      Could you please let me know what exactly i need to do here ?

      Thanks & regards,
      JOmy

      Author's profile photo Former Member
      Former Member
      I'm also having the Same Problem that Vishal is Having.Whether I have to do any Additional Configurations ?

      Please Help me in this.

      Thanks & Regards.

      Author's profile photo Former Member
      Former Member
      Hi Sir Im not getting aout put
      Author's profile photo Former Member
      Former Member

      <br/>Hi iam Getting like This When i Execute The Program can u please solve my problem<br/><br/><br/><br/><html><head><title>Application Server Error</title><br/><style type="text/css"><br/>body { font-family: arial, sans-serif;}<br/></style><br/></head><br/><BODY text="#172972" link="#808080" vlink="#808080"<br/>alink="#8e236b" bgcolor=white  leftmargin="0" topmargin="0"<br/>marginheight="0" marginwidth="0"><br/><table height="61" width="100%" border="0" cellspacing="0"<br/>cellpadding="0"><tr><td background="http://mytecsap02.mytecsoft.com:8001/sap/public/icman/img/bluebar_tile.gif"<br/>height="30"><table> <tr> <td width=5></td> <td width=20% nowrap><font face=arial size="-1" color=white>SAP Web Application Server<br/></font></td><td width=75% align="right" nowrap><font face=arial<br/>size="-1" color="white">Help

      !http://mytecsap02.mytecsoft.com:8001/sap/public/icman/img/theme.jpg|height=61|alt=SAP|width=122|src=http://mytecsap02.mytecsoft.com:8001/sap/public/icman/img/theme.jpg|border=0!
       

      404 Resource not found

      Partner not reached


      Error: -20
      Version: 7000
      Component: ICM
      Date/Time: Mon Sep 15 16:57:00 2008#
      Module: icxxconn.c
      Line: 2314
      Server: mytecsap02_IDS_01
      Error Tag: {00027a4e}
      Detail: Connection request from (26/1696/5) to host: proxy, service: 8080 failed (NIEHOST_UNKNOWN)#RM-T26, U1696, 800 DEVELOPER, mytecdtp018, 16:56:56, M5, W7, SE
      © 2001-2005, SAP AG

      </FONT><br/></td></tr></table><br/></body></html><br/><br/><br/>

      Author's profile photo Former Member
      Former Member
      Raja,
      It required & work on Centerl instance only,I confirgured HTTP NODe in SCOT and test sms is going , How can I using this program ? So that RFC which I crated work usign HTTP NODe and I can Monitor using T-code sost,

      Pl.Help

      Author's profile photo Former Member
      Former Member
      Hi Experts
      I tried the same code,but i am also getting the same error as others mentioned in the blog.Pls guide me as to what extra configurations have to be made to send an sms.
      Author's profile photo Former Member
      Former Member
      Thank A lot for this code , It work perfectly need only little bit adding of Code,
      this program workin won Cental instance only where in background mode, where as I would like run on any aplication server for that I create RFC for desired URL and also configured HTTP node.

      it is workign with HTTP client proxy setting which direct connection from program and URL

      I need help how can we attach this program with HTTP node sothat we can monitor through SOST.

      sanjay

      Author's profile photo Former Member
      Former Member

      Hi Sir,Help

      !http://shaktidev:8000/sap/public/icman/img/theme.jpg|height=61|alt=SAP|width=122|src=http://shaktidev:8000/sap/public/icman/img/theme.jpg|border=0!
       

      404 Resource not found

      Partner not reached


      Error: -20
      Version: 7000
      Component: ICM
      Date/Time: Mon Oct 06 13:36:34 2008#
      Module: icxxconn.c
      Line: 2321
      Server: shaktidev_SPD_00
      Error Tag: {00012467}
      Detail: Connection request from (33/758/0) to host: www.webservicex.net, service: 80 failed (NIEHOST_UNKNOWN
      © 2001-2005, SAP AG

      </FONT><br/></td></tr></table><br/></body></html><br/><br/><br/><br/>Thnaks in advance<br/>

      Author's profile photo Former Member
      Former Member
      Hi i am alos facing the same error how did u resolved it and why this error occurs
      Author's profile photo Former Member
      Former Member
      good contribution
      Author's profile photo Former Member
      Former Member

      <?xml version="1.0" encoding="utf-8"?><br/><SMSResult xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.webserviceX.NE<br/>  <FromEmailAddress>chandrababu.g@wentregue.com</FromEmailAddress><br/>  <MobileNumber>919243444741</MobileNumber><br/>  <Provider>Not Covered</Provider><br/>  <State>Not Covered</State><br/>  <Status>Not Covered</Status><br/></SMSResult>

      Author's profile photo Former Member
      Former Member

      Hi,

      Author's profile photo Durairaj Athavan Raja
      Durairaj Athavan Raja
      Blog Post Author
      the return message tell you all

      Not CoveredNot Covered
      Not Covered
      Author's profile photo Former Member
      Former Member
      Hello Durai,
            Could you please let me know what i need to do since the message is not reaching to the Mobile even though i got Message Sent successfully message ?
      Author's profile photo Durairaj Athavan Raja
      Durairaj Athavan Raja
      Blog Post Author
      What is the response you are getting
      Author's profile photo Former Member
      Former Member

      hello Durai,Jomy

      Author's profile photo Durairaj Athavan Raja
      Durairaj Athavan Raja
      Blog Post Author
      If this is what you get and the message still doesnt reach we cannot do much about it. May be the webservice is not working anymore.
      Author's profile photo Former Member
      Former Member
      Hello Durai, 
            Do you have any other way for example, any other Webservice or other method by which i can send SMS from a ABAP program ?

      Thanks & regards,
      Jomy

      Author's profile photo Durairaj Athavan Raja
      Durairaj Athavan Raja
      Blog Post Author
      go this page and try it from there.

      http://www.webservicex.net/WS/WSDetails.aspx?CATID=4&WSID=59

      does it work here and not work from your ABAP

      Author's profile photo Sai Krishna
      Sai Krishna

      i'm getting the response of application error give the possible ways to overcome this issue if u figured it .but i deeply appriciate u on ur fantastic work dude  i'm pasting the screen i got on ur exceution of ur program go through that and check out to avoid to get sucessfully to transmitt my message to the mobile from abap<br/><br/><br/>&----


      &
      <br/><br/><br/><br/><html><head><title>Application Server Error</title>     <br/><style type="text/css"><br/>body  font-family: arial, sans-serif;<br/></style><br/></head><br/><BODY text="#172972" link="#808080" vlink="#808080"<br/>alink="#8e236b" bgcolor=white  leftmargin="0" topmargin="0"<br/>marginheight="0" marginwidth="0"><br/><table height="61" width="100%" border="0" cellspacing="0"<br/>cellpadding="0"><tr><td background="http://mytecsap02.mytecsoft.com:8010/sap/public/icman/img/bluebar_tile.gif"<br/>height="30"><table> <tr> <td width=5></td> <td width=20% nowrap><font face=arial size="-1" color=white>SAP Web Application Server<br/></font></td><td width=75% align="right" nowrap><font face=arial<br/>size="-1" color="white">Help

      !http://mytecsap02.mytecsoft.com:8010/sap/public/icman/img/theme.jpg|height=61|alt=SAP|width=122|src=http://mytecsap02.mytecsoft.com:8010/sap/public/icman/img/theme.jpg|border=0!
       

      404 Resource not found

      Partner not reached


      Error: -20
      Version: 7000
      Component: ICM
      Date/Time: Fri Jul 09 15:53:45 2010
      Module: icxxconn.c
      Line: 2321
      Server: mytecsap02_IDS_10
      Error Tag: 00017adb
      Detail: Connection request from (18/2855/0) to host: proxy, service: 8080 failed (NIEHOST_UNKNOWN)
      RM-T18, U2855, 800 DEVELOPER, mytecdtp014, 15:53:39, M0, W5, SEU_, 3/2

      © 2001-2005, SAP AG

      </FONT><br/></td></tr></table><br/></body></html><br/><br/><br/>

      Author's profile photo Former Member
      Former Member
      i am using the sms from sap to send sms .
      while using sms some time it give error
      like this

      (1) the specified serial port is not avalable

      (2)

      can some one tell me why it is coming

      Author's profile photo Aditya Niyogi
      Aditya Niyogi
      Hi Guys,

      This was a great article and it helped me configure the SMS settings for my client.
      I was facing the NIEHOST_UNKNOWN error for a long time and there was no solution from our BASIS team. Further analysis revealed that the DNS settings were not proper.
      A few things that can be done in this case :
      (1)Check the DNS settings of the server
      (2)Try to put the IP address of the service instead of www.domain.com name. This will solve 90% of the problems
      (3)Check the HTTP ICF settings and see if the port is working using netstat(AIX) command.

      Hope this helps others as I had to dig deep to find the solution.
      Thanks,
      Aditya

      Author's profile photo Gokulan Natarajan
      Gokulan Natarajan

      Hi Durairaj,

      Your code really helped me to send sms well. But my requirement exceeds message length. Can we increase message length.

      Regards,

      Gokulan N