Код: Выделить всё
entity ComplaintTypeConfigurations : cuid, managed {
identifier : DataType.Identifier;
complaintCategory : ComplaintCategory;
code : DataType.Code;
description : localized DataType.Description;
individualComplaintType : DataType.Flag default false;
itemCategory : ItemCategory;
complaintTypeToSalesAreaMappings : Composition of many ComplaintTypeToSalesAreaMappings
on complaintTypeToSalesAreaMappings.complaintTypeConfiguration = $self;
numberRange : NumberRange; //deprecated
isActive : Boolean default true;
currentNumber : DataType.CurrentNumber; //deprecated
}
Код: Выделить всё
entity ComplaintTypeToSalesAreaMappings : cuid, managed {
salesOrganization : SalesOrganization;
distributionChannel : DistributionChannel;
division : Division;
complaintTypeConfiguration : ComplaintTypeConfiguration;
}
Код: Выделить всё
Predicate predicateSalesArea = CQL.get(ComplaintTypeToSalesAreaMappings.SALES_ORGANIZATION_ID).eq(salesOrganization)
.and(CQL.get(ComplaintTypeToSalesAreaMappings.DISTRIBUTION_CHANNEL_ID).isNull()
.and(CQL.get(ComplaintTypeToSalesAreaMappings.DIVISION_ID).isNull()))
.or(CQL.get(ComplaintTypeToSalesAreaMappings.SALES_ORGANIZATION_ID).eq(salesOrganization)
.and(CQL.get(ComplaintTypeToSalesAreaMappings.DISTRIBUTION_CHANNEL_ID).eq(distributionChannel)
.and(CQL.get(ComplaintTypeToSalesAreaMappings.DIVISION_ID).isNull())))
.or(CQL.get(ComplaintTypeToSalesAreaMappings.SALES_ORGANIZATION_ID).eq(salesOrganization)
.and(CQL.get(ComplaintTypeToSalesAreaMappings.DISTRIBUTION_CHANNEL_ID).eq(distributionChannel)
.and(CQL.get(ComplaintTypeToSalesAreaMappings.DIVISION_ID).eq(division))));
Predicate predicate = CQL.get(ComplaintTypeConfigurations.IS_ACTIVE).eq(true)
.and(CQL.get(ComplaintTypeConfigurations.COMPLAINT_CATEGORY_CODE).eq(complaintCategoryCode))
.and(CQL.get(ComplaintTypeConfigurations.COMPLAINT_TYPE_TO_SALES_AREA_MAPPINGS).isNull()).or(predicateSalesArea);
if(code!=null || description!=null) {
predicate.and(CQL.get(ComplaintTypeConfigurations.CODE).contains(code).and(CQL.get(ComplaintTypeConfigurations.DESCRIPTION).contains(description)));
}
CqnSelect select=Select.from(ComplaintTypeConfigurations_.class)
.columns(a->a.ID(),b->b.code(),c->c.description(),
e->e.complaintTypeToSalesAreaMappings().salesOrganization_ID(),
f->f.complaintTypeToSalesAreaMappings().distributionChannel_ID(),
g->g.complaintTypeToSalesAreaMappings().division_ID(),
h->h.individualComplaintType(),
i->i.itemCategory_ID()).where(predicate);
filteredResult=db.run(select);
Код: Выделить всё
No element with name 'salesOrganization_ID' in 'CustomerConfigurationService.ComplaintTypeConfigurations' (service 'PersistenceService$Default', event 'READ', entity 'CustomerConfigurationService.ComplaintTypeConfigurations')
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.ComplaintTypeConfigurationDao.getAllComplaintsWithWildCharacter(ComplaintTypeConfigurationDao.java:179) ~[classes/:na]
at jdk.internal.reflect.GeneratedMethodAccessor33.invoke(Unknown Source) ~[na:na]
Может кто-нибудь помочь мне здесь?
Однако я могу добиться этого, используя запрос CQN, как показано ниже.
Код: Выделить всё
filteredResult = db
.run(Select.from(ComplaintTypeConfigurations_.class)
.columns(a->a.ID(),b->b.code(),c->c.description(),
e->e.complaintTypeToSalesAreaMappings().salesOrganization_ID(),
f->f.complaintTypeToSalesAreaMappings().distributionChannel_ID(),
g->g.complaintTypeToSalesAreaMappings().division_ID(),
h->h.individualComplaintType(),
i->i.itemCategory_ID())
.where(d->d.isActive().eq(true).and(d.complaintCategory_code().eq(complaintCategoryCode).and(d.code().contains(code).or(d.description().contains(description))).and(not(d.complaintTypeToSalesAreaMappings().exists())
.or(d.complaintTypeToSalesAreaMappings().salesOrganization_ID().eq(salesOrganization)
.and(d.complaintTypeToSalesAreaMappings().distributionChannel_ID().isNull()
.and(d.complaintTypeToSalesAreaMappings().division_ID().isNull())))
.or(d.complaintTypeToSalesAreaMappings().salesOrganization_ID().eq(salesOrganization)
.and(d.complaintTypeToSalesAreaMappings().distributionChannel_ID().eq(distributionChannel)
.and(d.complaintTypeToSalesAreaMappings().division_ID().isNull())))
.or(d.complaintTypeToSalesAreaMappings().salesOrganization_ID().eq(salesOrganization)
.and(d.complaintTypeToSalesAreaMappings().distributionChannel_ID().eq(distributionChannel)
.and(d.complaintTypeToSalesAreaMappings().division_ID().eq(division))))))));
Подробнее здесь: https://stackoverflow.com/questions/789 ... p-cds-ql-p