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.
About this task
Note: 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
- Determine which verb to support: Create, Update, or Delete.
- 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.
- Determine the criteria for detecting an event.
You
should have knowledge of the database tables associated with a business
object.
- Create an ABAP program containing the criteria for generating
an event.
- 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.
- 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.
- Create is determined to be the supported verb.
- The quote number is determined to be the unique key used to retrieve
the events.
- 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.