如何将Smartfield连接到odata服务?

时间:2018-07-10 10:01:33

标签: sapui5 cds

我有一个SmartField,我想连接到ODATA服务以免费获得valueHelp
指向ODATA服务的模型如下所示:

"EAMMALFUNCTION": {
    "uri": "/sap/opu/odata/sap/EAM_MALFUNCTION_MANAGE/",
    "type": "sap.ui.model.odata.v2.ODataModel",
    "settings": {
        "defaultOperationMode": "Server",
        "defaultBindingMode": "OneWay",
        "defaultCountMode": "Request"
    },
    "dataSource": "EAM_MALFUNCTION_MANAGE",
    "preload": true
}

实体集的uri为/sap/opu/odata/sap/EAM_MALFUNCTION_MANAGE/I_PMContactCardEmployee,元定义为:

<EntitySet Name="I_PMContactCardEmployee" EntityType="EAM_MALFUNCTION_MANAGE.I_PMContactCardEmployeeType" sap:creatable="false" sap:updatable="false" sap:deletable="false" sap:searchable="true" sap:content-version="1"/>

<EntityType Name="I_PMContactCardEmployeeType" sap:label="Mitarbeiter" sap:content-version="1">
    <Key>
        <PropertyRef Name="PersonnelNumber"/>
    </Key>
    <Property Name="PersonnelNumber" Type="Edm.String" Nullable="false" MaxLength="8" sap:display-format="NonNegative" sap:text="EmployeeFullName" sap:label="Personalnummer"/>
    <Property Name="EmployeeFullName" Type="Edm.String" MaxLength="80" sap:label="Vollständiger Name" sap:filterable="false"/>
    <Property Name="FirstName" Type="Edm.String" MaxLength="40" sap:label="Vorname" sap:quickinfo="Vorname des Geschäftspartners (Person)"/>
    <Property Name="FamilyName" Type="Edm.String" MaxLength="40" sap:label="Nachname" sap:quickinfo="Nachname des Geschäftspartners (Person)"/>
    <Property Name="Job" Type="Edm.String" MaxLength="8" sap:display-format="NonNegative" sap:label="Stellenschlüssel" sap:quickinfo="Stelle" sap:filterable="false"/>
    <Property Name="JobName" Type="Edm.String" MaxLength="25" sap:label="Stellenbezeichnung" sap:filterable="false"/>
    <Property Name="CompanyCode" Type="Edm.String" MaxLength="4" sap:display-format="UpperCase" sap:text="CompanyCodeName" sap:label="Buchungskreis"/>
    <Property Name="CompanyCodeName" Type="Edm.String" MaxLength="25" sap:label="Name der Firma" sap:quickinfo="Buchungskreis- oder Firmen-Bezeichnung" sap:filterable="false"/>
    <Property Name="OrganizationalUnit" Type="Edm.String" MaxLength="8" sap:display-format="NonNegative" sap:label="Organisationseinheit"/>
    <Property Name="OrganizationalUnitName" Type="Edm.String" MaxLength="25" sap:label="OrgEinheitenkurztext" sap:quickinfo="Organisationseinheitenkurztext" sap:filterable="false"/>
    <Property Name="PhoneNumber" Type="Edm.String" MaxLength="30" sap:display-format="UpperCase" sap:label="Telefon" sap:quickinfo="Telefonnummer: Vorwahl+Anschluß" sap:filterable="false"/>
    <Property Name="NormalizedPhoneNumber" Type="Edm.String" MaxLength="30" sap:display-format="UpperCase" sap:label="Telefonnummer" sap:quickinfo="Vollständige Nummer: Vorwahl+Anschluß+Durchwahl" sap:filterable="false"/>
    <Property Name="MobilePhoneNumber" Type="Edm.String" MaxLength="30" sap:display-format="UpperCase" sap:label="Telefon" sap:quickinfo="Telefonnummer: Vorwahl+Anschluß" sap:filterable="false"/>
    <Property Name="MblNormalizedPhoneNumber" Type="Edm.String" MaxLength="30" sap:display-format="UpperCase" sap:label="Telefonnummer" sap:quickinfo="Vollständige Nummer: Vorwahl+Anschluß+Durchwahl" sap:filterable="false"/>
    <Property Name="DefaultEmailAddress" Type="Edm.String" MaxLength="241" sap:label="E-Mail-Adresse"/>
    <Property Name="UserID" Type="Edm.String" MaxLength="12" sap:display-format="UpperCase" sap:label="Benutzer-ID" sap:filterable="false"/>
</EntityType>

提供以下数据:

{
    "d": {
        "results": [
            {
                "__metadata": {
                    "id": "https://example:4000/sap/opu/odata/sap/EAM_MALFUNCTION_MANAGE/I_PMContactCardEmployee('00000019')",
                    "uri": "https://example:4000/sap/opu/odata/sap/EAM_MALFUNCTION_MANAGE/I_PMContactCardEmployee('00000019')",
                    "type": "EAM_MALFUNCTION_MANAGE.I_PMContactCardEmployeeType"
                },
                "PersonnelNumber": "00000019",
                "EmployeeFullName": "Test Normi_20180206",
                "FirstName": "Normi_20180206",
                "FamilyName": "Test",
                "Job": "00000000",
                "JobName": "",
                "CompanyCode": "CH01",
                "CompanyCodeName": "Country Template CH",
                "OrganizationalUnit": "50000066",
                "OrganizationalUnitName": "",
                "PhoneNumber": "",
                "NormalizedPhoneNumber": "",
                "MobilePhoneNumber": "",
                "MblNormalizedPhoneNumber": "",
                "DefaultEmailAddress": "",
                "UserID": ""
            },
            {
                "__metadata": {
                    "id": "https://example:4000/sap/opu/odata/sap/EAM_MALFUNCTION_MANAGE/I_PMContactCardEmployee('00000014')",
                    "uri": "https://example:4000/sap/opu/odata/sap/EAM_MALFUNCTION_MANAGE/I_PMContactCardEmployee('00000014')",
                    "type": "EAM_MALFUNCTION_MANAGE.I_PMContactCardEmployeeType"
                },
                "PersonnelNumber": "00000014",
                "EmployeeFullName": "TEST Einchäuferli",
                "FirstName": "Einchäuferli",
                "FamilyName": "TEST",
                "Job": "00000000",
                "JobName": "",
                "CompanyCode": "CH01",
                "CompanyCodeName": "Country Template CH",
                "OrganizationalUnit": "50000055",
                "OrganizationalUnitName": "",
                "PhoneNumber": "",
                "NormalizedPhoneNumber": "",
                "MobilePhoneNumber": "",
                "MblNormalizedPhoneNumber": "",
                "DefaultEmailAddress": "",
                "UserID": "M4711"
            }, 

我要归档的是,将SmartField与ODATA服务连接,并免费获得valueHelp,而无需任何特定的代码来提供价值帮助。

当我在值帮助中选择一个值时,它应该在<{1}中插入 PersonnelNumber

SmartField是CDS使用情况视图,它提供了搜索帮助的界面:

I_PMContactCardEmployee

我已经尝试通过以下方式将SmartField与@AbapCatalog.sqlViewName: 'IPMCONTCARDEMP' @AbapCatalog.compiler.compareFilter: true @AccessControl.authorizationCheck: #CHECK @VDM.viewType: #COMPOSITE @EndUserText.label: 'Employee' @ObjectModel.representativeKey : 'PersonnelNumber' @Search.searchable: true @ClientHandling.algorithm: #SESSION_VARIABLE @ObjectModel.usageType.dataClass: #MASTER @ObjectModel.usageType.serviceQuality: #D @ObjectModel.usageType.sizeCategory: #L @AccessControl.personalData.blocking: #REQUIRED define view I_PMContactCardEmployee 服务连接:

I_PMContactCardEmployee

,我收到错误消息:

<smartField:SmartLabel labelFor="pmAssignTo" />
<smartfield:SmartField id="pmAssignTo" binding="{EAMMALFUNCTION>/I_PMContactCardEmployee}" value="{PersonnelNumber}">
    <layoutData>
        <layout:GridData span="L7 M7 S12"/>
    </layoutData>
</smartfield:SmartField> 

0 个答案:

没有答案