Editing a Repository Object

Objective

After completing this lesson, you will be able to Improve coding speed using ABAP Development Tools' code completion utilities and templates.

Repository Objects and ABAP Development Tools

Creating a Repository Object

Some repository objects can have subobjects that are themselves repository objects. For example, function modules belong to function groups. Furthermore, repository objects can reference other repository objects.

ABAP Development Tools allow you to create and edit repository objects.

Different tools are available for creating, editing, and displaying ABAP Repository Objects in ADT. Some of these tools are native to Eclipse but some objects must be displayed and edited in the SAP GUI.

Keyword Completion

ADT's keyword completion feature allows you to reduce the time spent on pure code editing by proposing valid ABAP keywords and identifiers to be inserted at any given position within the source code. To use keyword completion, you simply begin typing the first few characters of a keyword or identifier – suggestions appear automatically.

If the initial suggestion is correct, simply choose the TAB key to accept it. To see more options, choose Ctrl + Space on your keyboard, and then choose the desired ABAP keyword or identifier from the list of suggested entries. Note that keyword completion can be turned off in Preferences, but it is enabled by default.

Code Completion

The keyboard shortcut, Ctrl + Space, is not used solely for keyword completion. You can also use it to access code completion suggestions for the following:

  • Data objects declared within the application
  • Methods, attributes, and events
  • Function modules
  • Class names

When you choose Ctrl + Space, a full list of objects matching what you have already typed appears. As you continue to type, the list is narrowed down. To insert the name of a variable, function module, or method into your code, select the entry and choose Enter or double-click the name. For function modules and methods, you will often want to insert not just the name but also the full interface or signature. To do this, highlight the function module or method and choose Shift + Enter (on your keyboard).

Syntax Checking and Object Activation

There are two basic functions that all developers will need to use when developing ABAP applications. The first is syntax checking and the second is object activation.

The keyboard commands used to perform these basic functions are exactly the same as those of the SAP GUI-based editors (Ctrl + F2 for syntax check, and Ctrl + F3 for activation). However, the buttons have slightly different icons.

Static Code Templates

ABAP code templates are structured descriptions of coding patterns that can be used in ABAP source code. Their use allows developers to reduce the time they spend on routine editing activities and to improve consistency.

ABAP code templates go beyond the functionality of simple code snippets. They are integrated with ADT's code completion feature and they can use both predefined and custom variables. ADT contains a number of predefined code templates, but you can easily create your own, either by editing an existing template or by starting from scratch. Templates can be inserted into the ABAP source code editor using the same keyboard command – Ctrl + Space – that is used for keyword and code completion.

While there are a number of standard variables that can be used – as listed in the table below – the main advantage of code templates is that you can define your own placeholders. When you insert the template in your code, you provide values to replace the placeholders. If a placeholder is used more than once, the value replaces all its occurrences. This helps to avoid typing errors or errors caused by forgetting to rename a particular variable at a particular position in a block of code.

You can also drag and drop code templates into your code from the Templates view.

You can view, edit, or create new ABAP code templates in ADT Preferences. The options are very similar to those available when creating code templates in the ABAP Editor of the SAP GUI.

To create a placeholder within a template, use the dollar sign followed by the name of the placeholder enclosed in braces. Note that the editor for code templates does not provide a syntax check.

Log in to track your progress & complete quizzes