You use CDS annotations to enrich your data model with metadata. In some cases, this can reduce readability and make it hard to maintain your data definitions. To improve this situation, metadata extensions have been introduced.
With metadata extensions you can modularize the annotations within your data definitions and add customer-specific metadata to SAP entities modifying the data definition. It’s a transportable ABAP development object with its own Dictionary folder in the Project Explorer.
Using Refactoring Features and Templates
To improve the readability of your data definition you can extract annotations from the data definition into a separate metadata extension. Just select the relevant annotations in the CDS view with the mouse and choose “Source Code” > “Extract Metadata Extension” from the context menu.
The extraction wizard for creating a new metadata extension is opened.
Here the same logic is used as for the rest of the development objects.
Templates provide you a predefined set on code.
I am sure, you know what to do. After finishing, the selected annotations are removed from the CDS view and added to the new metadata extension.
But you don’t have to extract all annotations to make your code clearer. You can also show and hide all annotations for a quick check. To do this, right click in the ruler bar beside the editor.
From this menu, you can choose the relevant entry.
Finally, I want to highlight code folding. It allows you to collapse coherent parts of source code such as SQL clauses, CDS annotations, and comments. You can trigger it from the same menu as hiding comments/annotations.
If you choose “Collapse All”, the annotations are hidden:
The fact that the annotations are collapsed is highlighted by the sign at the beginning and the double dot indicator at the end of the row.
You want to know more about working with the coding of metadata extensions? You should then take a look on Horst’s blog: ABAP News for Release 7.51 – Meta Data Extensions in ABAP CDS
For more information in our help content, look here