Top 20 RAP Annotations Every ABAPer Needs to Master

20 Most Used Annotations in RAP for ABAP Developers


Hey ABAPers! If you’re diving into the RESTful ABAP Programming Model (RAP) to build slick Fiori apps, you know annotations are your best friend. They’re like cheat codes—telling SAP how to display data, control behavior, and make your apps look pro without sweating over UI5 code. Today, I’m dropping the 20 most used RAP annotations you’ll see (and need) in CDS views to power your RAP services. Let’s roll!

What Are RAP Annotations?

In RAP, annotations are metadata tags in your CDS views that define how data looks and acts in Fiori apps. They handle UI layout, field properties, and service behavior. You write them with @ symbols in your CDS code, and RAP uses them to generate OData services.

No annotations = boring app. With them = Fiori magic.

Here’s the top 20, grouped by what they do, with examples you can steal for your own projects! 

UI-Focused Annotations (Make It Pretty)

  1.  @UI.lineItem
    • What: Adds a field to the main table/list in your Fiori app.
    • Use: Control position and label.
    • Example
      • @UI.lineItem: [{ position: 10, label: 'Order Number' }]  vbeln
       2.  @UI.selectionField
    • What: Puts a field in the filter bar for searching.
    • Use: Let users filter data easily.
    • Example
      • @UI.selectionField: [{ position: 20 }] erdat

        3.  @UI.headerInfo
    •  What: Sets the title and description in the app header.
    • Use: Defined at the view level, not per field.
    • Example
      • @UI.headerInfo: { typeName: 'Sales Order', title: { value: 'vbeln' } }
      • define view Z_Sales_View as select from vbak { ... }

        4.  @UI.identification
    • What: Shows a field on the object page (detail view).
    • Use: For key info in the details screen.
    • Example
      • @UI.identification: [{ position: 30, label: 'Customer' }]
      • kunnr
        5.  @UI.fieldGroup
    • What: Groups fields together on the object page.
    • Use: Organize details into sections.
    • Example:
      • @UI.fieldGroup: [{ groupId: 'BasicData', position: 10 }]
      • matnr

        6.  @UI.hidden
    • What: Hides a field from the UI.
    • Use: Keep data in the model but out of sight.
    • Example
      • @UI.hidden: true
      • tech_field

        7.  @UI.dataPoint
    • What: Turns a field into a visual (e.g., rating, progress bar).
    • Use: Highlight key metrics.
    • Example
      • @UI.dataPoint: { title: 'Order Value', criticality: 'netwr' }
      • netwr
         8.  @UI.chart
    • What: Creates a chart from your data.
    • Use: Visuals for analytics apps.
    • Example
      • @UI.chart: [{ chartType: #COLUMN, measures: ['netwr'] }]
      • netwr

        9.  @UI.facet
    • What: Defines sections/tabs on the object page.
    • Use: Structure the detail view.
    • Example:
      • @UI.facet: [{ id: 'General', purpose: #STANDARD, label: 'General Info' }]


        10.  @UI.criticality
    • What: Colors a field based on its value (e.g., red for bad, green for good).
    • Use: Visual status cues.
    • Example:
      • @UI.criticality: 'status'
      • status
      Behavior and Semantics (Control the Logic) 

         11.  @Semantics.amount.currencyCode
    • What: Links an amount field to its currency.
    • Use: Proper formatting in Fiori.
    • Example
      • @Semantics.amount.currencyCode: 'waerk'
      • netwr

        12.  @Semantics.currencyCode
    • What: Marks a field as a currency key.
    • Use: Pairs with amounts.
    • Example
      • @Semantics.currencyCode: true
      • waerk
        13.  @ObjectModel.readOnly
    • What: Makes a field non-editable.
    • Use: Lock down data in RAP.
    • Example
      • @ObjectModel.readOnly: true
      • vbeln

        14.  @ObjectModel.mandatory
    • What: Marks a field as required.
    • Use: Force user input.
    • Example
      • @ObjectModel.mandatory: true
      • kunnr
        
        15.  @ObjectModel.createEnabled
    • What: Allows creating new entries for an entity.
    • Use: Enable CRUD in RAP.
    • Example
      • @ObjectModel.createEnabled: true
      • define view Z_Sales_View as select from vbak { ... }
        Service and OData (Backend Magic)
        
        16.  @EndUserText.label
    • What: Sets a user-friendly label for a field.
    • Use: Better than technical names.
    • Example:
      • @EndUserText.label: 'Material Name'
      • maktx
        17.  @Consumption.filter
    • What: Configures filter behavior in Fiori.
    • Use: Smart filtering options.
    • Example:
      • @Consumption.filter: { multipleSelections: true }
      • matkl
        18.  @OData.publish
    • What: Exposes your CDS view as an OData service.
    • Use: Makes RAP work with Fiori.
    • Example
      • @OData.publish: true
      • define view Z_Sales_View as select from vbak { ... }
        19.  @AccessControl.authorizationCheck
    • What: Enables authorization checks for the view.
    • Use: Secure your data.
    • Example:
      • @AccessControl.authorizationCheck: #CHECK
      • define view Z_Sales_View as select from vbak { ... }
        20.  @AbapCatalog.viewEnhancementCategory
    • What: Controls how the view can be extended.
    • Use: Future-proof your CDS.
    • Example:
      • @AbapCatalog.viewEnhancementCategory: [#NONE]
      • define view Z_Sales_View as select from vbak { ... }

Why These Matter

These 20 annotations are the bread and butter of RAP. They bridge ABAP’s backend power with Fiori’s frontend flair. Whether you’re building a simple list app or a full-on transactional beast, you’ll hit most of these. Start with @UI.lineItem and @UI.selectionField—they’re in every RAP project—then level up to @UI.dataPoint or @ObjectModel stuff as you go.

Quick Tips

  • Test your annotations in ADT (Eclipse) with the “Preview” feature.
  • Pair them with a Behavior Definition (e.g., create; update;) for full RAP power.
  • Check SAP’s official CDS Annotation Reference for edge cases.

What’s your favorite RAP trick? Drop a comment below—I’ll be back with more ABAP goodies soon!



Comments

Popular posts from this blog

Unleashing the Power of BAPI with ABAP!"

Pranking with TH_POPUP