on 03-12-2021 7:00 AM
Hi Experts!
I am developing Java CAP application on SBAS. I implemented the UI using annotation from the CDS model. I have a list of reports and have navigation to the Object Pages of each row of data.
Here is the structure of the project
admin-service.cds
using cnma.businesspartner as cnma from '../db/schema';
@path:'admin'
service AdminService {
entity BusinessPartners as select from cnma.BusinessPartners;
entity Addresses as projection on cnma.Addresses;
entity Communications as projection on cnma.Communications;
entity CloudPersons as projection on cnma.CloudPersons;
entity PersonBusinessPartnerAssignments as projection on cnma.PersonBusinessPartnerAssignments;
entity Documents as projection on cnma.Documents;
}
// Enable Fiori Draft
annotate AdminService.BusinessPartners with @odata.draft.enabled : true; // open button create and edit with this annotation
annotate AdminService.BusinessPartners with @fiori.draft.enabled : true;
annotate AdminService.Addresses with @fiori.draft.enabled : true;
common.cds
/*
Common Annotations shared by all apps
*/
using { cuid } from '@sap/cds/common';
using {cnma.businesspartner as cnma} from '../db/schema';
// Fiori requires generated IDs to be annotated with @Core.Computed
annotate cuid with {
ID @Core.Computed
}
// Business Partner Object Common
annotate cnma.BusinessPartners with {
description @UI.MultiLineText;
}
annotate cnma.BusinessPartners with @(
UI: {
Identification: [{Value:name}],
SelectionFields: [ ID, sort ],
HeaderInfo: {
TypeName: 'BusinessPartner',
TypeNamePlural: 'BusinessPartners'
},
LineItem: [
{Value: ID},
{Value: name},
{Value: sort},
{Value: homePage},
{Value: duns}
]
}
);
fiori-service.cds (in webapp directory)
using AdminService from '../../srv/admin-service';
using cnma from '../common';
/* Addresses - Communication - Document annotation has remove from here by limit character */
/* Business Partner Object Page */
annotate AdminService.BusinessPartners with @(
UI: {
// List of BusinessPartner
SelectionFields: [ ID, businessPartnerNo, sort ],
LineItem:[
{Value: name , Label:'{i18n>bp.name}'},
{Value: sort, Label:'{i18n>bp.sort}'},
{Value: homePage, Label:'{i18n>bp.homePage}'},
{Value: duns, Label:'{i18n>bp.duns}'},
{Value: bpStatus.name, Label:'{i18n>bpStatus.main}'},
],
// Detail of BusinessPartner
HeaderInfo: {
TypeName: 'BusinessPartner',
TypeNamePlural: 'BusinessPartners',
// Title: {Value: name, Label:'{i18n>bp.name}'},
// Description: {Value: description, Label:'{i18n>bp.description}'},
ImageUrl: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQMdby2azEu5hqNg-AfCniKM3XrYi_UmHCcIQ&usqp=CAU'
},
Facets: [
{$Type: 'UI.ReferenceFacet', Label: '{i18n>GeneralInfo}', Target: '@UI.FieldGroup#GeneralInfo'},
{$Type: 'UI.ReferenceFacet', Label: '{i18n>AdditionalInfo}', Target: '@UI.FieldGroup#AdditionalInfo'},
{$Type: 'UI.ReferenceFacet', Label: '{i18n>Communications}', Target: 'communications/@UI.LineItem'},
{$Type: 'UI.ReferenceFacet', Label: '{i18n>Addresses}', Target: 'addresses/@UI.LineItem'},
{$Type: 'UI.ReferenceFacet', Label: '{i18n>Documents}', Target: 'bpDocuments/@UI.LineItem'},
{$Type: 'UI.ReferenceFacet', Label: '{i18n>ContactPersons}', Target: 'personAssignments/@UI.LineItem'},
{$Type: 'UI.ReferenceFacet', Label: '{i18n>Administrative}', Target: '@UI.FieldGroup#Administrative'},
],
FieldGroup#GeneralInfo: {
Data: [
{Value: name, Label: '{i18n>bp.name}'},
{Value: sort, Label: '{i18n>bp.sort}'},
{Value: businessPartnerNo, Label: '{i18n>bp.businessPartnerNo}'},
{Value: description, Label: '{i18n>bp.description}'},
{Value: homePage, Label: '{i18n>bp.homePage}'},
{Value: duns, Label: '{i18n>bp.duns}'},
{Value: bpStatus_code, Label: '{i18n>bpStatus.code}'},
]
},
FieldGroup#AdditionalInfo: {
Data: [
{Value: founded, Label: '{i18n>founded}'},
{Value: amtEmloyees, Label: '{i18n>amtEmloyees}'},
{Value: turnOver, Label: '{i18n>turnOver}'},
{Value: taxNumber, Label: '{i18n>taxNumber}'},
{Value: vatTaxNumber, Label: '{i18n>vatTaxNumber}'}
]
},
FieldGroup#Administrative: {
Data: [
{Value: createdAt},
{Value: createdBy},
{Value: modifiedAt},
{Value: modifiedBy},
]
}
},
Common: {
SideEffects#Addresses: {
SourceEntities: [
addresses
]
},
SideEffects#Documents: {
SourceEntities: [
bpDocuments
]
},
SideEffects#ContactPersonsChanged: {
SourceEntities: [
personAssignments
]
}
}
);
Component.js
sap.ui.define(["sap/fe/core/AppComponent"],
ac => ac.extend("admin.Component", {
metadata:{ manifest:'json' }
}))
manifest.json
{
"_version": "1.8.0",
"sap.app": {
"id": "admin",
"type": "application",
"title": "{{appTitle}}",
"description": "{{appDescription}}",
"dataSources": {
"AdminService": {
"uri": "/api/admin/",
"type": "OData",
"settings": {
"odataVersion": "4.0"
}
}
},
"-sourceTemplate": {
"id": "ui5template.basicSAPUI5ApplicationProject",
"-id": "ui5template.smartTemplate",
"-version": "1.40.12"
}
},
"sap.ui5": {
"dependencies": {
"libs": {
"sap.fe.templates": {}
}
},
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"uri": "i18n/i18n.properties"
},
"": {
"dataSource": "AdminService",
"settings": {
"synchronizationMode": "None",
"operationMode": "Server",
"autoExpandSelect" : true,
"earlyRequests": true,
"groupProperties": {
"default": {
"submit": "Auto"
}
}
}
}
},
"routing": {
"routes": [
{
"pattern": ":?query:",
"name": "BusinessPartnerList",
"target": "BusinessPartnerList"
},
{
"pattern": "BusinessPartners({key}):?query:",
"name": "BusinessPartnerDetails",
"target": "BusinessPartnerDetails"
},
{
"pattern": "BusinessPartners({boo})/addresses({boo2}):?query:",
"name": "AddressDetails",
"target": "AddressDetails"
},
{
"pattern": "BusinessPartners({boo})/communications({boo2}):?query:",
"name": "CommunicationDetails",
"target": "CommunicationDetails"
},
{
"pattern": "BusinessPartners({boo})/bpDocuments({boo2}):?query:",
"name": "BpDocumentDetails",
"target": "BpDocumentDetails"
},
{
"pattern": "BusinessPartners({boo1})/personAssignments({boo2}):?query:",
"name": "PersonAssignmentDetails",
"target": "PersonAssignmentDetails"
},
{
"pattern": "CloudPersons({key}):?query:",
"name": "CloudPersonDetails",
"target": "CloudPersonDetails"
}
],
"targets": {
"BusinessPartnerList": {
"type": "Component",
"id": "BusinessPartnerList",
"name": "sap.fe.templates.ListReport",
"options": {
"settings" : {
"entitySet" : "BusinessPartners",
"navigation" : {
"BusinessPartners" : {
"detail" : {
"route" : "BusinessPartnerDetails"
}
}
}
}
}
},
"BusinessPartnerDetails": {
"type": "Component",
"id": "BusinessPartnerDetails",
"name": "sap.fe.templates.ObjectPage",
"options": {
"settings": {
"entitySet": "BusinessPartners",
"navigation": {
"addresses":{
"detail": {
"route": "AddressDetails"
}
},
"communications":{
"detail": {
"route": "CommunicationDetails"
}
},
"bpDocuments": {
"detail": {
"route": "BpDocumentDetails"
}
},
"personAssignments":{
"detail": {
"route": "PersonAssignmentDetails"
}
},
"cloudPerson": {
"detail": {
"route": "CloudPersonDetails"
}
}
}
}
}
},
"AddressDetails": {
"type": "Component",
"id": "AddressDetails",
"name": "sap.fe.templates.ObjectPage",
"options": {
"settings": {
"entitySet": "Addresses"
}
}
},
"CommunicationDetails": {
"type": "Component",
"id": "CommunicationDetails",
"name": "sap.fe.templates.ObjectPage",
"options": {
"settings": {
"entitySet": "Communications"
}
}
},
"BpDocumentDetails": {
"type": "Component",
"id": "BpDocumentDetails",
"name": "sap.fe.templates.ObjectPage",
"options": {
"settings": {
"entitySet": "Documents"
}
}
},
"PersonAssignmentDetails": {
"type": "Component",
"id": "PersonAssignmentDetails",
"name": "sap.fe.templates.ObjectPage",
"options": {
"settings": {
"entitySet": "PersonBusinessPartnerAssignments"
}
}
},
"CloudPersonDetails": {
"type": "Component",
"id": "CloudPersonDetails",
"name": "sap.fe.templates.ObjectPage",
"options": {
"settings": {
"entitySet": "CloudPersons"
}
}
}
}
},
"contentDensities": {
"compact": true,
"cozy": true
}
},
"sap.ui": {
"technology": "UI5",
"fullWidth": false
},
"sap.fiori": {
"registrationIds": [],
"archeType": "transactional"
}
}
When running the app, the list report display below
When clicking into a row, I get an error
Here is the console log
It's worth mentioning here: Previously I ran the application completely fine and didn't have any changes in the code, but all of a sudden this error pops up, I'm not sure if this is a CDS or Fiori error, or yes may be due to version. Another strange thing is that when I access the application by phone it works normally!
Any idea, what is missing and how to fix it? Any help would be appreciated (maybe a new missing annotation?).
Best Regards
Hieu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
96 | |
11 | |
11 | |
10 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.