Over time quite some ABAP coding is written in the context of Transformations. On one hand it is an enabler for implementing the most sophisticated requirements. On the other hand it can easily become a chaos without proper standards and guidelines. It can even become dangerous, uncontrolled and cumbersome to support having so much coding all over the place.
The “best practice” concept of Transformation Classes can help to better encapsulate, organize and maintain the source code. ABAP-OO (Object Oriented) programming principles are used – in accordance with official and de facto development standards as published by SAP SE.
The purpose of this blog is to present the concept. In the blog Transformation Class Approach – Part 2: Implementation I will give step-by-step guidelines in creating Transformation Classes and embedding them in Transformations.
Coding in Transformations is often written directly inside the Transformation rule(s) in a free-format way and in different constellations:
- Start Routine
- Field Routine(s)
- End Routine
- Expert Routine
Figure 1: Options for Routines in a Transformation (source: SAP SE)
More information can be found in SAP Help – ABAP Routines in Transformations.
Coding directly inside Transformation routines has several disadvantages:
- Encapsulation of source code is not possible
- Solid version management is not available
- Not possible to create separate methods to organize or modularize (complex) coding
- Advanced ABAP Workbench tools are not available, e.g. Extended Syntax Check, Code Inspector and Test Cockpit
- These ABAP Workbench tools are essential for Quality Assurance of developed ABAP coding
- In case the Transformation is deleted, all source code is gone
Use a Transformation Class as soon as any ABAP coding is required. Two Transformation Class templates are available:
- ZCL_TRFN_TEMPLATE_1 for a “regular” Transformation
- ZCL_TRFN_TEMPLATE_2 for an “Expert Routine” Transformation
Starting point is a copy of the appropriate Transformation Class template. You must write few lines of (standardized) source code inside the Start Routine, End Routine or Expert Routine to call the Transformation Class. All logic can now be implemented in the new Transformation Class.
Two additional recommendations are:
- Avoid coding in Field Routines and use End Routine instead
- Only use an Expert Routine in special cases
Reusable ABAP Objects
In the table below you can find an overview of the reusable ABAP objects which we are going to use in the Transformation Class approach.
Figure 2: Overview of reusable ABAP Objects
In this blog I introduced the Transformation Class approach. The concept of Transformation Classes can help to better encapsulate, organize and maintain the source code within Transformation Routines. Please refer to the blog Transformation Class Approach – Part 2: Implementation for more information regarding implementation of this approach.