Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
sander_vanwilligen
Active Contributor
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.

Situation


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.

Complication


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


Suggested Approach


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

Conclusion


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.
3 Comments
RafkeMagic
Active Contributor
Thanks for this blog, Sander!
former_member729347
Discoverer
0 Kudos
Hi Sander,

Would you give some information, how the template ZCL_TRFN_TEMPLATE_1 and ZCL_TRFN_TEMPLATE_2 to be created.

I mean is there any standard class from which we can copy and create these templates.

 

Regards,

T
sander_vanwilligen
Active Contributor
0 Kudos
Hi Tapan,

Please have a look at the following Question:

Where can I find attachments of blog "Transformation Class Approach – Part 2: Implementation"?

Here you can download the files with ABAP source code.

Best regards,

Sander

 
Labels in this area