/* TARGET OBJECT : data definition ZR_CHANGEAPPROVAL (root view entity) - README step U5, UI leg abap: URI : abap:/repotree-v1/0M7DEJI/System%20Library/ZLOCAL/ZARENA_PLM/Core%20Data%20Services/Data%20Definitions/ZR_CHANGEAPPROVAL/zr_changeapproval.ddls.acds ACTION : create empty via ADT MCP (objectType DDLS/DF, README U5), replace entire content, save, then activate (table ZCHANGEAPPROVAL must be active first). Notes: StatusText / StatusCriticality / IsApprovable / IsRetriable are derived from Status with CASE expressions here, because a transactional_query projection list may only contain elements of the projected entity, path expressions, associations and virtual elements - no expressions [source: abap-docs /abap-docs-cloud/ABENCDS_DEFINE_VIEW_AS_PROJECTION, verified 2026-09-15]. CASE syntax [source: abap-docs /abap-docs-cloud/ABENCDS_CASE_EXPRESSION_V2, verified 2026-09-15]; cast of a case distinction to a data element (abap_boolean, released) [source: abap-docs /abap-docs-cloud/ABENCDS_CAST_EXPRESSION_V2, verified 2026-09-16]. @ObjectModel.text.element [source: abap-docs /abap-fiori-showcase/06_object_page_content#displaying-text-instead-of-id, verified 2026-09-15]. @Semantics admin-field annotations [source: abap-docs /abap-platform-rap-opensap/week2/unit3#step-1-create-the-interface-cds-view-for-the-travel-entity, verified 2026-09-15]. Criticality values 2/2/5/3/1/1 per PRD RAP-1. ABAP_BOOLEAN is released [source: sap-released-objects DTEL ABAP_BOOLEAN public_cloud level A, verified 2026-09-16]. Result types of the CASE expressions: - A CASE result gets the maximum technical data type of all THEN and ELSE branches, and keeps a data element only if every branch with that type carries the same one [source: abap-docs /abap-docs-cloud/ABENCDS_CASE_EXPRESSION_V2, verified 2026-09-16]. StatusText is therefore CHAR as long as its longest literal (29), not Status's CHAR(10). - IsApprovable / IsRetriable cast the WHOLE case distinction to abap_boolean once. Casting inside the branches does not work: a cast to a data element passes on its semantics, "An exception to this is the use of the CAST expression within a case distinction" [source: abap-docs /abap-docs-cloud/ABENCDS_CAST_EXPRESSION_V2, verified 2026-09-16]. - The branches use typed literals abap.char'X' / abap.char' ': length is "derived from the literal value" and "the type length includes the trimmed trailing blanks", so both are CHAR(1) and the CASE result is CHAR(1) [source: abap-docs /abap-docs-cloud/ABENCDS_TYPED_LITERAL_V2, verified 2026-09-16]. (Untyped 'X' would not prove it: its DB length is only "at least as large as" the literal [source: abap-docs /abap-docs-cloud/ABENCDS_UNTYPED_LITERAL_V2, verified 2026-09-16].) - PRESERVING TYPE needs the operand's built-in type and length to match the data element exactly [source: abap-docs /abap-docs-cloud/ABENCDS_CAST_EXPRESSION_V2, verified 2026-09-16]. ABAP_BOOLEAN is "of data type CHAR of length 1" [source: abap-docs /abap-docs-standard/ABENDATAOBJECTS_TRUE_VALUE_GUIDL, verified 2026-09-16], so the types match. If activation rejects the cast anyway, delete "preserving type": a plain cast still inherits the data element's semantics, and a same-type warning "can be ignored" [source: abap-docs /abap-docs-cloud/ABENCDS_CAST_EXPRESSION_V2, verified 2026-09-16]. - An untyped integer literal is INT1, INT2, INT4 or INT8 depending on its value [source: abap-docs /abap-docs-cloud/ABENCDS_UNTYPED_LITERAL_V2, verified 2026-09-16], so StatusCriticality (0..5) is expected INT1. Open (UNVERIFIED 2026-09-16 - no doc found): the OData EDM types the UI binding emits for INT1 (app expects Edm.Byte), ABAP_BOOLEAN (app expects Edm.Boolean) and UTCLONG (app expects Edm.DateTimeOffset Precision 7). Read them from the live $metadata after publishing (README step U15); do not change this source without a cited rule. */ @AccessControl.authorizationCheck: #CHECK @EndUserText.label: 'Arena change approval' define root view entity ZR_CHANGEAPPROVAL as select from zchangeapproval { key id as ID, item_number as ItemNumber, item_name as ItemName, change_type as ChangeType, arena_eco_id as ArenaEcoId, @ObjectModel.text.element: ['StatusText'] status as Status, case status when 'PENDING' then 'Pending approval' when 'APPROVED' then 'Approved - awaiting execution' when 'EXECUTING' then 'Executing in SAP' when 'SYNCED' then 'Synced to SAP' when 'REJECTED' then 'Rejected' when 'FAILED' then 'Execution failed' else status end as StatusText, case status when 'PENDING' then 2 when 'APPROVED' then 2 when 'EXECUTING' then 5 when 'SYNCED' then 3 when 'REJECTED' then 1 when 'FAILED' then 1 else 0 end as StatusCriticality, requested_by as RequestedBy, requested_on as RequestedOn, decided_by as DecidedBy, decided_on as DecidedOn, sap_change_number as SapChangeNumber, error_message as ErrorMessage, reject_reason as RejectReason, sap_preview as SapPreview, cast( case status when 'PENDING' then abap.char'X' else abap.char' ' end as abap_boolean preserving type ) as IsApprovable, cast( case status when 'FAILED' then abap.char'X' else abap.char' ' end as abap_boolean preserving type ) as IsRetriable, @Semantics.user.createdBy: true created_by as CreatedBy, @Semantics.systemDateTime.createdAt: true created_at as CreatedAt, @Semantics.user.lastChangedBy: true last_changed_by as LastChangedBy, @Semantics.systemDateTime.lastChangedAt: true last_changed_at as LastChangedAt, @Semantics.systemDateTime.localInstanceLastChangedAt: true local_last_changed_at as LocalLastChangedAt }