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

To report this post you need to login first.

42 Comments

You must be Logged on to comment or reply to a post.

  1. 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

    (0) 
    1. * Ammarah * (Away) 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 LIKPKUNNR. 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.

      (0) 
  2. 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

    (0) 
  3. 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

    (0) 

Leave a Reply