Retrieve SAP business events(BE) within BEG and BET

The following code takes a Business event group(L) or a business event type (D) as its input so_begt, and retieves all the business events which exist within the data range. Also retrieves BE's with all the subordinate BEG and BET. The results are stored in the table it_bevents with the following fields:

sobid - Business Event id(E)
begda - Start date
endda - End date
betype - Business Event Type id (D)


tables: hrp1001,BAPIETDAT.
SELECT-OPTIONS:so_begt for BAPIETDAT-ETYID no INTERVALS.
data: it_hrp1001_tmp type STANDARD TABLE OF hrp1001,
types: begin of t_bevents,
  objid type hrp1001-objid,
  begda type hrp1001-begda,
  endda type hrp1001-endda,
  betype type hrp1001-objid,
 end of t_bevents.
data: it_bevents type STANDARD TABLE OF t_bevents,
      wa_bevents like line of it_bevents.
data: r_objid type RANGE OF hrp1001-objid,
      wa_objid like line of r_objid.
  if not so_begt is initial.
    SELECT *
    from hrp1001
    into table it_hrp1001_tmp
   where ( otype eq 'L' or
           otype eq 'D' or
           otype eq 'P' or
           otype eq 'E' ) and
         objid in so_begt and       "r_objid and
         rsign = 'B'.
    perform store_retrieved_records.
  endif.
  do.
    refresh it_hrp1001_tmp.
    SELECT *
      from hrp1001
      into table it_hrp1001_tmp
     where ( otype eq 'L' or
           otype eq 'D' or
           otype eq 'P' or
           otype eq 'E' ) and
           objid in r_objid and
           rsign = 'B'.
    if sy-subrc eq 0.
      perform store_retrieved_records.
    else.
      exit.
    endif.
  enddo.
*&---------------------------------------------------------------------*
*&      Form  STORE_RETRIEVED_RECORDS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM STORE_RETRIEVED_RECORDS .
*  append lines of it_hrp1001_tmp to it_hrp1001.
  refresh r_objid.
  clear: wa_objid.
  loop at it_hrp1001_tmp into wa_hrp1001_tmp.
    if wa_hrp1001_tmp-sclas eq 'E' and
       wa_hrp1001_tmp-begda in so_dates.
      wa_bevents-objid = wa_hrp1001_tmp-sobid.
      wa_bevents-begda = wa_hrp1001_tmp-begda.
      wa_bevents-endda = wa_hrp1001_tmp-endda.
      wa_bevents-betype = wa_hrp1001_tmp-objid.
      append wa_bevents to it_bevents.
      read table it_betype into wa_betype with key betype = wa_hrp1001_tmp-objid.
      if sy-subrc ne 0.
        wa_betype-begda = wa_hrp1001_tmp-begda.
        wa_betype-endda = wa_hrp1001_tmp-endda.
        wa_betype-betype = wa_hrp1001_tmp-objid.
        append wa_betype to it_betype.
      endif.
     endif.
      wa_objid-sign = 'I'.
      wa_objid-option = 'EQ'.
      wa_objid-low    = wa_hrp1001_tmp-sobid.
      append wa_objid to r_objid.
  endloop.
  refresh: it_hrp1001_tmp.
ENDFORM.                    " STORE_RETRIEVED_RECORDS


Related Articles

Information about SAP's Training and Event Management ( TEM ) application
SAP TEM course attendees
SAP TEM course attendees
Useful SAP function modules and BAPI's for training and events management - SAP TEM
Structure of a BEG, BET and BE
Basic SAP TEM table relationships