Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
wolfgang_woehrle
Product and Topic Expert
Product and Topic Expert
Hi ABAP community,

this blog describes how to benefit from content assist and code element information when creating or editing data definitions using ABAP Development Tools (ADT) a.k.a. ABAP in Eclipse.

Content assist describes the Eclipse features that make your daily work easier. Code completion is one of these features. It proposes existing elements, keywords, or identifiers which might fit best at the current cursor position in your source code.

What Can I Insert Using Content Assist?


Code completion provides you a list with proposals which you can insert at the current cursor position. This can be, for example the following identifiers ...

  • CDS annotations

  • Datasources such as CDS view entities, CDS DDIC-based views, database tables, and so on

  • ABAP CDS keywords


In the following sample, you can see where you can trigger code completion in a data definition:


Simply choose Ctrl + Space at the relevant position in your source code if automatic code completion is not activated.

How To Use Content Assist?


Code completion is enabled by default. To disable it in the preferences, see the section "Automatic Display of Proposals".

For keywords ...


Start typing your code. If code completion finds a matching keyword, it will be displayed as proposal automatically:


 Just press the tab key to take it over.

Alternatively, you can choose Ctrl + Space and takeover the keyword from the proposal list:



For CDS annotations and so on ...


To reduce the number of proposals, enter asterisk (*) at the relevant position and choose Ctrl + Space. Note that the cursor position is relevant. The proposal will be added there.


The proposal list only displays the matching entries.

Did you know that content assist also helps you find the relevant value?


Note that you always position the cursor at the relevant position where you need assistance. Choose then Ctrl + Space and check the entries from the proposal list.

For datasources ...


Not enough? You are also supported when adding datasources, for example a database table.


After adding a datasource, you can add all of its elements in one step. Did you know that? Simply choose Ctrl + Space to trigger content assist and choose "Insert all elements" from the proposal list.


Afterwards, all elements of the datasource will be added to your data definition.


When you have defined an association in your data definition, ...

  • the elements from the association target will also be automatically inserted. The /*Associations*/ comment highlights that the subsequent elements result from the association.

  • you can also insert all elements from the association target. To do this, add a dot after the element, choose Ctrl + Space and choose Insert all elements from the list.




How To Set the Relevant Preferences?


Automatic Display of Proposals


Content assist (inclusive code completion) is enabled by default. To disable automatic proposals, choose Window > Preferences > ABAP Development > Editors > Source Code Editors > Code Completion from the menu bar. Alternatively, you can directly enter "code completion" in the search field of the Preferences dialog.


Just deselect then the Automatically trigger code completion after typing '-', '~', '->' checkbox.

Defining Insertion or Overwrite



You can predefine how to take over proposals from the code completion list. In the Content Assist section from the latter preference page, choose one of the following radio buttons ...

  • Completion inserts to add the proposal to your input at the current cursor position

  • Completion overwrites to remove your input with the chosen proposal


Note that this function only works when you keep Ctrl pressed and select the relevant proposal, your source code will be adapted as follows:

Insertion


ADT inserts the proposal at the current cursor position.


So,you might need to remove your previous input to fix possible errors.

Overwrite


ADT completely overwrites the existing input in the whole line.



Flat or Structured Insertion



To predefine ABAP CDS-specific code completion, choose Window > Preferences > ABAP Development > Editors > Source Code Editors > CDS > Code Completion from the menu bar. Alternatively, you can directly enter "code completion" in the search field of the Preferences dialog.

For example, here you can define how to insert CDS annotations.

Flat Insertion



The annotation will be added in one line.

Structured Insertion



The annotation will be added indented across several lines.

How To Benefit From Code Element Information?


When triggering content assist, you can use the element information popup to get more information about the element you want to add. This supports you to ensure adding the right element. Just select the relevant proposal and its element information popup will be opened.


In addition, you can navigate from here to associations, and so on.

Help Content


Do you want to get more details? Great, see our help content on the SAP help portal.