There is a very important time-saving ABAP Editor setting that enables data declaration of actual parameters when calling a function module (FM) or class method. The setting should work fine on ABAP release 731 and above.
After enabling the setting, call pattern for FM would look like this:
Call pattern of class method would look like this:
The settings can be found in ABAP Editor > Utilities > Settings > ABAP Editor > Editor > Pattern
I had seen the setting about 1 year ago on 701 release but the meaning was not so obvious. Enabling the setting did nothing on that release.
The text ( Name Actual Parameter Same as Name Formal Param. ) does not suggest that the actual parameters will be declared automatically.
F1 help or verbatim Google search returned 0 hits.
This 4 years old blog explains how to insert custom pattern (FM and data declarations) using ABAP Editor exit.
This ready-made solution was luckily present in my work environment. Excited by the thought of saving so much time, I started using the editor exit.
My work environment changed some time back ( different system having 731 release ) and the custom pattern was no longer with me.
I missed the functionality but didn’t install the code due to:
- Laziness – It is a selective thing. When it comes to touch typing, I am not lazy at all.
- Reluctance – Basis/Security might question me if dumps came due to that exit.
Couple of days ago I finally installed the editor exit. Nowadays I am trying to use methods instead of forms. As an exercise, I thought of understanding how the code works so that some day I’ll replace all forms with methods and probably improve the code using newer ABAP features.
The custom code reads FM’s formal parameters, determines the types, generates code for data declaration and then generates code for FM call. I thought to see how the standard generates FM call and reuse that code if possible. While debugging standard Call Pattern > Call Function, I found that there is an FM to generate the FM call. After generating the FM call code, there was additional code enclosed in IF condition. It really looked like the code is present for data declaration but it is not getting called.
The IF condition was on field of table RSEUMOD, which stores user specific ABAP workbench settings. This meant the setting can be activated somewhere in ABAP Editor settings. Added bonus was that similar setting is present for class methods too, which my custom editor exit didn’t do. I tried out same thing on 701 release ABAP trial and found that even though the setting is present in options, there is no corresponding code to do something with it.
This is how I came to know about the setting while debugging standard code.
Some Notes ℹ
- I am also using the option ” Functional Writing Style for Call METHOD ” . Functional-style method calls help reduce the lines of code and can be used in functional expressions. For example, try creating pattern for get_instance( ) method of some class. Generated code would have actual parameter on left hand side and functional method call on right hand side.
- You can export the ABAP Workbench settings to PC so that it can be imported by your colleagues.
- The custom pattern uses magic word *$&$MUSTER. Muster is German for Pattern.