SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Sending SMS notification via business workflow



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SAP Business Workflow
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sun Dec 16, 2007 1:05 am    Post subject: Sending SMS notification via business workflow Reply with quote

Author: Ronen Fox

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

Code:
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

Code:
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

Code:
   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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SAP Business Workflow All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.