Working with Code Completion

In the ABAP source code editor, the content assist function proposes valid ABAP keywords and identifiers that are relevant at the current position. One of these proposals can be inserted in the source code.

Context

You can reduce the time spent on code editing and ensure that you are using the valid source code elements by using code completion.

The following code completion functions are provided:

List of Available ABAP Code Completion Functions
Content Assist Description
Keyword Completion The best matching ABAP keyword is automatically proposed as soon as you start typing.
Non-Keyword Completion The best matching non-keyword that is available for the corresponding source code section is automatically proposed as soon as you start typing.
Code Completion A list of all matching keywords, identifiers, components, and templates is displayed for the position where you have chosen the Ctrl + Space shortcut.

Keyword Completion

In the ABAP source code editor, the best matching ABAP keyword is displayed as soon as you start typing the keyword. If you choose the tabulator tab, the keyword is inserted at the current position.

Prerequisites

To use this functionality, navigate to the Start of the navigation pathWindow Next navigation step Preferences Next navigation step ABAP Development Next navigation step Editors Next navigation step Source Code Editors Next navigation step Code CompletionEnd of the navigation path preference page and select the Start of the navigation pathTyping Next navigation step Suggest keywordsEnd of the navigation path option.

Context

Procedure

  1. In the source code, start typing a keyword.

    The proposal for the most relevant keyword is displayed.

    Display of a proposal for a certain keyword while typing
    Display of a proposal for a certain keyword while typing
  2. Adopt the displayed entry into your source code by choosing the tabulator key.

Results

At the position where you have selected the proposal, the corresponding keyword is added to the source code.

Non-Keyword Completion

In the ABAP source code editor, the best matching non-keyword, such as an element name or type definition, is displayed when you start typing.

Prerequisites

To use this functionality, open the Start of the navigation pathABAP Development Next navigation step Editors Next navigation step Source Code Editors Next navigation step Code Completion Next navigation step TypingEnd of the navigation path preference page and select the Also suggest non-keywords option.

Context

Procedure

  1. In the source code, start typing a non-keyword.

    The proposal for the most relevant non-keyword is displayed.

    Display of a proposal for a certain non-keyword while typing
    Display of a proposal for a certain non-keyword while typing
  2. Adopt the displayed entry into your source code by choosing the tabulator key.

Results

At the position where you have selected the proposal, the corresponding non-keyword is added to the source code.

Code Completion

In the ABAP source code editor, you can open the code completion list manually at any position or automatically after you have typed a component selector such as -, ~, ->, =>.

Context

This functionality enables you to:

  • add possible keywords or identifiers such as variables, classes, interfaces, methods
  • select and add the component of the related identifier, such as a field of a structure or a method of a class

to your source code.

Procedure

  1. In the source code editor, type the beginning character(s).
  2. To display the list of suggested entries at this position, choose Ctrl + Space.
    The most relevant proposals are displayed in the code completion list.
  3. Choose Enter to add keywords or identifiers or Shift + Enter to add the full signature of a method or function module.
  4. Selecting a proposal from the code completion list.

Results

The corresponding keyword or identifier is added to the source code at this position.

Using Code Completion Automatically

In the ABAP source code editor of a development object, you want to open the code completion list automatically when you enter a component selector such as -, ~, ->, =>.

Prerequisites

To use this function, open the Start of the navigation pathWindow Next navigation step Preferences Next navigation step ABAP Development Next navigation step Editors Next navigation step Source Code Editors Next navigation step Code CompletionEnd of the navigation path preference page and select the Start of the navigation pathTyping Next navigation step Automatic code completion after typing -,~,->,=>End of the navigation path option.

Context

Procedure

  1. In the source code, you start typing a component.

    The following component selectors are supported:

    Component Selector Displayed Proposals
    - Fields of structures
    ~ Components of interfaces
    -> Instance components of object references
    => Static components of ABAP classes / interfaces

    The code completion list is automatically displayed.

    Code completion list and popup according to the component
    Code completion list and popup according to the component
  2. Select a component from the code completion list.

Results

The component is added to the source code at the current position.

A call to the static call_static_demo2 method is inserted at your current position
A call to the static call_static_demo2 method is inserted at your current position

Inserting a Full Signature Automatically

In the ABAP source code editor of a development object, you want to insert the full signature of a method, function module, or form routine automatically.

Prerequisites

To use this function, open the Start of the navigation pathABAP Development Next navigation step Editors Next navigation step Source Code Editors Next navigation step Code Completion Next navigation step TypingEnd of the navigation path preference page and select the Always insert full signature on completion option.

Context

Procedure

  1. In the source code editor, type the name of a method, function module, or form routine.
    The code completion list with the available entries and full signature is displayed.
  2. Select the relevant entry.

Results

The full signature is inserted in the source code at the current position.

Inserting or Overwriting Source Code

In the ABAP source code editor, you can insert a keyword, identifier, or template from the code completion list at the current position. Optionally, you can configure the code completion to overwrite the keyword or identifier at the current position.

Prerequisites

To overwrite the keyword or identifier at the current position, choose the Start of the navigation pathABAP Development Next navigation step Editors Next navigation step Source Code Editors Next navigation step Code Completion Next navigation step Content Assist Next navigation step Completion overwritesEnd of the navigation path preference in advance.

Context

Procedure

  1. In the source code editor, type the beginning character(s).
  2. To display the list of suggested entries at this position, choose Ctrl + Space.

    The code completion list is opened.

    Example for inserting the identifier current_speed and replacing it with the existing identifier result
    Example for inserting the identifier current_speed and replacing it with the existing identifier result
  3. Adopt the displayed entry into your source code by choosing the tabulator key.

Results

The selected keyword, identifier, or template is inserted and replaces the keyword or identifier at the current cursor position.

Example after replacing the identifier result with current_speed
Example after replacing the identifier result with current_speed