agentleFS
logalitechlogalitech/abap-skills/skills/cds-view-entities/SKILL.md

cds-view-entities

Skill0 starsChanged 3 months agoMITView on GitHub

Modelado con CDS view entities: capas del VDM (basic/composite/consumption), asociaciones, anotaciones de UI/analíticas, DCL y expresiones. Úsala cuando el usuario cree vistas CDS, define view entity, asociaciones, anotaciones, access control (DCL) o modele datos para RAP/analítica.

3 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    No accedas a tablas estándar crudas: consume vistas I_* liberadas.

    line 113
  2. Very specific:

    No dupliques una I_* estándar para modificarla: extiéndela o joina desde tu ZI_*.

    line 115

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

CDS View Entities

Guía para modelar datos con CDS view entities siguiendo el Virtual Data Model (VDM): capas, asociaciones, anotaciones semánticas y control de acceso con DCL.

Cuándo y cómo usarla

  1. Identifica el objetivo: exponer datos para Fiori, alimentar un BO RAP, construir una query analítica o crear una entidad reutilizable.
  2. Sitúa el contexto: decide la capa del VDM (basic, interface o consumption) y si consumes vistas I_* liberadas o tu propia capa basic.
  3. Aplica el patrón: usa define view entity (no la sintaxis clásica DEFINE VIEW), nombra los componentes en UpperCamelCase, añade asociaciones y anotaciones, y protege con DCL.

Las tres capas del VDM

CONSUMPTION (C_*)  ->  proyeccion final para un consumidor concreto
       consume
INTERFACE   (I_*)  ->  entidad de negocio estable y reutilizable
       consume
BASIC       (P_*)  ->  acceso normalizado a una tabla
       consume
   Tablas SAP / Z
  • Basic (ZP_*): acceso normalizado a una tabla, no reutilizable fuera del módulo.
  • Interface (ZI_*): contrato de negocio estable; muchas I_* de SAP están liberadas (C1).
  • Consumption (ZC_*): proyección específica para Fiori, OData o analítica.

View entity raíz con asociaciones y auditoría

@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Travel Root View'
define root view entity ZR_Travel
  as select from ztravel
  association [0..1] to I_BusinessPartner as _Customer
    on $projection.CustomerId = _Customer.BusinessPartner
{
  key travel_uuid           as TravelUuid,
      travel_id             as TravelId,
      agency_id             as AgencyId,
      customer_id           as CustomerId,
      total_price           as TotalPrice,
      currency_code         as CurrencyCode,

      @Semantics.user.createdBy: true
      created_by            as CreatedBy,
      @Semantics.systemDateTime.createdAt: true
      created_at            as CreatedAt,
      @Semantics.systemDateTime.localInstanceLastChangedAt: true
      local_last_changed_at as LocalLastChangedAt,
      @Semantics.systemDateTime.lastChangedAt: true
      last_changed_at       as LastChangedAt,

      _Customer   // publicar la asociacion
}

Cardinalidades: [1..1] exactamente uno, [0..1] cero o uno (por defecto), [1..*] uno o varios. Publica la asociación en la lista de campos para que los consumidores puedan navegar por ella.

Proyección de consumo, textos y búsqueda

Sobre la interface se define la consumption con contrato transaccional y anotaciones de UI/búsqueda.

@EndUserText.label: 'Travel Consumption'
@AccessControl.authorizationCheck: #NOT_REQUIRED
@Metadata.ignorePropagatedAnnotations: true
@Search.searchable: true
define root view entity ZC_Travel
  provider contract transactional_query
  as projection on ZI_Travel
{
  key TravelId,

      @Search.defaultSearchElement: true
      @Search.ranking: #HIGH
      @Search.fuzzinessThreshold: 0.8
      @ObjectModel.text.element: [ 'CustomerName' ]
      CustomerId,
      _Customer.BusinessPartnerName as CustomerName,

      TotalPrice,
      CurrencyCode,
      _Customer
}
  • @ObjectModel.text.element vincula un código con su descripción para no mostrar dos columnas.
  • localized (por ejemplo _Status._Text.Description as StatusText : localized) inyecta el texto en el idioma del usuario.
  • Las transformaciones complejas (concat, concat_with_space) van en la capa raíz, no en la proyección.

Control de acceso con DCL

Una view entity con @AccessControl.authorizationCheck: #CHECK exige un rol DCL asociado, o el ATC avisa. El rol filtra los datos según las autorizaciones PFCG del usuario.

@MappingRole: true
define role ZR_Travel_Auth {
  grant select on ZR_Travel
    where ( CompanyCode ) = aspect pfcg_auth( S_TRVL, BUKRS, ACTVT = '03' );
}

Valores de la anotación: #CHECK (exige rol), #NOT_REQUIRED (como check pero sin warning), #NOT_ALLOWED (sin control). El control implícito solo aplica al acceder directamente a la vista con Open SQL o SADL, no cuando se usa como fuente de otra CDS.

Buenas prácticas y errores comunes

  • Usa define view entity, no la sintaxis clásica DEFINE VIEW ... WITH. Las view entities no crean vista de diccionario y validan más estricto.
  • No accedas a tablas estándar crudas: consume vistas I_* liberadas.
  • Nombra en UpperCamelCase para respetar la convención OData que heredarán los servicios.
  • No dupliques una I_* estándar para modificarla: extiéndela o joina desde tu ZI_*.
  • Planifica el DCL desde el modelado: un acceso indirecto sin rol puede exponer datos que creías filtrados.

Referencias

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.