Skip to Content
Author's profile photo Thomas Fiedler

Insert Code Patterns and Templates within Eclipse

A famous feature in the ABAP workbench editor is to insert code patterns into your source code.

I mean the magic behind this button in the editor toolbar:

 

Pattern.png

 

And with ABAP in Eclipse this feature is gone 😯

–> NO WAY ! It is integrated with the code completion

 

See this small video tutorial to learn how to use this feature:

 

In addition to that we also have static code templates available in Eclipse. A flexible way to easily generate code in your editor. You can also define your own templates and use them. A good example is the template to generate a local test class.

 

See this small video tutorial to learn how to use this feature:

Regards and have fun,

Thomas.

 

Assigned Tags

      20 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Adam Krawczyk
      Adam Krawczyk

      Hi Thomas,

       

      Thank you for great hints. I could not find insert pattern for function module before, and it is so simple - the trick with autocompletion and SHIFT + ENTER.

       

      Regards

      Adam

      Author's profile photo Adam Krawczyk
      Adam Krawczyk

      Hi again,

       

      I like pattern build in code completion, however it looks like pattern for FORM is missing? Insert FORM pattern in SAP GUI lists all available subroutines in main program. When I type PERFORM and then beginning of form name with CTRL + SPACE, nothing is found. It may work in case if forms are in same include. As we often need to work with legacy code, having pattern for FORMs in program would be helpful, otherwise we need to open include in SAP GUI and insert pattern there. Any tips here?

       

      Regards

      Adam

      Author's profile photo Uwe Fetzer
      Uwe Fetzer

      You are working with FORM/PERFORM? Oh, you bad guy, no presents for xmas this year 😉

      Author's profile photo Luís Pérez Grau
      Luís Pérez Grau

      Back to the roots 😀

      Author's profile photo Adam Krawczyk
      Adam Krawczyk

      Hi Uwe,

       

      I still have a chance with Easter rabbit.

       

      I get often questions from experienced SAPpers (they can make mistake only once ) about missing things in eclipse, when they are trying to show that eclipse is not good enough yet. And FORM pattern is one of weaknesses, to be honest it may be useful if we work much with legacy code and that is reality. Another case hard to defend is not allowed activation or "where used search" for include used in many programs, but that is another story. Need to switching to embed GUI too often may burn eclipse desire. Not with me anyhow, I am fan of it.

       

      Regards

      Adam

      Author's profile photo Thomas Fiedler
      Thomas Fiedler
      Blog Post Author

      Hi Adam,

      I have just check it and it works. I closed my door and darkened the room to create a form routine in a report with ABAP in Eclipse     

      The Code Completion wizard displayed it after typing PERFORM ...

       

      Regards,

      Thomas.

      Author's profile photo Adam Krawczyk
      Adam Krawczyk

      Hi Thomas,

       

      Great hint with doors closing, I must remember it

      It might be that you are using FORM that you just created or it is in same include or you have latest AIE 2.7. Anyhow, I accept answer "works on my PC" (sometimes I saw it was working as well), I just wanted to check if there is maybe hidden option with same dialog as for pattern button.

       

      Regards,

      Adam

      Author's profile photo Former Member
      Former Member

      Hi colleagues,

       

      I was just pointed to a feature of the SE80 patterns that I did not yet find in Eclipse:

       

      activating the option 'Name of Actual Parameter Same as Formal Parameter' in the settings of the SE80 ABAP Editor yields a nice hidden feature only available when using the 'Pattern' dialogue: it will generate variable declaration with correct data types.

       

      Example:

      *DATA FIELDS TYPE STANDARD TABLE OF SVAL.

      CALL FUNCTION 'POPUP_GET_VALUES'
         EXPORTING
      *   NO_VALUE_CHECK        = ' '
           popup_title           = popup_title
      *   START_COLUMN          = '5'
      *   START_ROW             = '5'
      * IMPORTING
      *   RETURNCODE            = RETURNCODE
         TABLES
           fields                = fields
      * EXCEPTIONS
      *   ERROR_IN_FIELDS       = 1
                 .
      Any chance to have that generated in Eclipse, too?


      Regards

      Markus

      Author's profile photo Thomas Fiedler
      Thomas Fiedler
      Blog Post Author

      Hi Markus,

      you are right. This option is missing in Eclipse. The data declarations are only generated by pattern function in the GUI edior but not for the Shift-Enter Function of code completion. We will offer a new Quick Fix in Eclipse "Add Data Declaration" which generates the missing variables into your code. I have already tested it yesterday in our dev system. Really cool stuff.

       

      Regards,

      Thomas.

      Author's profile photo Martin Krupka
      Martin Krupka

      Thomas, has this ever been released? I am unable to trigger this functionality from Eclipse. 

      Author's profile photo Chaouki Akir
      Chaouki Akir

      Were you able to trigger this functionality in Eclipse ?

      Author's profile photo Christine Arundell
      Christine Arundell

      Hi Thomas,

       

      I really like the auto-completion of function calls in ADT using SHIFT+ENTER - but I've found that for some function modules, it doesn't work - instead I get the message 'Code information isn't available#' when I use CTRL+SPACE to find the function module in question.  It works perfectly for other function modules - can you think of a reason why it wouldn't work in partciular cases?  The function module in question is definitely valid (POPUP_TO_CONFIRM)

       

      Thanks

      Christine

      Author's profile photo Thomas Fiedler
      Thomas Fiedler
      Blog Post Author

      Hi Christine,

      on which ABAP stack do you have the issue? Is it NW 7.31 or NW 7.4?

      Which Suppport Package Level do you have?

       

      Regards,

      Thomas.

      Author's profile photo Christine Arundell
      Christine Arundell

      Hi Thomas,

       

      NW 7.4, SPS 2

       

      Christine

      Author's profile photo Former Member
      Former Member

      Hey everybody,

      is there any posibility to transfer the Patterns from SAP SE80 to Eclipse?
      Because I think it would be even easier to take the standard SE80 Patterns from my company instead of creating new ones.


      Regards,

      Erik

       

      P.S. Sorry for bad english!

      Author's profile photo Former Member
      Former Member

      Hi, Erik,

      There is no standard tool to transfer patterns from se80.

      But I've developed Z-tool for this. You can inport it in you system as SAPLink nugget

       

      See this post

       

      Best regards,

      Vitaliy

      Author's profile photo Pavel Astashonok
      Pavel Astashonok

      How to automatically create method implementation when I declared it in CLASS DEFINITION? Shift-Enter seems to doesn't work in this case.

      Author's profile photo Thomas Fiedler
      Thomas Fiedler
      Blog Post Author

      Hi Pavel,

      for generation of method implementations we have the the following Quickfix for you.

      Just press CTRL + 1 on the method definition statement and you will get the following options:

       

      Quickfixes is one of the most important features in ADT.

      Regards,

      Thomas.

       

      Author's profile photo Pavel Astashonok
      Pavel Astashonok

       Thanks, it works!

      Author's profile photo Jesús López Urrabieta
      Jesús López Urrabieta

      I know this is a really old thread, but I couln't find any more current/relevant one.

       

      The one code completion I miss in ADT is the select table pattern.

       

      I try to enter select * from <beginingLettersOfMyTable> and I press Cntrl-Enter and y get a matching list of possible tables. But then, no matter if I press Enter or Shift-Enter (depending on Eclipse configuration, I have it configured to include full signatures with just Enter) I only get the table name.

       

      I miss being able to select the fields for the where clause, similarly as it does for Importing/exporting arguments in functions/methods.

       

      Anyway to do this in ADT? Thanks in advance.