Skip to Content
0
Nov 11, 2022 at 01:53 PM

Association is read only

189 Views

Hi,

I am having a problem with an association. I have created a business object which I have embedded in an extension of the standard Material business object. In this business object I have a node called Items which I want to associate with the Material business object. I am trying to do this association in the event AfterModify. However I am receiving an error "13 Identifier 'toItems' is read-only and cannot be changed". May someone tell me what the problem is and how it may be solved? Enclosed is the code I am using.

import AP.Common.GDT as apCommonGDT; 
import AP.FO.ProductDataMaintenance.Global;
import AP.PDI.bo;

businessobject ZBarcode {

		[AlternativeKey] element id : ID;
		element materialId : UUID;

		association toMaterial to Material;
						
		node Items [0,n] {
			element description : SHORT_Description;
			element barCode: Code; //not in use
			element newBarCode: String;
			element attachToMaterialId: UUID;

			association toItems to Material;
		}
}

//Event-AfterModify.absl

import ABSL;
import AP.FO.ProductDataMaintenance.Global; 

if (!this.materialId.IsInitial()) {
	var instMaterial = Material.Retrieve(this.materialId);
	//var testMaterial = Material.query;

	if (instMaterial.IsSet()) {
		this.toMaterial = instMaterial;

		if (this.toMaterial.IsSet()) {
			this.Items.toItems = instMaterial;
		}