Symptom
You receive the following error message when trying to save or activate an .ABSL script file in your custom solution within the SAP Cloud Applications Studio:
"Identifier 'My_Field' is read-only and cannot be changed" (where My_Field is the name of an element)
“Image/data in this KBA is from SAP internal systems, sample data, or demo systems. Any resemblance to real data is purely coincidental.“
Environment
- SAP Business ByDesign
- SAP Cloud Applications Studio
- SAP Cloud for Customer
Cause
Case 1:
The cause for this issue can be related to the Deployment Unit of the affected business objects.
You can directly access business objects that reside in the Foundation deployment unit from any deployment unit (DU). However, business objects in the Foundation deployment unit cannot access any business object residing in another deployment unit, not even by using asynchronous communication. You can only use a query to read the data of this business object.
In case your script was created on a business object that resides in the Foundation DU, you will not be able to write on elements from a business object that resides on the CustomerRelationshipManagement DU, for example.
For all other deployment units the following applies: You cannot directly change the data of a business object residing in another deployment unit. However, you can read the data of such a business object by using a query, the Retrieve method or an association. To change the data of a business object residing in another deployment unit, use asynchronous, message-based communication.
Case 2:
You are trying to change data in a Validation / ActionValidation script. Validations can only read data and cannot change any values.
Case 3:
You are attempting to write to a persistent field on the AfterLoading event
Resolution
Case 1:
You can assign the business object to another Deployment Unit by making use of the annotation in your BO: [DeploymentUnit(<deployment unit name>)] businessobject <name> {
Example: [DeploymentUnit(Foundation)] businessobject MyCustomBO {
Case 2:
You must move the custom logic to a supported script type such as an Event.
Case 3:
It is only possible to write to a transient field on the AfterLoading event.
From Help documentation: Actions, Events, and Validations | SAP Help Portal
You can implement this event to modify transient fields (only available for business objects) of the current node of a business object. The system executes the AfterLoading event when it reads a node instance of a business object from the data base.
You cannot use an AfterLoading event to do the following:
-
Read and modify a transient field of another node
-
Modify a persistent field
-
Create or delete a node
-
Call an action
Keywords
SDK, PDI, Deployment Unit, validation, XBO, BO, DU , KBA , AP-RC-BDS-SCR , ByDesign Studio Scripting (ABSL) , AP-RC-BDS-BO , ByDesign Studio BO definition/generation , How To