Show TOC

ABAP: Set SMT to Prefetch ModeLocate this document in the navigation structure

Use

If transformation or condition methods must access the database, performance problems may occur due to inefficient database selections. The SMT supports a Prefetch mode to solve this issue.

After you have created an SMT object with the indicator I_WITH_PREFETCH = abap_true, or after you have called the Engine method PREFETCH, the SMT is in prefetch mode. You can inform the SMT about all inbound data in this mode. When prefetch mode ends, then transformation or condition methods in this mode can save relevant inbound data in order to be able to carry out all selections in one step.

Prerequisites

Your program has generated an object of type CL_SMT_ENGINE with activated prefetch.

Procedure
  • Your code sets the SMT to prefetch mode. (This can be skipped if the SMT object has been created with I_WITH_PREFETCH = abap_true):

    l_engine->prefetch_start( ).

    (The SMT calls method START_OF_PREFETCH of all transformation and condition classes.)

  • Your program performs a loop over all inbound data, and calls the method PREFETCH of the SMT engine to transfer the source data:

    TRY.
          LOOP AT lt_source INTO l_source.
            l_engine->prefetch( EXPORTING i_source = l_source ).
          ENDLOOP.
        CATCH cx_smt_customizing_error cx_smt_transformation_error INTO l_error.
          "...
      ENDTRY.
    
  • Your program ends the prefetch mode by calling up method PREFETCH_END: l_engine->prefetch_end( ).

    (The SMT calls method END_OF_PREFETCH of all transformation and condition classes.)

Table 1: Parameters of prefetch method

Parameter

Meaning

I_SOURCE

Source data line

I_PREDECESSOR1-4

Optional source data lines, which are hierarchical predecessors of the source data line. If, for example, the source is a document item, the first predecessor is the document header.

I_ADD1-20

Optional import parameters for additional data lines, that are not part of the source data hierarchy. You can use these, for example, to transfer Customizing data.

Note

If you use prefetch mode, then you should set

CHECK i_prefetch IS INITIAL.

in the first line of method EXECUTE of all transformations and conditions that do not support the prefetch. Otherwise your operations will also be carried out in prefetch mode.