IBM BPM, V8.0.1, All platforms > Authoring services in Integration Designer > Services and service-related functions > Access external services with adapters > Configure and using adapters > IBM WebSphere Adapters > SAP Software > Configure the module for deployment > Performing prerequisite tasks specific to an interface > Implementing event-detection mechanisms

Implementing batch programs

To implement batch program as an event detection mechanism, you must write an ABAP program that evaluates database information.

If the criteria in the ABAP program is fulfilled when the program executes, then an event is triggered.

This procedure is for the Advanced event processing interface only.

If you are not using the Advanced event processing interface, skip this procedure.

To implement batch program for event detection:


Procedure

  1. Determine which verb to support: Create, Update, or Delete.
  2. Determine the business object key for the transaction.

    The business object key must be unique so that the business object can be retrieved from the database. A composite key might be required.

  3. Determine the criteria for detecting an event.

    You should have knowledge of the database tables associated with a business object.

  4. Create an ABAP program containing the criteria for generating an event.

  5. If you are implementing the future events capability, in addition to adding the event-detection code for future events, contact your Basis administrator to schedule the adapter-delivered batch program /CWLD/SUBMIT_FUTURE_EVENTS to run once every day.
  6. Determine if a background job is required to automate the batch program.

    A background job is useful if there is an impact on system resources, which makes it necessary to run the batch program during off-peak hours.


Example

The following steps describe the process of creating a batch program that detects events for all sales quotes created on today's date. The code that follows it is a result of this process.

  1. Create is determined to be the supported verb.

  2. The quote number is determined to be the unique key used to retrieve the events.

  3. The creation date (VBAK-ERDAT) and the document category (VBAK-VBTYP) must be checked.

The following sample code supports the SAP sales quote as a batch program:

REPORT ZSALESORDERBATCH.  
tables: vbak.   

parameter: d_date like sy-datum default sy-datum.   

data: tmp_key like /CWLD/LOG_HEADER-OBJ_KEY, 
   tmp_event_container like swcont occurs 0.   

" retrieve all sales quotes for today's date   

" sales quotes have vbtyp = B   

select * from vbak where erdat = d_date and vbtyp = 'B'.   

tmp_key = vbak-vbeln.  

CALL FUNCTION '/CWLD/ADD_TO_QUEUE_AEP'  	
	EXPORTING  		
		OBJ_NAME = 'SAP4_SalesQuote'  		
		OBJKEY = tmp_key  		
		EVENT = 'Create'  		
		GENERIC_RECTYPE = ''  	
	IMPORTING  		
		RECTYPE = r_rectype  	
	TABLES  		
		EVENT_CONTAINER = tmp_event_container.  

write: / vbak-vbeln.   

endselect.


What to do next

Configure the adapter for Advanced event processing.

Implementing event-detection mechanisms