Symptom
- A system dump occurs when creating a child record in a draft-enabled scenario after introducing an alias-based key field approach.
- Dump analysis indicates a duplicate key insert even though no active record exists with the same key combination. Runtime exception: CX_CSP_ACT_INTERNAL.
- The alias key field is not converted to a final key during CONVERT KEY; the final key remains initial, leading to the duplicate insert at save/activation.
Environment
SAP S/4HANA Cloud Public Edition
Reproducing the Issue
- In a RAP draft-enabled application with late numbering and a child entity that uses a key alias bound to a parent key, create a new parent record.
- Edit the parent draft and add a child record.
- Activate the draft (save): a dump occurs indicating a duplicate key insert.
Cause
- In the ADJUST_NUMBERS implementation for the draft-enabled BO with late numbering, the draft values for keys were not read (READ ENTITIES retrieved active data by default).
- %IS_DRAFT was not set to if_abap_behv=>mk-on for reading draft data, resulting in incomplete %TKEY and an initial final key for the alias-bound field.
- Because the alias key value was not converted by CONVERT KEY, CSP attempted to insert with an initial key, causing a duplicate key dump.
Resolution
- In the ADJUST_NUMBERS method of the behavior implementation, read draft data instead of active data:
- Use READ ENTITIES ... with %is_draft = if_abap_behv=>mk-on to retrieve draft values needed for numbering, or
- Select required values directly from the draft table of the entity.
- Ensure the complete %tkey of the child entity is populated in the MAPPED structure, including all primary key fields and the alias-bound key to the parent.
- Verify that temporary keys (%tmp) and %pid are set and that the alias field is converted to the final key during CONVERT KEY before save/activation.
- Retest creating and activating the draft child record to confirm the dump (duplicate key insert) no longer occurs.
Keywords
rap, draft, late numbering, adjust_numbers, %is_draft, if_abap_behv=>mk-on, %tkey, convert key, cx_csp_act_internal, duplicate key, alias key, child entity, save activation, csp, duplicate insert , KBA , BC-ESI-ESF-BSA , Business Service Adaptation , Problem
Product
SAP S/4HANA Cloud Public Edition all versions
SAP Knowledge Base Article - Public