ABAP Code completion basics

Just a quick post to briefly describe the ABAP code completion functionality in SAP, as it can be a little cumbersome if you don’t know exactly what buttons and settings you need to use to get the best from it. I am going to use the BOPF demo code to help demonstrate how this autocomplete functionality can become an essential part of your ABAP development toolset. For example, if you wanted to insert the GET_SERVICE_MANAGER method of /bobf/cl_tra_serv_mgr_factory class, including all the pattern details.

Press Ctrl+Space to activate ABAP Code completion

Access ABAP auto completion

Choose entry and press TAB or Enter key

For some reason, the system I am using shows this in a very small dialogue popup, hopefully it will be much clearer for you. Anyway you can scroll up and down to choose the method/option you want. For this example, I am going to choose GET_SERVICE_MANAGER. Once this is highlighted press the tab key

ABAP auto method selection

The entry will then be added to your code, but this Is not where this functionality stops. You can also use it to auto-insert the import, export etc parameters/pattern details. It is a bit fiddly at first, but very simple once you know how.

Press Ctrl+Space again

So now place the cursor at the end of the text just inserted and press the Ctlr+Space bar again, you will then get the next option to select from.

ABAP OO code insertion

Select the desired entry and Press TAB again

For this example there is only one option so select this and press the TAB button (or Enter key). The full pattern details of the ABAP code for this method will then be inserted

ABAP code completion full pattern details

Another example

Also note you can use it for all aspects of object based code, So for example when implementing the BOPF query you could first use it to fill the patter of lo_svc_mngr->query then also to complete zif_zts_bopf1_c=>sc_query-tsroot-select_all

lo_svc_mngr->query(
  EXPORTING
    iv_query_key            =   zif_zts_bopf1_c=>sc_query-tsroot-select_all  " Query
*    it_filter_key           =     " Key Table
    it_selection_parameters =     lt_selparam  " Query Selection Parameters
*    is_query_options        =     " Query Options
    iv_fill_data            = abap_true    "if true fills et_data table if false et_data left blank
*    it_requested_attributes =     " List of Names (e.g. Fieldnames)
  IMPORTING
*    eo_message              =     " Message Object
*    es_query_info           =     " Query Information
    et_data                 = lt_data
    et_key                  = lt_key
).

ABAP Code completion settings

One last thing in-case code completion is not working for you or you want to see what other options are available you can access the setting using the very small folder and paper icon in the bottom right-hand corner

Click this and choose the Code Completion option from the next screen to see all the relevant settings

ABAP Code completion settings

Leave a Comment

Your email address will not be published. Required fields are marked *