Triggering Workflow Using Business Transaction Events (BTE)

9
Triggering Workflow using Business Transaction Events (BTE) What are Business Transaction Events? The enhancement technique (Open FI) that were developed for Financial Accounting Component. Open FI is based upon the following principles: o Application developers must define their interface in a function module, an assignment table is read in the accompanying code and the customer modules assigned are called dynamically. This can be easily adopted / customized to the business needs wherein SAP does not provide the standard functionality through customization or enhancements. This functionality is primarily used in FI in the areas of dunning, credit management, banking etc. For Example: Standard Dunning functionality in SAP sends the notice to the Pay to partner function (based on the partner functions in SD module i.e. pay to hits the books in Accounts Receivable in FI module), whereas the requirement could be to send the same to Bill to party, based on the premise that the original invoice was sent to him as per the partner functions in SD. Basic steps in configuring the Business Transaction Events : Company A would like to fill the Assignment field with custom value ‘Demo BTE’ when an accounting document is posted for a certain Company Code for accounting purposes to analyze the data. To accomplish this requirement, Company A will use the Business Transaction Event 1120, Post Document: SAP Internal Field Substitution. Depending on the business scenarios, generally the reference document number field and assignment number field will be populated with a unique identifier for analyzing the accounting data. For the purpose of this document, I have used a scenario of populating the text field while creating accounting document. IMG Menu Path: Financial Accounting ->Financial Accounting Global Settings-> Business Transaction Events- > Environment-> Infosystem (Processes). Execute the search with the defaults.

Transcript of Triggering Workflow Using Business Transaction Events (BTE)

  • Triggering Workflow using Business Transaction Events (BTE)

    What are Business Transaction Events?

    The enhancement technique (Open FI) that were developed for Financial Accounting Component.

    Open FI is based upon the following principles:

    o Application developers must define their interface in a function module, an assignment table is read in the accompanying code and the customer modules assigned are called dynamically.

    This can be easily adopted / customized to the business needs wherein SAP does not provide the standard functionality through customization or enhancements. This functionality is primarily used in FI in the areas of dunning, credit management, banking etc. For Example: Standard Dunning functionality in SAP sends the notice to the Pay to partner function (based on the partner functions in SD module i.e. pay to hits the books in Accounts Receivable in FI module), whereas the requirement could be to send the same to Bill to party, based on the premise that the original invoice was sent to him as per the partner functions in SD.

    Basic steps in configuring the Business Transaction Events:

    Company A would like to fill the Assignment field with custom value Demo BTE when an accounting document is posted for a certain Company Code for accounting purposes to analyze the data. To accomplish this requirement, Company A will use the Business Transaction Event 1120, Post Document: SAP Internal Field Substitution. Depending on the business scenarios, generally the reference document number field and assignment number field will be populated with a unique identifier for analyzing the accounting data. For the purpose of this document, I have used a scenario of populating the text field while creating accounting document.

    IMG Menu Path: Financial Accounting ->Financial Accounting Global Settings-> Business Transaction Events-> Environment-> Infosystem (Processes).

    Execute the search with the defaults.

  • Find the correct interface for updating the document.

    Place the cursor on the key 00001120 and click on Sample Function Module

    This navigates you to SE37 Function Builder. This is the function module (SAMPLE_PROCESS_00001120) we would need to copy into a Z or Y function module for coding

    Click on copy button.

  • Specify the function module name and the function group.

    Now in the SE37 screen, click on change button and enter the following code:

    Save and activate the function module

    Go back to the first screen by multiple clicking on BACK.

  • To assign function module to the event, we need to create a product, say ZPRODUCT. Click as shown below:

    Click on New entries.

    Ensure that the Active check box is checked, otherwise BTE wouldnt trigger.

    Now we need to assign the function module created earlier to the event

    Click as per the following screenshot:

  • Click on new entries and create the following entry for 00001120:

    Test the BTE by creating a document through FB01 transaction.

    To check whether the assignment field is filled with Demo BTE, display the created accounting document from FB03 and check for the Assignment value.

    Double click on the item.

  • Triggering business object events:

    Update the Z function module that is created earlier by calling the function module SWE_EVENT_CREATE to trigger a business object event. Link this event to the workflow. To know about triggering an event programmatically, see:

    Triggering Events Programmatically

    By Suresh Kumar Parvathaneni

    Purpose: This document details the procedure in triggering the business object events programmatically.

    Pre-requisites: It is assumed that the reader of this document is aware of the business object concepts and good in ABAP.

    Procedure:

    In this document, we would take an example of the business object BUS1001006 (Material) and the event CREATED. In general, this event is triggered whenever a material is created using a standard procedure like MM01 or any others. Now we would trigger this event from our own programs.

    Following are the screenshots of the business object BUS1001006 and the event CREATED. Go to transaction SWO1 for more information of the business object.

  • Double-clicking on the key field parameter gives you technical information of the field.

    In order to trigger an event programmatically, we would use the function module SWE_EVENT_CREATE.

    Following is the sample code to trigger the events programmatically:

    REPORT ZDEMO_TRIGGER_EVENT. DATA: KEY LIKE SWEINSTCOU-OBJKEY. KEY = '1163'. Material Number (hard-coded) CALL FUNCTION 'SWE_EVENT_CREATE' EXPORTING objtype = 'BUS1001006' objkey = KEY event = 'CREATED' * CREATOR = ' '

  • * TAKE_WORKITEM_REQUESTER = ' ' * START_WITH_DELAY = ' ' * START_RECFB_SYNCHRON = ' ' * NO_COMMIT_FOR_QUEUE = ' ' * DEBUG_FLAG = ' ' * NO_LOGGING = ' ' * IDENT = * IMPORTING * EVENT_ID = * TABLES * EVENT_CONTAINER = EXCEPTIONS OBJTYPE_NOT_FOUND = 1 OTHERS = 2 . IF sy-subrc 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ELSE. WRITE 'Event Triggered'. ENDIF. COMMIT WORK.

    In order to test whether the event is getting triggered or not, we can make use of Event Trace. Switch on the event trace using the transaction SWELS.

    Press Switch On.

    Now execute the program developed earlier. Now switch-off the event trace using the same transaction SWELS.

    Now go to transaction SWEL. Here you can list out the events triggered in the particular period of time. Here is the event-trace list:

  • Triggering Workflow using Business Transaction Events (BTE)Triggering Events Programmatically