Collection of RAP determination patterns, implementation examples, common pitfalls, and troubleshooting notes gathered from real-world projects.
Basic Numbering
The child entity requires a sequential RecordNumber, which is part of the entity key and defined as NUMC(9). Since RAP early numbering was not suitable for this numbering requirement, the key value was assigned in a determination during creation.
Behavior Definition
managed implementation in class ZBP_FIXXXZ4KOPF unique;
strict ( 2 );
define behavior for ZR_FIXXXZ4KOPF alias Z4Kopf
persistent table zfiXXXz4kopf
etag master LocalLastChangedAt
lock master
authorization master ( global )
{
...
create ( precheck );
update;
delete;
association _Z4Pos { create; }
...
}
define behavior for ZR_FIXXXZ4POS alias Z4Position
persistent table zfiXXXz4pos
lock dependent by _Z4Kopf
authorization dependent by _Z4Kopf
early numbering
{
field ( readonly )
RecordNumber,
CreatedOn,
CreatedAt,
CreatedBy,
ChangedOn,
ChangedAt,
ChangedBy,
ReportedOn,
ReportedAt,
ReportedBy,
LocalCreatedAt,
LocalCreatedBy,
LastChangedAt,
LocalLastChangedAt,
LocalLastChangedBy;
field ( readonly : update )
CompanyCode,
FiscalYear,
FiscalPeriod,
SourceSystem;
update;
delete;
association _Z4Kopf;
determination fillAuditFields on modify { create; }
...
}
Behavior Implementation
CLASS lhc_z4position DEFINITION INHERITING FROM cl_abap_behavior_handler.
PRIVATE SECTION.
METHODS fillAuditFields FOR DETERMINE ON MODIFY
IMPORTING keys FOR Z4Position~fillAuditFields.
ENDCLASS.
CLASS lhc_z4position IMPLEMENTATION.
METHOD fillAuditFields.
MODIFY ENTITIES OF zr_fixxxz4kopf
IN LOCAL MODE
ENTITY Z4Position
UPDATE FIELDS (
RecordNumber
CreatedOn
CreatedAt
CreatedBy )
WITH VALUE #( FOR key IN keys
INDEX INTO idx
( %tky = key-%tky
RecordNumber = idx
CreatedOn = sy-datum
CreatedAt = sy-timlo
CreatedBy = sy-uname ) ).
ENDMETHOD.
ENDCLASS.
