Skip to Content
Author's profile photo Michael Schneider

ABAP Block Highlighting

Recently, I saw some questions in this community related to the structure of your ABAP coding: “How can I navigate to the end-statement of an IF-Block?” or “Where does my current ABAP code blocks start or end?”

I would like to show you in this blog how ABAP Block Highlighting can help you to answer these questions.

What is ABAP Block Highlighting?

ABAP Block Highlighting is a nice way to highlight ABAP code blocks in the ABAP editor.

abapIfBlock.png

Here are some examples of ABAP Code Blocks

  • CLASS … ENDCLASS
  • METHOD … ENDMETHOD
  • FORM … ENDFORM
  • IF … ELSE … ENDIF
  • CASE … WHEN … ENDCASE
  • LOOP … ENDLOOP
  • WHILE … ENDWHILE
  • TRY … CATCH … ENDTRY

“How can I navigate to the end-statement of an IF-Block?”

The highlighting of ABAP blocks is realized as Eclipse annotations. This helps you to use some Eclipse standard functionality to navigate through the various parts of the current ABAP block: Just use the buttons Next and Previous Annotation in the toolbar or the shortcuts Ctrl+. or Ctrl+,.

annotationButtons.png

Ensure that you have enabled the annotation ABAP Block Highlighting as navigation target. Just click on the button’s drop-down icon to reach the following selection:

annotationSelection.png

BTW: You can use this navigation also for other annotations (e.g., ABAP Occurrences, Errors and/or Warnings listed by the ABAP syntax check).

“Where does my current ABAP code blocks start or end?”

In the preferences (Windows > Preferences > General > Editors > Text Editors > Annotations > ABAP Block Highlighting) you can also enable the option Overview ruler.

annotationPreferences.png

This will show you the current ABAP block also in the editor’s overview ruler. This gives you a nice overview about the structure of your current ABAP block and you can also use the ruler to navigate by clicking on the marker.

abapIfBlockOverviewRuler.png

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Efstratios Tsantilis
      Efstratios Tsantilis

      Very cool feature during work, underrated and/because quite unknown!

      Author's profile photo Peter Inotai
      Peter Inotai

      Hi Michael,

      Thanks for this info.

      It seems that 'CASE WHEN' has some backend dependencies, because it doesn't work with 7.40 SP4 (all the other statements work), but seems to work with SP10 system.

      Do you have some info about this?

      Thanks,

      Peter

      Author's profile photo Joachim Rees
      Joachim Rees

      Nice, I didn’t know that.

       

      But with the annotation naviagtion, you can get “trapped”:

      If you only have DO and ENDO you can navigate beween theme infinitely, thats fine. 

      But if you add an EXIT or CONTINUE in, that will become your next navigation target.

      If that stetement is enclosed by IF / ENDIF (as it most often will be the case) you now only can navigate in that narrow frame! ?

       

      Maybe this shows it better what I want to say:

      best

      Joachim