Batch program

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.

  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) need to 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 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.
 

Copyright IBM Corp. 1997, 2003