供應商和工廠天氣風險洞察

這項用量資料產品範例示範如何將零複製 SAP Business Data Cloud (SAP BDC) 採購和進貨交貨共用資料,與透過 BigQuery 共用訂閱的 Google WeatherNext 3 集合天氣預報資料結合。這項解決方案不需要商業航運遙測訂閱,既可做為獨立的設施間天氣風險加速器,也是供應商入庫交貨天氣風險洞察的基礎模組。

這個範例可讓您:

  • 追蹤未結入庫交貨支出,以及供應商、工廠和重要物料類型的風險值。
  • 根據預先封裝的城市地理空間目錄,對實體出貨地 (使用多步驟 SAP 出貨地瀑布) 和收貨工廠進行地理編碼。
  • 在可設定的空間半徑 (預設為 25 公里) 內,疊加 72 小時、0.1 度的 WeatherNext 3 集合預測,預測 P50 和 P90 到達日期,並標記天氣引起的時程差異。

參考架構

高階參考架構會概略說明,為這個用途提供資料所需的來源特定資料產品。

Cortex Framework 的供應商和工廠天氣風險洞察消費資料產品範例參考架構

圖 1:Cortex Framework 的供應商和工廠天氣風險洞察資訊用量資料產品範例參考架構。

已發布的資料資產

部署 cortex_samples.sap_bdc.products.supplier_plant_weather_risk_insights 後,系統會在目標資料集中建立下列 BigQuery 資料表和檢視表:

資料資產 實體化 主鍵精細程度 說明
inbound_delivery_insights Table delivery_document、delivery_document_item 整合進貨交貨項目主幹,使用多步驟 SAP 瀑布式模型 (手動覆寫訂購單標頭地址 ADRNR、貨物供應商 LLIEF、供應工廠 RESWK 和供應商主檔 LIFNR),解析實體出貨來源、按比例分配的淨訂單價值、歷史準時交貨 (OTIF) 標記,以及供應商到工廠的前置時間和波動基準。
supplier_plant_weather_risk_insights View delivery_document、delivery_document_item 在消耗量檢視畫面中,疊加 72 小時 WeatherNext 3 降水、風勢、溫度和集合預報,並顯示在調度來源和接收 SAP 工廠,以便分類天氣暴露層級,並預測調整後的到貨日期。
world_city_directory Table city_id 全球和美國城市的參考資料表,包含標準化 WGS84 座標和預先計算的 BigQuery GEOGRAPHY 點 (city_geom),可用於空間彙整。

必要的外部目錄來源

啟用這個範例前,請先設定下列外部目錄來源:

  • SAP Business Data Cloud (lakehouse_delta_share):匯入共用項目,公開訂購單 (purchaseorder)、供應商 (supplier)、工廠 (plant)、地址 (address)、產品 (product)、公司 (company)、進貨交貨標頭 (delivery_header) 和進貨交貨項目 (delivery_item)。如需設定操作說明,請參閱「SAP Business Data Cloud 整合」。
  • Google WeatherNext 3 (analytics_hub):在 BigQuery sharing 中訂閱 Google WeatherNext 3 資訊,並將預測資料表 (例如 weathernext_3_0_0) 納入 analytics_hub 目錄模組的 inlineTableSettings.tables。如需設定操作說明,請參閱「BigQuery sharing 整合」。

在 config/config.yaml 啟用資料產品

在 data.modules.catalogs 下註冊 SAP BDC 和 Google WeatherNext 目錄,然後在 data.modules.products 下啟用 cortex_samples.sap_bdc.products.supplier_plant_weather_risk_insights:

data:
  namespaces:
    - name: cortex
    - name: cortex_samples

  modules:
    catalogs:
      # SAP Business Data Cloud Delta Sharing catalog.
      - id: sap_bdc_catalog
        type: lakehouse_delta_share
        bindsNamespaces: [sap_bdc]
        connectionSettings:
          catalogId: sap_bdc_catalog
          projectId: SAP_BDC_CATALOG_PROJECT_ID
          location: US
          shares:
            - shareId: PURCHASE_ORDER_SHARE_ID
            - shareId: SUPPLIER_SHARE_ID
            - shareId: PLANT_SHARE_ID
            - shareId: ADDRESS_SHARE_ID
            - shareId: PRODUCT_SHARE_ID
            - shareId: COMPANY_SHARE_ID
            - shareId: DELIVERY_HEADER_SHARE_ID
            - shareId: DELIVERY_ITEM_SHARE_ID

      # Google WeatherNext 3 linked dataset subscribed from BigQuery sharing.
      - id: ah_weathernext_catalog
        type: analytics_hub
        bindsNamespaces: [cortex.external.weathernext]
        connectionSettings:
          projectId: LINKED_DATASET_PROJECT_ID
          datasetId: WEATHERNEXT_DATASET_ID
          location: US
        inlineTableSettings:
          tables:
            - weathernext_3_0_0

    products:
      # Enabled Supplier & Plant Weather Risk Insights sample.
      - moduleId: supplier_plant_weather_risk_insights
        enabled: true
        modulePath: cortex_samples.sap_bdc.products.supplier_plant_weather_risk_insights
        dataTargetId: samples_target
        dependencyBindings:
          sapBdcPurchaseOrder: sap_bdc_catalog.purchaseorder
          sapBdcSupplier: sap_bdc_catalog.supplier
          sapBdcPlant: sap_bdc_catalog.plant
          sapBdcAddress: sap_bdc_catalog.address
          sapBdcProduct: sap_bdc_catalog.product
          sapBdcCompany: sap_bdc_catalog.company
          sapBdcDeliveryHeader: sap_bdc_catalog.delivery_header
          sapBdcDeliveryItem: sap_bdc_catalog.delivery_item
          weatherNext: ah_weathernext_catalog.weathernext_3_0_0
        inlineTableSettings:
          supplier_plant_weather_risk_insights:
            filters:
              critical_material_types: ["ROH", "RAW", "HALB"]
              weather_thresholds:
                forecast_horizon_hours: 72
                spatial_radius_meters: 25000

更改下列內容:

  • SAP_BDC_CATALOG_PROJECT_ID:託管 BigLake Delta Sharing 目錄的 Google Cloud 專案 ID,例如:my-sap-bdc-project。
  • PURCHASE_ORDER_SHARE_ID:從 SAP BDC 匯入的訂購單實體 Delta Sharing 共用 ID,例如 purchaseorder。
  • SUPPLIER_SHARE_ID:從 SAP BDC 匯入的供應商實體 Delta Sharing 共用 ID,例如 supplier。
  • PLANT_SHARE_ID:從 SAP BDC 匯入的工廠實體 Delta Sharing 共用項目 ID,例如 plant。
  • ADDRESS_SHARE_ID:從 SAP BDC 匯入的實體 Delta Sharing 共用 ID,用於位址,例如 address。
  • PRODUCT_SHARE_ID:從 SAP BDC 匯入的產品實體 Delta Sharing 共用 ID,例如 product。
  • COMPANY_SHARE_ID:從 SAP BDC for Company 匯入的實體 Delta Sharing 共用 ID,例如 company。
  • DELIVERY_HEADER_SHARE_ID:從 SAP BDC 匯入的實體 Delta Sharing 共用 ID,用於入庫交貨標頭,例如:delivery_header。
  • DELIVERY_ITEM_SHARE_ID:從 SAP BDC 匯入的入庫交貨項目實體 Delta Sharing 共用 ID,例如:delivery_item。
  • LINKED_DATASET_PROJECT_ID:託管已訂閱 WeatherNext 連結資料集的 Google Cloud 專案 ID,例如:my-cortex-project。
  • WEATHERNEXT_DATASET_ID:訂閱的 WeatherNext 3 資訊清單 BigQuery 資料集 ID,例如:google_weathernext_3。

您可以在 inlineTableSettings 或 tableSettings 檔案中,進一步自訂各項資產 filters 區塊下的 SAP 用戶端和交貨篩選器 (inbound_delivery_insights 上的 sap_client、inbound_delivery_categories_vbtyp 和 ocean_incoterms)、重要物料類型 (critical_material_types)、時程差異緩衝區 (schedule_variance_thresholds) 和惡劣天氣截止時間 (weather_thresholds)。如需可調整門檻和預設值的完整清單,請參閱 src/data_modules/cortex_samples/sap_bdc/products/supplier_plant_weather_risk_insights/table_settings.default.yaml。

建構及部署設定好的範例:

export CORTEX_CONFIG_FILE=config/config.yaml
uv run cortex-build-and-deploy --config $CORTEX_CONFIG_FILE

實體關係圖

您可以在模組的 README.md 中查看實體關係圖,或使用 uv run cortex-metadata erd 從編譯的工作區生成:

export CORTEX_CONFIG_FILE=config/config.yaml
uv run cortex-metadata erd \
  --config $CORTEX_CONFIG_FILE \
  --module-id supplier_plant_weather_risk_insights

原始碼

在 src/data_modules/cortex_samples/sap_bdc/products/supplier_plant_weather_risk_insights 存放區中,探索 SQL 模型、manifest.yaml 和註解。

啟用 AI 代理

在 BigQuery 中具體化 inbound_delivery_insights 和 supplier_plant_weather_risk_insights 後,您可以使用 uv run cortex-create-ca-agents 佈建自然語言資料代理,或直接在 BigQuery Studio 中建構自訂資料代理 (建立資料代理),詢問有關受天氣影響的配送、延遲供應商和有風險的工廠支出等問題。

後續步驟