Skip to Content
Author's profile photo Former Member

Trigger Process Chain by User

Hello BW folks,

Purpose:

The purpose of this document is to trigger a job by user through portal and open the SAP BW system and to show message to user in a pop-up window for the confirmation of job executed.

Pre-requisite:

Create a button in the Portal where user can access by using Javascript.

Requirement:

The requirement is the end user needs to execute the job through Portal which will trigger a process chain whenever they needs.

                       

                             Capture3333.PNG

When the user click on the button through Portal, the SAP system will open automatically which shows the message on the bottom of the screen which doesn’t seems good to the user as shown below.

                         Capture2.PNG

So we plan to show a pop-up message and send a mail to the user who triggers the process chain.

1.   

  1. Create a program Z_PC_RUN needs to be created which calls the Function Module ‘RSPC_CHAIN_START’ to trigger the process chain, show the pop-up message and send email notification to the user who triggers.

See the program in APPENDIX A.

Now the user is getting a pop-message as shown below.

                    Capture3.PNG

                                                                 

                   

                         Email notification to the user Inbox.

               Capture1.PNG

2.       2. Create another program attached to the end of the Process chain which sends an email notification of the successful completion of the Process Chain.

               See the program in APPENDIX B.

APPENDIX A

REPORT  z_pc_run.

DATA: objcont      LIKE solisti1 OCCURS 5 WITH HEADER LINE.

DATA: it_receivers TYPE TABLE OF somlreci1.

DATA: ls_receivers TYPE somlreci1.

DATA: doc_chng     LIKE sodocchgi1.

DATA: entries      LIKE sy-tabix.

DATA: name(15).

DATA: l_pc         TYPE rspc_chain.

l_pc = ‘XXXX’. – Process Chain Name

CALL FUNCTION ‘RSPC_CHAIN_START’

  EXPORTING

    i_chain             = l_pc

*   I_T_VARIABLES       =

*   I_SYNCHRONOUS       =

*   I_SIMULATE          =

    i_noplan            = ‘X’

*   I_DONT_WAIT         =

*   I_POLL              =

* IMPORTING

*   E_LOGID             =

          .

IF sy-subrc = 0.

Fill the document

  doc_chng-obj_name  = ‘Process Chain XXXX has been triggered. On Successful Completion, Email Notification will be sent to you’.

  doc_chng-obj_descr = ‘Process Chain XXXX has been triggered. On Successful Completion, Email Notification will be sent to you’.

  doc_chng-sensitivty = ‘P’.

  objcont = ‘Hi Receiver,’.

  APPEND objcont.

  objcont = ‘Process Chain XXXX has been triggered. On Successful Completion, Email Notification will be sent to you’.

  APPEND objcont.

  1. ELSE.

* Fill the document

  doc_chng-obj_name  = ‘Process Chain XXXX has been triggered. On Successful Completion, Email Notification will be sent to you’.

  doc_chng-obj_descr = ‘Process Chain XXXX has been triggered. On Successful Completion, Email Notification will be sent to you’.

  doc_chng-sensitivty = ‘P’.

  objcont = ‘Hi Receiver,’.

  APPEND objcont.

  objcont = ‘Process Chain XXXX has been triggered. On Successful Completion, Email Notification will be sent to you’.

  APPEND objcont.

  1. ENDIF.

DESCRIBE TABLE objcont LINES entries.

READ TABLE objcont INDEX entries.

doc_chng-doc_size = ( entries – 1 ) * 255 + STRLEN( objcont ).

Retrieve mail address

DATA: l_per TYPE ad_persnum.

DATA: l_add TYPE ad_addrnum.

DATA: l_mail TYPE adr6-smtp_addr.

SELECT SINGLE persnumber addrnumber FROM usr21 INTO (l_per , l_add) WHERE bname = sy-uname.

SELECT SINGLE smtp_addr FROM adr6 INTO l_mail WHERE persnumber = l_per AND addrnumber = l_add.

ls_receivers-receiver = l_mail.

ls_receivers-rec_type = ‘U’.

APPEND ls_receivers TO it_receivers.

WRITE:/05  ‘Process Chain has been Triggered.’.

WRITE:/05  ‘On Completion You will get Email Notification.’.

WRITE:/05  ‘Please Close Now this Window.’.

APPENDIX B

REPORT  z_pc_run_success.

DATA: objcont      LIKE solisti1 OCCURS 5 WITH HEADER LINE.

DATA: it_receivers TYPE TABLE OF somlreci1.

DATA: ls_receivers TYPE somlreci1.

DATA: doc_chng     LIKE sodocchgi1.

DATA: entries      LIKE sy-tabix.

DATA: e_state      TYPE rspc_state.

DATA: name(15),

      l_logid      TYPE rspc_logid.

DATA: l_pc         TYPE rspc_chain.

l_pc     = ‘XXXX’.

sy-batch = ‘X’.

DATA: l_t_logs     TYPE TABLE OF rspclogchain,

      l_s_logs     TYPE rspclogchain.

SELECT * FROM rspclogchain

       APPENDING TABLE l_t_logs

       WHERE chain_id = l_pc.

SORT l_t_logs BY datum zeit DESCENDING.

READ TABLE l_t_logs INTO l_s_logs INDEX 1.

IF l_s_logs-analyzed_status = ‘G’ AND sy-subrc = 0.    ” Successfully completed

Fill the document

  doc_chng-obj_name  = ‘XXX to YYY data load information’.

  doc_chng-obj_descr = ‘XXX to YYY data load information’.

  doc_chng-sensitivty = ‘P’.

  objcont = ‘Dear User,’.

  APPEND objcont.

  objcont = ‘XXX to YYY data load has been completed successfully.’.

  APPEND objcont.

  objcont = ”.

  APPEND objcont.

  objcont = ‘Regards’.

  APPEND objcont.

  1. ENDIF.

DESCRIBE TABLE objcont LINES entries.

READ TABLE objcont INDEX entries.

doc_chng-doc_size = ( entries – 1 ) * 255 + STRLEN( objcont ).

*Retrieve mail address

DATA: l_per TYPE ad_persnum.

DATA: l_add TYPE ad_addrnum.

DATA: l_mail TYPE adr6-smtp_addr.

SELECT SINGLE persnumber addrnumber FROM usr21 INTO (l_per , l_add) WHERE bname = sy-uname.

SELECT SINGLE smtp_addr FROM adr6 INTO l_mail WHERE persnumber = l_per AND addrnumber = l_add.

ls_receivers-receiver = l_mail.

ls_receivers-rec_type = ‘U’.

APPEND ls_receivers TO it_receivers.

* Send the document

CALL FUNCTION ‘SO_NEW_DOCUMENT_SEND_API1’

  EXPORTING

    document_type              = ‘RAW’

    document_data              = doc_chng

    put_in_outbox              = ‘X’

  TABLES

    object_content             = objcont

    receivers                  = it_receivers

  EXCEPTIONS

    too_many_receivers         = 1

    document_not_sent          = 2

    operation_no_authorization = 4

    OTHERS                     = 99.

COMMIT WORK.

SUBMIT rsconn01 WITH mode = ‘INT’ AND RETURN.

Thank you All….

Assigned Tags

      7 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Useful Document 🙂 🙂

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

      Thank you.....

      Author's profile photo Martin Grob
      Martin Grob

      thanks for sharing..nice info

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

      Thanks Martin..

      Author's profile photo abilash n
      abilash n

      Nice one Rajesh.

      Author's profile photo Harish Allachervu
      Harish Allachervu

      Informative nice job rajesh.

      Regards,

      Harish

      Author's profile photo Former Member
      Former Member

      Hi - have you considered using a button in a web template? There is a function that allows you to trigger a process chain.

      Cheers

      Henry