agentleFS
logalitechlogalitech/abap-skills/skills/rap/SKILL.md

rap

Skill0 starsChanged 3 months agoMITView on GitHub

Construcción de objetos de negocio con RAP: managed vs unmanaged, behavior definition (BDEF), draft, validaciones, determinaciones, acciones, autorizaciones y EML. Úsala cuando el usuario cree un business object RAP, un servicio OData con RAP, hable de BDEF, behavior pool, EML, draft, o determinaciones/validaciones.

5 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, 1 is distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 5 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    No accedas a la base de datos con SELECT dentro del pool: usa READ/MODIFY ENTITIES en modo local.

    line 110
  2. Very specific:

    No emitas COMMIT WORK ni ROLLBACK: la coherencia transaccional la gestiona RAP.

    line 111

“Common” is measured: kept by at least 6 in 10 of the 5 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

RAP (RESTful ABAP Programming Model)

Guía para construir objetos de negocio (BO) con RAP: modelo de datos CDS en capas, contrato de comportamiento (BDEF), implementación en el behavior pool y manipulación transaccional con EML.

Cuándo y cómo usarla

  1. Identifica el objetivo: crear un BO transaccional, exponerlo como OData, añadir acciones/validaciones/determinaciones o habilitar draft.
  2. Sitúa el contexto: elige managed (RAP gestiona la persistencia, caso habitual) o unmanaged (persistencia legacy propia); decide si necesitas draft.
  3. Aplica la arquitectura: root entity CDS, proyecciones interface/consumption, BDEF con el comportamiento, behavior pool con la lógica, y service definition + binding para publicar.

Capas de un BO RAP

  • Root entity (ZR_...): vista raíz sobre la tabla de persistencia, con campos de auditoría y ETag.
  • Interface projection (ZI_...): contrato transaccional reutilizable (provider contract transactional_interface).
  • Consumption projection (ZC_...): proyección para el consumidor (provider contract transactional_query).
  • Behavior definition (BDEF): qué operaciones y reglas expone el BO.
  • Behavior pool: clase ABAP con la implementación de acciones, validaciones y determinaciones.

Behavior definition (managed)

El BDEF es el contrato declarativo del BO. Define CRUD, campos controlados, acciones, validaciones, determinaciones, autorizaciones y draft.

managed implementation in class zbp_r_travel unique;
strict ( 2 );
define behavior for ZR_Travel alias Travel
persistent table ztravel
draft table ztravel_d
lock master
total etag LastChangedAt
etag master LocalLastChangedAt
authorization master ( instance )
{
  create;
  update;
  delete;

  field ( numbering : managed, readonly ) TravelUuid;
  field ( mandatory )                     AgencyId, CustomerId;
  field ( readonly )                      LastChangedAt, LocalLastChangedAt;

  action ( features : instance ) confirmTravel result [1] $self;

  validation validateDates on save { create; field BeginDate, EndDate; }
  determination calculateTotal on modify { field BookingFee, FlightPrice; }

  side effects { field BookingFee affects field TotalPrice; }

  draft action Resume;
  draft action Edit;
  draft action Activate optimized;
  draft action Discard;
  draft determine action Prepare { validation validateDates; }

  mapping for ztravel { TravelUuid = travel_uuid; AgencyId = agency_id; }
}

Puntos clave: con strict ( 2 ) es obligatorio declarar el tipo de lock; field ( numbering : managed ) genera el UUID automáticamente; los campos de auditoría van readonly; el draft exige total etag y las cuatro draft actions.

Managed vs unmanaged

  • Managed: el framework RAP crea, actualiza y borra en la tabla de persistencia. Es el caso por defecto y el recomendado para desarrollos nuevos.
  • Unmanaged: el desarrollador implementa manualmente la persistencia y el bloqueo (lock master unmanaged). Se usa al envolver lógica legacy existente.

Implementación con EML

La lógica del behavior pool no usa SQL directo: manipula el BO con Entity Manipulation Language. Lectura y modificación en modo local dentro del contexto transaccional (nunca COMMIT/ROLLBACK explícitos).

METHOD confirmTravel.
  READ ENTITIES OF ZR_Travel IN LOCAL MODE
    ENTITY Travel
    ALL FIELDS WITH CORRESPONDING #( keys )
    RESULT DATA(travels)
    FAILED failed.

  MODIFY ENTITIES OF ZR_Travel IN LOCAL MODE
    ENTITY Travel
    UPDATE FIELDS ( OverallStatus )
    WITH VALUE #( FOR t IN travels
                  ( %tky         = t-%tky
                    OverallStatus = 'A' ) ).

  READ ENTITIES OF ZR_Travel IN LOCAL MODE
    ENTITY Travel
    ALL FIELDS WITH CORRESPONDING #( keys )
    RESULT DATA(updated).

  result = VALUE #( FOR t IN updated
                    ( %tky = t-%tky  %param = t ) ).
ENDMETHOD.

Las tablas de trabajo se declaran con TYPE TABLE FOR UPDATE ZR_Travel e incluyen campos técnicos %tky, %key, %pky, %is_draft, %param.

Validaciones, determinaciones y autorizaciones

  • Validación: bloquea el guardado si los datos no son válidos; reporta el error por failed/reported, no con MESSAGE.
  • Determinación: rellena campos automáticamente on save u on modify; esos campos suelen ser readonly.
  • Autorización: global (aplica a toda la entidad) o instance (depende del registro concreto, por ejemplo el centro o sociedad). Genera métodos en el pool a implementar.

Buenas prácticas y errores comunes

  • No accedas a la base de datos con SELECT dentro del pool: usa READ/MODIFY ENTITIES en modo local.
  • No emitas COMMIT WORK ni ROLLBACK: la coherencia transaccional la gestiona RAP.
  • Ordena el BDEF de forma lógica: operaciones, campos, acciones y por último validaciones/determinaciones.
  • Recuerda devolver siempre result en las acciones con result [1] $self, o la UI no reflejará los cambios.
  • Al activar draft, no olvides total etag y las draft actions; sin ellas la app no arranca en modo borrador.

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.