*----------------------------------------------------------------------*
*   INCLUDE ZINSPECTION                                                *
*----------------------------------------------------------------------*
* &
* &  Report Title:         ZINSPECTION
* &  Author:               Christoph Weyd, SOO1 GmbH
* &  Creation Date:        01.01.2001
* &  Development Class:    ...
* &  Transport request:    MBSK900017
* &
*----------------------------------------------------------------------*
*&
*& This include is evaluating conditions which are defined
*& outside of the calling program in a special table ZINSPECT.
*&
*& e.g. we want to execute some lines of code in some user-exits
*&      if we have a shipment load-id. The code will look like:
*&
*&  IF lidtype EQ 'DSH010' OR
*&     lidtype EQ 'DSH030'.
*&   ...
*&  ENDIF.
*&
*& with this new include we configure the condition in table ZINSPECT
*& so the new code looks like:
*&
*&  INCLUDE ZINSPECTION.      " once in every main program
*&  inspect 'shipment LID'.
*&    ...
*&  endinspect.
*&
*&  Table ZINSPECT:
*&
*&  Key              Cond   F1                Op       F2
*&  'shipment LID'   0001   $lidtype          EQ       'DSH010'
*&  'shipment LID'   0002   $lidtype          EQ       'DSH030'
*&  'shipment LID'   0003   #1                OR       #2
*&
*& If we add a new shipment load-id we don't need to change the source
*& code in all the user exits, we just add two more lines to this table
*&
*&  Key              Cond   F1                Op       F2
*&  'shipment LID'   0001   $lidtype          EQ       'DSH010'
*&  'shipment LID'   0002   $lidtype          EQ       'DSH030'
*&  'shipment LID'   0003   $lidtype          EQ       'DSH035'
*&  'shipment LID'   0004   #1                OR       #2
*&  'shipment LID'   0005   #3                OR       #4
*&
*& how to use this includes?
*&
*& 1. check that ZINSPECTION is included once in the main program
*&    (inside of this include we define the tables/data/macros)
*&
*& 2. define a unique key (e.g. 'key1' for the set of conditions you
*&    want to evaluate
*&
*& 3. maintain table ZINSPECT (SM30). First character of Fx means:
*&     '$' -> local or global variable of program
*&     '#' -> result of a previous condition
*&     ' ' -> fix value
*&
*& 4. start evaluating the conditions by inserting (variant a. or b.)
*&
*&     a.) 00010 inspect 'key1'.        " call as macro -> no debugging
*&     b.) 00010 inspectkey = 'key1'.
*&         00020 INCLUDE ZINSPECT.      " debugging is possible
*&
*&    inside of this include/macro, the set of conditions for the
*&    given key is evaluated and the result is true or false.
*&    Depending on this result, at the very end of this include/macro
*&    we open an IF statement. This IF stement has to be closed
*&    by using:
*&
*&     a.) 00030 endinspect.            " macro
*&     b.) 00030 INCLUDE ZENDINSPECT.   " include
*&     c.) 00030 ELSE.   ....   ENDIF.
*&
*&  5. more informations by Christoph Weyd, SOO1 GmbH
*&                          http://www.SOO1.de
*-----------------------------------------------------------------------

*& Tables and Data
  TABLES: ZINSPECT, T000.
  DATA: CT LIKE ZINSPECT OCCURS 0 WITH HEADER LINE.

  DATA: INSPECTKEY LIKE ZINSPECT-INSPECTKEY.
  FIELD-SYMBOLS: <F1> TYPE ANY,
                 <F2> TYPE ANY.

  DATA: F1 LIKE BDCDATA-FVAL.
  DATA: F2 LIKE BDCDATA-FVAL.
  DATA: OP LIKE ZINSPECT-OP.
  DATA: RC LIKE SY-SUBRC.

*& evaluate all conditions for a given key and if the result is true
*& then execute all statements between INSPECT and ENDINSPECT
DEFINE INSPECT.
*&  select all conditions from DB table
  INSPECTKEY = &1.
  INCLUDE ZINSPECT.
END-OF-DEFINITION.

DEFINE ENDINSPECT.
*& close the pending if statements
  INCLUDE ZENDINSPECT.
END-OF-DEFINITION.

(C) www.SOO1.de