Code: Select all
entity ProtestTypeConfigurations : cuid, managed {
finder : DataType.finder;
protestCategory : ProtestCategory;
code : DataType.Code;
description : localized DataType.Description;
individualProtestType : DataType.Flag default false;
malCategory : MalCategory;protestTypeToMarAreaMappings
protestTypeToMarAreaMappings : Composition of many protestTypeToMarAreaMappings
on ProtestTypeToMarAreaMappings.protestTypeConfiguration = $self;
isActive : Boolean default true;
}
}
Code: Select all
entity protestTypeToMarAreaMappings : cuid, managed {
salesOrganization : SalesOrganization;
distributionChannel : DistributionChannel;
division : Division;
protestTypeConfiguration : ProtestTypeConfiguration;
}
Predicate predicateSalesArea = CQL.get(ProtestTypeToMarAreaMappings.SALES_ORGANIZATION_ID).eq(salesOrganization)
.and(CQL.get(ProtestTypeToMarAreaMappings.DISTRIBUTION_CHANNEL_ID).isNull()
.and(CQL.get(ProtestTypeToMarAreaMappings.DIVISION_ID).isNull()))
.or(CQL.get(ProtestTypeToMarAreaMappings.SALES_ORGANIZATION_ID).eq(salesOrganization)
.and(CQL.get(ProtestTypeToMarAreaMappings.DISTRIBUTION_CHANNEL_ID).eq(distributionChannel)
.and(CQL.get(ProtestTypeToMarAreaMappings.DIVISION_ID).isNull())))
.or(CQL.get(ProtestTypeToMarAreaMappings.SALES_ORGANIZATION_ID).eq(salesOrganization)
.and(CQL.get(ProtestTypeToMarAreaMappings.DISTRIBUTION_CHANNEL_ID).eq(distributionChannel)
.and(CQL.get(ProtestTypeToMarAreaMappings.DIVISION_ID).eq(division))));
Predicate predicate = CQL.get(ProtestTypeConfigurations.IS_ACTIVE).eq(true)
.and(CQL.get(ProtestTypeConfigurations.PROTEST_CATEGORY_CODE).eq(protestCategoryCode))
.and(CQL.get(ProtestTypeConfigurations.PROTEST_TYPE_TO_SALES_AREA_MAPPINGS).isNull()).or(predicateSalesArea);
if(code!=null || description!=null) {
predicate.and(CQL.get(ProtestTypeConfigurations.CODE).contains(code).and(CQL.get(ProtestTypeConfigurations.DESCRIPTION).contains(description)));
}
CqnSelect select=Select.from(ProtestTypeConfigurations_.class)
.columns(a->a.ID(),b->b.code(),c->c.description(),
e->e.protestTypeToMarAreaMappings().salesOrganization_ID(),
f->f.protestTypeToMarAreaMappings().distributionChannel_ID(),
g->g.protestTypeToMarAreaMappings().division_ID(),
h->h.individualProtestType(),
i->i.malCategory_ID()).where(predicate);
filteredResult=db.run(select);
< /code>
Wenn ich diese Abfrage ausführe, erhalte ich einen Fehler wie unten. < /p>
No element with name 'salesOrganization_ID' in 'CustomerConfigurationService.ProtestTypeConfigurations' (service 'PersistenceService$Default', event 'READ', entity 'CustomerConfigurationService.ProtestTypeConfigurations')
at com.sap.cds.services.impl.ServiceImpl.dispatch(ServiceImpl.java:256) ~[cds-services-impl-2.10.1.jar:na]
at com.sap.cds.services.impl.ServiceImpl.emit(ServiceImpl.java:177) ~[cds-services-impl-2.10.1.jar:na]
at com.sap.cds.services.ServiceDelegator.emit(ServiceDelegator.java:33) ~[cds-services-api-2.10.1.jar:na]
at com.sap.cds.services.utils.services.AbstractCqnService.run(AbstractCqnService.java:53) ~[cds-services-utils-2.10.1.jar:na]
at com.sap.cds.services.utils.services.AbstractCqnService.run(AbstractCqnService.java:43) ~[cds-services-utils-2.10.1.jar:na]
at com.sap.ic.cmh.configuration.persistency.ProtestTypeConfigurationDao.getAllComplaintsWithWildCharacter(ProtestTypeConfigurationDao.java:179) ~[classes/:na]
at jdk.internal.reflect.GeneratedMethodAccessor33.invoke(Unknown Source) ~[na:na]
< /code>
Ich kann die Felder der Verbundentität nicht abrufen. Wie kann ich dies mit Prädikaten erreichen. filteredResult = db
.run(Select.from(ProtestTypeConfigurations_.class)
.columns(a->a.ID(),b->b.code(),c->c.description(),
e->e.protestTypeToSalesAreaMappings().salesOrganization_ID(),
f->f.protestTypeToSalesAreaMappings().distributionChannel_ID(),
g->g.protestTypeToSalesAreaMappings().division_ID(),
h->h.individualComplaintType(),
i->i.itemCategory_ID())
.where(d->d.isActive().eq(true).and(d.protestCategory_code().eq(protestCategoryCode).and(d.code().contains(code).or(d.description().contains(description))).and(not(d.protestTypeToSalesAreaMappings().exists())
.or(d.protestTypeToSalesAreaMappings().salesOrganization_ID().eq(salesOrganization)
.and(d.protestTypeToSalesAreaMappings().distributionChannel_ID().isNull()
.and(d.protestTypeToSalesAreaMappings().division_ID().isNull())))
.or(d.protestTypeToSalesAreaMappings().salesOrganization_ID().eq(salesOrganization)
.and(d.protestTypeToSalesAreaMappings().distributionChannel_ID().eq(distributionChannel)
.and(d.protestTypeToSalesAreaMappings().division_ID().isNull())))
.or(d.protestTypeToSalesAreaMappings().salesOrganization_ID().eq(salesOrganization)
.and(d.protestTypeToSalesAreaMappings().distributionChannel_ID().eq(distributionChannel)
.and(d.protestTypeToSalesAreaMappings().division_ID().eq(division))))))));
< /code>
Aber für mein Szenario müsste ich die Abfrage gemäß bestimmten Bedingungen ändern, weshalb ich die obige Abfrage verwendet habe, wenn ich mehrfach mit fast gleicher Abfrage mit geringfügiger Änderung der Felder blockiert werde. Daher haben wir uns für Prädikate entschieden. Aber wir können dies nicht erreichen.