Skip to Content
Author's profile photo Former Member

Sending SMS to the Customer on Delivery Order using 3rd party API!

Sending SMS to the Customer on Delivery Order using 3rd party Application Program Interface.

I’m sure many of us came across the similar requirement where there’s a need to send SMS or Email to the customers through integration with ERP system. Since we’ve implemented SMS sending through HTTP with 3rd party API server so thought of sharing a document which I believe will explain well how to follow major procedure by using Standard SAP configuration for SMS generation.

BUSSINESS REQUIREMENT:


There was a business requirement to send an SMS to the Customer on the creation of Delivery Order in SD Sale Process. Reason behind this was that Customers should be aware as how much Qty. of which product has been dispatched from the warehouse to them which we’ve catered in SAP by using 3rd party API server. Moreover, Email functionality has also been implemented in order to intimate about delivery orders creation to our Branch Managers, Accountants and Warehouse In-charges.

LOGIC:

We have implemented automatic SMS generating functionality on transactions VL01N (Delivery Order Creation at the time of PGI) and VL09 (Delivery Order Reversal) where system will initiate SMS via ABAP Program for the customer against their cell numbers which have been maintained in Customer Master record. Before this we’ve re-verified Customer Master Record (maintenance of Mobile No. under General Data Tab in Mobile Phone Text Box i.e. TELF2 field in CMR) for all the Customers which will be picked by KNA1 Table against LIKP-KUNNR.

We’ve defined a Z* table in order to pass necessary Parameters for SMS sending after getting the response data (i.e. URL building through HTTP request) via class method like KUNNR, TELF2, MESSAGE TEXT, SENT FLAG, ERDAT and TIME against which we’ll receive back response from 3rd party API server.

SMS content.png

After retrieving the HTTP response by utilizing 3rd party API we will update the Z* table accordingly by setting SENT flag to ‘X‘ if API’s server back response is successful. In case SMS hasn’t been sent from DB due to any reason system will retry sending it via background job and it will send all the SMS that have been pending in a queue.

Message Text has been defined based on Movement Type logic as if there’s a Stock Out from Inventory system will send Dispatch SMS to the Customer. If it’s Return, it will give the intimation that Stock has been Returned to warehouse. In case of Delivery Order Reversal, system will send an SMS to the Customer that Delivery Order has been cancelled due to ___ Reason. Attaching snapshots for better understanding which shows the Message Content that have been delivered to the customer.

return msg.png

cancelled text.png

SMS:


We’ve implemented the coding in BADI LE_SHP_DELIVERY_PROC at method IF_EX_LE_SHP_DELIVERY_PROC~SAVE_AND_PUBLISH_BEFORE_OUTPUT via class method

1st we need to build the URL string based on the input parameters (A valid account ID of 3rd party server, Text Msg, SMS masking, Language, Valid mobile number to whom you want to send SMS number and valid password to request API) that will be dynamically created (SMS TEXT) and (MOBILE NUM).

3rd Party Mobile Number will be maintained after building the URL via HTTP request from Z* Table after which we’ll pass this corresponding field to our Internal Table and concatenate the URL as mentioned below.

/wp-content/uploads/2013/10/1_306607.png

After the URL creation, we will prepare HTTP Client request to 3rd party’s API server using the classes.

1. IF_HTTP_CLIENT OBJECT CREATION

/wp-content/uploads/2013/10/2_306650.png

This class CL_HTTP_CLIENT is used to call a Web Service which will generate the Request Data and Post the Returned Data as a result of which the request will be converted to a HTTP Data Stream.

2. SENDING REQUEST

/wp-content/uploads/2013/10/3_306651.png

The system will use this Header Field to submit a Request to 3rd party’s API server after which we’ll receive the Response transmitted back to our Application Server.

3. RETRIEVE THE RESULT

/wp-content/uploads/2013/10/4_306652.png

This call method HTTP_CLIENT->RECEIVE will be used to get the Response back from the API server however there’s a need to make sure as if HTTP Requests are going fine through a proxy server and after that they should have been set on your Application Server for e.g. If Message Sending is Successful or Unsuccessful due to Incomplete or Missing Parameters, Account Expiry, Invalid API Password, Special Characters in SMS etc.

/wp-content/uploads/2013/10/6_306665.png

Finally we need to get the Response data in STRING format from and we need to make sure that String type should be as CHAR.


EMAIL:


In order to send email to our Branch Managers, Accountants and Warehouse In-charges we’ve created a separate Z* table in which every Branch Common Email Address Group has been maintained based on the Sales District. After appending the desired Parameters like Mail Group etc. We’ve used a call function CALL FUNCTION ‘SO_DOCUMENT_SEND_API1’ in order to send Email to an External Email Addresses. Also, we need to make sure that Address Declarations should be correct.

/wp-content/uploads/2013/10/11_306666.png

SMTP NODE CONFIGURATION:

SMTP node is necessary to send Mails to an External Mail System. From the Settings Menu you need to Define Domain, just type your Company’s Email Domain.

10-24-2013 3-47-55 PM.png

The SAP system will transfer the Outbound Mails to a Single Mail Server where we can set its Host Address and Mail Port Number.

10-24-2013 3-49-08 PM.png

In Mail host field name we will write an SMTP (outgoing mail) address and in the Mail port field we need to give the correct port which will be used to connect to an SMTP server.


Under Supported address types option, click on Set button next to the Internet check-box. Here give an address area as * as that will be used for a routing decision.

/wp-content/uploads/2013/10/14_306669.png

MONITORING IN SOST:

We can Monitor and view the Status of Outgoing Emails sent from SAP depending upon the selection criteria given in order to execute. This Transaction displays the relevant Send Status for all the Send Requests. Status String displays number of Send Requests, Warning, Waiting, Errors etc.

/wp-content/uploads/2013/10/15_306670.png

Send Method in our case is via Internet, Document Title will display complete details about the send request. Sender/Recipient will show the detailing about the Sender or Recipient. Send Date/Send Time will be the Date and Time at which the User sent the Message. Msg will show the Current Status Code of the Send Request. If Status is Green that means Email has been delivered. Also, you can view the Message Contents by going to the Display Document Option in Send Request Menu.

/wp-content/uploads/2013/10/17_306671.png

This step by step Document will be helpful from Functional and Technical perspective as I’ve tried my best to cover every possible Scenario one can encounter via doing this development. Please post your valuable comments if you feel that it’s worthwhile. Thanks

Assigned Tags

      42 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo BOJJA SIVASANKAR REDDY
      BOJJA SIVASANKAR REDDY

      hi

      nice document  and nice presentation keep it up

      regards

      sankar

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thank you for the 1st comment BOJJA SIVASANKAR REDDY 🙂

      Author's profile photo ' MoazzaM '
      ' MoazzaM '

      Nicely explained and presented. Thanks for sharing this.

      Thank$

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thank you ' MoazzaM ' for the words and time that you've given in reading this document.

      Author's profile photo Shiva Vasireddy
      Shiva Vasireddy

      Thanks for sharing.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Pleasure to share Siva Vasireddy and I'm sure it will be helpful.

      Author's profile photo Srinu S
      Srinu S

      Hi Amarrah,

      Very useful document shared, nicely explained. thanks for sharing.

      thanks,

      Srinu.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thank you dear, glad to know that its helpful and worth reading.

      Author's profile photo Deep K
      Deep K

      Hi Ammarah,

      Thank you very very muchhh for sharing document, we got same requirement for our client with billing number, this document will be very useful.

      Thanks & regards

      Deep

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thank you Deep K and feel free to discuss in case you need any further help in this regard.

      Author's profile photo Virinchy P
      Virinchy P

      Very useful Blog...

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thank you for the appreciation viru p 🙂

      Author's profile photo venu gopal
      venu gopal

      Hai   * Ammarah *

      Very useful document and nice explained ..but small doubt but where we maintain Phone no ?

      Thanks a lot .. 🙂

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Good day venu gopal. Are you talking about 3rd party Mobile Number or Customer one? If it's for Customer (KUNNR) then you will maintain the same in CMR (Customer Master Record) under General Data Tab in Mobile Phone (TELF2) field which will be picked by KNA1 Table against LIKP-KUNNR. If you're talking about 3rd party mobile number maintenance then after building the URL via HTTP request from Z* Table we'll pass this corresponding field to our Internal Table and concatenate the URL as mentioned in the 4th snapshot of the document. Hope i've made myself clear 🙂 . Feel free to ask in case you want to know more. Thanks.

      Author's profile photo Suhaib Bin Aziz
      Suhaib Bin Aziz

      It's very imformative document and very effectively explained, actually i was looking for the same requirement for my business process from couple of days but could'nt find anything like this over SCN... bundle of thanks foh sharing this! 🙂 I really appriciate your work & i hope you will cotinue sharing your creative work with us... Thanks!

      BG,

      Suhaib Bin Aziz

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thank you Suhaib Bin Aziz, i'm so overwhelmed by your kind words 🙂

      Author's profile photo Former Member
      Former Member

      Thank you for sharing Ammarah 🙂 . Many customers require to send SMS alerts for various activities.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Yep Karuna Ravuri thats the reason of sharing this document over SCN and i'm sure it will be helpful for many of us.

      Author's profile photo Former Member
      Former Member

      Congrats Ammarah....Nice Document

      Keep it up...... 🙂

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      pankaj labhasetwar thank you so much.

      Author's profile photo SUNIL PILLAI
      SUNIL PILLAI

      Thanks  * Ammarah * for sharing this document.

      Regards,

      Sunil

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      SUNIL PILLAI, thanks for appreciating.

      Author's profile photo Former Member
      Former Member

      Hi Ammarah,

      Great job.

      Nicely explained and presented.

      Thanks for sharing this.

      Kind regards,

      Khushi

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thank you Khushi Mughal.

      Author's profile photo Suman Sardar
      Suman Sardar

      Good document.Keep sharing.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Suman Sardar.

      Author's profile photo Former Member
      Former Member

      Thanks for sharing this document..

      Regards,

      Kris.

      Author's profile photo Former Member
      Former Member
      Blog Post Author
      Author's profile photo Jignesh Mehta
      Jignesh Mehta

      Thank you * Ammarah * for writing this doucment.

      It is very informative & well structured.

      Thanks,

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thank you sir, good to see your comments on the same.

      Author's profile photo Jorge Weiss
      Jorge Weiss

      Thanks a lot.

      Very good useful writing document.

      /Weiss

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thank you Jorge Weiss

      Author's profile photo Anandkumar KS
      Anandkumar KS

      Dear Ammarah,

      Very nice presentation and helpful to me for my business requirement.

      Thanks a tonne for uploading such a challenging one.

      Anand Kumar KS

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      It feels good to hear Anandkumar KS that it's useful for you. Also, feel free to discuss in case you need any further assistance regarding the same. Thanks.

      Author's profile photo Anandkumar KS
      Anandkumar KS

      Definitely, i will get back to you for my requirement.

      Anand Kumar KS

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Sure pleasure anytime.

      Author's profile photo Rakesh S
      Rakesh S

      Good document.thanks for sharing 🙂

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Rakesh S 🙂

      Author's profile photo Former Member
      Former Member

      once again useful info 🙂 keep posting.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thank you very much for your comments 🙂

      Author's profile photo Former Member
      Former Member

      It is Great Job.. I like this document verymuch

      Author's profile photo Vishal Hingole
      Vishal Hingole

      Thanks for great information.