Skip to Content
Author's profile photo Former Member

Automatically Generate Data Declarations While Inserting FM or Method Call

Summary

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

Story

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.

Call a function module in the ABAP Editor: Stop Crying – Start Laughing.

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:

  1. Laziness – It is a selective thing. When it comes to touch typing, I am not lazy at all.
  2. 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 ℹ

  1. 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.
  2. You can export the ABAP Workbench settings to PC so that it can be imported by your colleagues.
  3. The custom pattern uses magic word *$&$MUSTER. Muster is German for Pattern.

Assigned Tags

      21 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Thanks for making my work little easy. 🙂

      Author's profile photo nabheet madan
      nabheet madan

      What a tip 😎 ..Very nice..Well done..Please keep them coming 🙂

      Author's profile photo Naveen Vishal
      Naveen Vishal

      Excellent blog, very helpful and practical !

      WTG !! ➕ ➕

      Author's profile photo abilash n
      abilash n

      Excellent Blog Manish........

      Author's profile photo Ulrich Rechner
      Ulrich Rechner

      We've used release 731 for so long now, and I haven't known about this helpful feature. I remember e.g. declaring variables for a BAPI-call with a lot of effort. Great hint!

      Author's profile photo Ajit Kumar Panda
      Ajit Kumar Panda

      Nice useful blog Manish.

      2 questions:

      1. How to export/import ABAP workbench settings to/from PC.

      2. Can you explain Point 3 of Some notes section.

      Thanks in advance.

      Ajit

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      If you are at correct release level, Utilities > Settings popup will have buttons to export/import. I am able to see these options.

      2014-09-23 16_04_59-User-Specific Settings.png

      To understand point 3, you need to follow the steps mentioned in below blog and notice the screenshot in section 2.2

      Call a function module in the ABAP Editor: Stop Crying - Start Laughing.

      Author's profile photo Ajit Kumar Panda
      Ajit Kumar Panda

      Thanks a lot Manish 🙂

      Author's profile photo Suman Chakravarthy K
      Suman Chakravarthy K

      Nice info 🙂 Thanks for sharing!

      Author's profile photo Former Member
      Former Member

      Hi Manish,

      Thanks for your wonderful document...I am not able to understand first point that where you create instance for pattern can you please explain it.Thanks in advance for help.

      After that if this pattern as been imported it will work to all users right ?

      Regards,

      Ravi Shankar.L

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      I am inserting the code using standard Call pattern > ABAP Objects Patterns > Call Method.

      For example, see these screenshots.

      Step 1:Press Call Pattern or Ctrl F6 and choose ABAP Objects Patterns

      2014-09-23 19_16_59-Ins. statement.png

      Step 2: Call a static method that returns object instance and press enter

      With correct settings and ABAP release level, resulting code would be:

      /.

      Author's profile photo Gregory Gotera
      Gregory Gotera

      Helpful blog   😎

      Author's profile photo Former Member
      Former Member

      Very helpful and useful blog for ABAPers

      Author's profile photo Former Member
      Former Member

      Easy!!

      Great info...

      Author's profile photo Andrea Olivieri
      Andrea Olivieri

      Hi Manish,

      thanks so much for sharing this important feature and also for mentioning my good-old blog.

      Andrea

      Author's profile photo Siddhesh Satghare
      Siddhesh Satghare

      Thanks alot manish.. This setting is very useful..

      Author's profile photo Eli Pai
      Eli Pai

      Hi  Manish,

      Good Job, This can save time and use very convenient for ABAPers. Thanks.

      Author's profile photo Flavio Furlan
      Flavio Furlan

      Hi Manish,

      Very good tip! Thanks!

      Author's profile photo Marc Augustin
      Marc Augustin

      Great tip, thanks for sharing 🙂

      Author's profile photo Pramod Pathirana
      Pramod Pathirana

      Thank you very much... this is new tip for me....

      Author's profile photo Remi Kaimal B
      Remi Kaimal B

      Very useful - thank you for sharing