使用 SAP Fiori Tools 部署 SAP UI5 應用到 ABAP 伺服器時遇到的各種錯誤和解決辦法

注销發表於2022-02-20

錯誤1

(node:28340) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'customMiddleware' of undefined
at handleABAP (C:\Code\UI5\Walkthrough\35\node_modules\@sap\ux-ui5-tooling\dist\cli\cmd\add-deploy-config.js:113:29)

錯誤原因:使用的 Fiori tools CLI 版本過低所致。

"@sap/ux-ui5-tooling": "1.0.10"

https://www.npmjs.com/package...

解決辦法:使用最新的 1.4.7 版本:

錯誤訊息2

Error: Cannot find proxy middleware config in [C:\Code\UI5\Walkthrough\35\ui5.yaml]
at f (C:\app\node-v12.18.3-win-x64\node_modules\@sap\generator-fiori\generators\deployment-generator\abap\index.js:2:616172)
at Object.r.handleErrorMessage (C:\app\node-v12.18.3-win-x64\node_modules\@sap\generator-fiori\generators\deployment-generator\abap\index.js:2:616358)

錯誤原因:ui5.yaml 檔案內容不全。

至少應該包含 fiori-tools-proxy 區域。

參考一個格式正確的 ui5.yaml:

specVersion: '1.0'
metadata:
  name: 'project1'
type: application
ui5Theme: sap_fiori_3
server:
  customMiddleware:
  - name: fiori-tools-proxy
    afterMiddleware: compression
    configuration:
      ignoreCertError: false # If set to true, certificate errors will be ignored. E.g. self-signed certificates will be accepted
      backend:
      - path: /sap/opu/odata
        url: http://localhost
      ui5:
        path: 
        - /resources
        - /test-resources
        url: https://ui5.sap.com
        version:  # The UI5 version, for instance, 1.78.1. Empty means latest version
  - name: fiori-tools-appreload
    afterMiddleware: compression
    configuration:
     port: 35729
     path: webapp

錯誤訊息3

info builder:custom deploy-to-abap Create Archive
info builder:custom deploy-to-abap Starting Deployment.on project1 � (11/11) Running task deploy-to-abap...
WARN builder:custom deploy-to-abap Connecting without any credentials, deployment may fail if authorization is required
ERR! builder:custom deploy-to-abap Deployment Failed.tion project1 � (11/11) Running task deploy-to-abap...
ERR! builder:custom deploy-to-abap getaddrinfo ENOTFOUND aa

原因是 ui5-deploy.yaml 檔案中 deploy-to-abap 這個自定義 task 的 target, 即遠端 ABAP 系統的 url 維護不正確。

如果看到上圖所示的提示訊息:

The deployment destination requires authentication. Please enter your credentials below
? Username:

說明 ABAP 系統連線成功。

錯誤訊息4

Upload canceled, archive could not be read or appears to be empty

錯誤訊息和這個帖子介紹的一致。

這個錯誤和 SAP UI5 tools 的版本有關。

使用 generator-easy-ui5 建立的 SAP UI5 專案,SAP UI5 tools 的預設版本號如下圖所示:

"devDependencies": {
        "@ui5/cli": "^2.11.1",
        "@ui5/fs": "^2.0.6",
        "@ui5/logger": "^2.0.1",
        "@sap/ux-ui5-tooling": "1",
        "rimraf": "3.0.2"
    },
    "ui5": {
        "dependencies": [
            "@sap/ux-ui5-tooling"
        ]
    }

解決方案:刪除 package-lock.json 檔案和 node_modules 資料夾,

執行命令列安裝最新版本:

npm install @sap/ux-ui5-tooling@latest

成功安裝的版本號:1.4.7

package.json 檔案裡的 deploy 指令碼命令更改為:

npm run build && fiori deploy --config ui5-deploy.yaml

重新執行 npm run deploy 即可:

錯誤訊息5

Remote creation in customer namespace not possible in SAP systems

解決辦法是,提前在 ABAP 系統 ER9 手動建立好 BSP 應用即可:


另一種方法,參考這個連結

更多Jerry的原創文章,盡在:"汪子熙":

相關文章