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.
To implement Batch Program for event detection:
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.
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 YXR_EVENT-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. TMP_OBJTYPE = space. CALL FUNCTION 'Y_XR_ADD_TO_QUEUE' EXPORTING OBJTYPE = TMP_OBJTYPE OBJNAME = 'SAP_SalesQuote' OBJKEY = tmp_key EVENT = 'Create' GENERIC_RECTYPE = '' IMPORTING RECTYPE = r_rectype TABLES EVENT_CONTAINER = tmp_event_container. write: / vbak-vbeln. endselect.