Editing a Repository Object

After completing this lesson, you will be able to:

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 sub-objects that are themselves repository objects. For example, function modules belong to function groups. Furthermore, repository objects can reference other repository objects.

ABAP Development Tools allows 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 that may 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 re-name a particular variable at a particular position in a block of code.

ADT's standard variables are shown in the following table:

Standard Variables in ADT

Cursor modeSpecifies the cursor position after leaving template edit mode
DateEquates to the current date
DollarEquates to the dollar symbol ($)
line_selectionEquates to the content of all currently selected lines
TimeEquates to the current time
word_selectionEquates to the content of the currently selected text
YearEquates to the current year

ABAP-Specific Variables in ADT

enclosing_objectEquates to the name of the development object displayed in the current editor, such as the name of a class or include program
enclosing_packageEquates to the package, to which the development object belongs
system_idEquates to the ABAP System ID
UserEquates to the name of the user that is currently logged in to the ABAP system

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.

Save progress to your learning plan by logging in or creating an account

Login or Register