Skip to Content
Requirement: send an sms message for PM notification of a certain priority to a group of recipients.

 

Background: A technical team maintains equipment in fueling stations. Each malfunction is reported via the PM notification in R3. Certain malfunctions are of very high priority and must reach the attention of a group of employees apart from the actual technicians that handle the problem.

 

Solution: Use Sap business workflow to send SMS messages to recipients.

 

 

 

Details

 

The first question that comes to mind is why use WF and not the alert framework in order to send out the messages. That was the initial thought in the project but we encountered many problems in the alert framework especially when handling long text with many variables – a strong demand from the customer.

WF is perhaps a bit more demanding to set up, but is far more flexible and easier to change.

 

The WF built is as follows:

 

1. Triggering event is BUS2080.Created a WF start condition takes care of the task to start the WF only for the relevant notifications, according to their priority.

 

2. A background step reads the long text of the notification using a custom method based on the ‘read_text’ function module

 

3. A responsibility rule based on the notification priority is created. Different responsibilities are created for each priority, linked to employee records.

 

A background step based on ‘RH_GET_ACTORS’ function module reads the rule and stores the result in a multiline container element based on WFSYST-AGENT

 

4. A background step reads the employee cell number from infotype 105 in the employee master data. (This can also be utilized via attributes in the business object of the employee) We did this in a method that uses multiline parameters in order to be able and retrieve many cell numbers at once.

 

  

5. The SMS message is composed and sent in another background step based on a custom function module that is wrapped around the ‘SO_DOCUMENT_SEND_API1’  function module.

 

6. Messages are delivered to the outgoing message queue (Transaction SOST) and delivered via a periodical job.

 

This WF is completely handled in background, e.g. there is no user intervention and no one gets a work item in their inbox. However, the WF mechanism enabled us to deliver a flexible solution with a minimum effort and very little code writing. The only maintenance to be done is to maintain the assignment of persons to the responsibilities and the different notification priorities in the WF start conditions.

Using the WF capabilities we managed to compose complex texts for the messages and include many variables in them.

 

  

Samples of code for the function modules mentioned above

 

Read notification long text

 

BEGIN_METHOD READ_TEXT CHANGING CONTAINER.

 

data lines type tline occurs 0 with header line.

*data header type thead occurs 0 with header lines.

data name like THEAD-TDNAME.

 

move OBJECT-KEY to name.

 

  CALL FUNCTION ‘READ_TEXT’

    EXPORTING

      CLIENT = SY-MANDT

      ID = ‘LTXT’

      LANGUAGE = SY-LANGU

      NAME = name

      OBJECT = ‘QMEL’

      ARCHIVE_HANDLE = 0

      LOCAL_CAT = SPACE

*    IMPORTING

*      HEADER = HEADER

    TABLES

      LINES = LINES

    EXCEPTIONS

      ID = 01

      LANGUAGE = 02

      NAME = 03

      NOT_FOUND = 04

      OBJECT = 05

      REFERENCE_CHECK = 06

      WRONG_ACCESS_TO_ARCHIVE = 07

      OTHERS = 08.

 

 

SWC_SET_TABLE CONTAINER ‘lines’ LINES.

 

END_METHOD.

 

  

Reading the Rule result

 

BEGIN_METHOD GET_RULE_RESULT CHANGING CONTAINER.

 

Data: it_actor_tab like swhactor occurs 0 with header line.

swc_container role_container.                    “Define Container

 

SWC_GET_TABLE CONTAINER ‘role_container’ ROLE_CONTAINER.

 

  CALL FUNCTION ‘RH_GET_ACTORS’

    EXPORTING

      ACT_OBJECT = ‘AC90000002’

*      ACT_TASK =

*      ACT_WI_ID =

      ACT_PLVAR = ’01’

      SEARCH_DATE = SY-DATUM

*      ACTOR_CONTAINER_OO =

    TABLES

      ACTOR_CONTAINER = role_container

*      EXCLUDED_AGENTS =

      ACTOR_TAB = it_actor_tab

*      ERROR_TAB =

    EXCEPTIONS

      NO_ACTIVE_PLVAR = 01

      NO_ACTOR_FOUND = 02

      EXCEPTION_OF_ROLE_RAISED = 03

      NO_VALID_AGENT_DETERMINED = 04

      NO_CONTAINER = 05

      OTHERS = 06.

 

  CASE SY-SUBRC.

   WHEN 0.            ” OK

   WHEN 01.    ” to be implemented

   WHEN 02.    ” to be implemented

   WHEN 03.    ” to be implemented

   WHEN 04.    ” to be implemented

   WHEN 05.    ” to be implemented

   WHEN OTHERS.       ” to be implemented

  ENDCASE.

 

SWC_SET_TABLE CONTAINER ‘it_actor_tab’ IT_ACTOR_TAB.

 

END_METHOD.

 

 

  

Sending the SMS message

 

   CALL FUNCTION ‘SO_DOCUMENT_SEND_API1’

      EXPORTING

        document_data              = document_data

        put_in_outbox              = ‘X’

        sender_address             = sender_address

        sender_address_type        = ‘B’

        commit_work                = ‘X’

      TABLES

        packing_list               = packing_list

        contents_txt               = contents_txt

        receivers                  = receivers

      EXCEPTIONS

        too_many_receivers         = 1

        document_not_sent          = 2

        document_type_not_exist    = 3

        operation_no_authorization = 4

        parameter_error            = 5

        x_error                    = 6

        enqueue_error              = 7

        OTHERS                     = 8.

To report this post you need to login first.

17 Comments

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

  1. Srihari Hebbar
    We had to send sms notifications to a few recipients on particular business related errors during interface execution. We just decided to using the mail adapter in PI/XI to do the same.

    Receivers were stored in a custom table on the SAP system (Classified by error category and priority and interface type).

    (0) 
      1. rahul more
        Hi Ronen,
        I am new to ABAP so can you Please explain the method step by step.
        It will be very Helpfull to me.

        Thanks in advance.

        Rahul P. More

        (0) 
      1. sanjay khatri
        I am usign 4.7 Sr2 and I write abap code for the same ! sending SMs usign HTTP_client proxy which work on CI only ! for colelction as well as adfter invoiceing , Please Guide me how can i fo head in WF  Step by step so that I can do the same for Collection and Ivoice

        In case it possible

        sanjay

        (0) 
  2. Rahul Urs
    Great Blog !
    Just wondering or rather let me know if I am making sense
    Isnt SMS an old fashion technology considering everybody has a phone with EMAIL !!!
    SAPconnect configuration with workflow would satisfy the business logic of sending the message out to the concerned users. consider using the ALRTCATDEF t-code and integrating them to the Portal via UWL or using the email option.
    I hope that rings a bell ??
    (0) 
    1. Ronen Fox Post author
      Thanks !

      As for your comment: It does ring a bell, and sounds like a great technique, but… currently the involved users in the process do not have the option of receiving an email in their (simple and limited) cell phones, thus making the SMS option the better choice for us at the moment.

      Regards,
      Ronen

      (0) 
  3. Ashutosh Rastogi
    Nice Work !

    I was just wondering if there is some way where user send out an SMS and its text can be read in workflow (Text is sent in SMS in a pre decided format). And this text gets processed in Workflow for furthur steps ..

    Regards,
    Ashutosh

    (0) 
    1. Ronen Fox Post author
      Thanks for the comment !
      I’m not suer I understand what you mean, but in the way we got this WF set up, the SMS message is a simple workitem text and can be viewed and manipulated throughout the entire WF

      Best regards,
      Ronen

      (0) 
  4. Mistry Mohammedwasim N.
    Hi! Ronen,
    Nice Work!!
    After looking at your blog I got a hope that SMS can be sent from Workflow….

    But I have some queries for the same….
    -> Can you tell me how your Basis Configuration is done because there are two ways to do it as you might know about it, i.e. via HTTP Configuration or SMTP Configuration in SAPConnect?

    -> One more thing I was amaze to look that you are using SO_DOCUMENT_SEND_API1 Function Module for sending SMSs’. As I have searched and came to know that in 4.7D there is no Reciever Type ‘K’ (Pager/SMS) but it is available with ECC 6.0 Also, how you are passing the mobile no. in that function module probably in RECIEVERS table parameters.

    I would like if you can provide me with the code how u r passing the individual parameters to that function module….

    Hopefully, will be waiting for your response
    Thanks in Advance….

    Regards,
    Mistry Wasim

    (0) 
    1. Ronen Fox Post author
      Hello Wasim and thank you for your comment !

      The basis configuration for sending SMS is done via SCOT transaction using the HTTP configuration.

      Re: SO_DOCUMENT_SEND_API1 Function Module, we are on ECC 6, so I can’t realy tell you about this function in earlier releases. The mobile numbers are passed using the RECEIVERS table.

      Thanks,
      Ronen

      (0) 
    1. Ronen Fox Post author
      Hello Wasim,

      The way the number is transfered is as follows:

      RECEIVER  000      SMS 0505338790
      REC_TYPE  K

      I hope this helps.
      Thanks,
      Ronen

      (0) 
      1. rahul more
        Hi Ronen,
        I am new to ABAP so can you Please explain the method step by step.
        It will be very Helpfull to me.

        Thanks in advance.

        Rahul P. More

        (0) 

Leave a Reply