Skip to content

feat(sap_s4hana): add get_material_document and fix supplier invoice key order#4317

Merged
waleedlatif1 merged 3 commits intostagingfrom
waleedlatif1/chennai-v1
Apr 28, 2026
Merged

feat(sap_s4hana): add get_material_document and fix supplier invoice key order#4317
waleedlatif1 merged 3 commits intostagingfrom
waleedlatif1/chennai-v1

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • Add get_material_document tool to fetch a single A_MaterialDocumentHeader by composite key (MaterialDocumentYear + MaterialDocument)
  • Reorder get_supplier_invoice composite key to alphabetic order (FiscalYear, SupplierInvoice)
  • Wire new tool into types, index, registry, and block (dropdown, subBlocks, conditions, switch case, inputs)

Type of Change

  • New feature

Testing

Tested manually. Lint and typecheck clean.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

waleedlatif1 and others added 2 commits April 27, 2026 20:03
Why: SAP A_PurchaseOrder POST silently fails or returns opaque errors
without to_PurchaseOrderItem entries. Block already required this body
but the tool marked it optional and didn't validate items presence —
mismatched contract with create_sales_order / create_purchase_requisition.

Also clarifies the deliveryDocument placeholder to show both outbound
and inbound number ranges.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…key order

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Apr 28, 2026 6:31am

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 28, 2026

PR Summary

Medium Risk
Mostly additive, but it changes runtime behavior for purchase order creation (new required parameter and stricter validation) and adjusts supplier-invoice key formatting, which could break existing workflows relying on the previous behavior.

Overview
Adds sap_s4hana_get_material_document to retrieve a single A_MaterialDocumentHeader by (MaterialDocument, MaterialDocumentYear), wiring it through the SAP S/4HANA tool exports, registry, block UI inputs, and integration metadata.

Tightens sap_s4hana_create_purchase_order by making body required and validating it contains a non-empty to_PurchaseOrderItem array, and fixes sap_s4hana_get_supplier_invoice by reordering the composite key in the OData path to FiscalYear, SupplierInvoice.

Updates docs/metadata: SAP docs now include the new material document GET tool and mark PO body as required; Slack docs and integration metadata add canvas operations (get, list, lookup sections, delete) and bump operation counts accordingly.

Reviewed by Cursor Bugbot for commit 5be41b7. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 28, 2026

Greptile Summary

This PR adds a sap_s4hana_get_material_document tool to fetch a single A_MaterialDocumentHeader by composite key, fixes the get_supplier_invoice OData key ordering to alphabetical (FiscalYear, SupplierInvoice), and makes the create_purchase_order body parameter required with runtime validation for a non-empty to_PurchaseOrderItem array. All integration points (types, index, registry, block dropdown/subBlocks/switch/inputs) are correctly wired. The PR also bundles documentation additions for four Slack canvas tools — these are documentation-only and carry no code risk.

Confidence Score: 5/5

This PR is safe to merge — no logic errors, security concerns, or breaking regressions identified.

All changes are consistent and well-scoped: the new tool follows the established pattern exactly, the key-order fix is safe under OData v2 named-predicate semantics, and the body validation is correct. No P0 or P1 findings.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/tools/sap_s4hana/get_material_document.ts New tool implementing get-by-composite-key for A_MaterialDocumentHeader; OData path key order (MaterialDocument, MaterialDocumentYear) is alphabetically correct and matches description.
apps/sim/tools/sap_s4hana/get_supplier_invoice.ts Key order in OData path corrected to alphabetical (FiscalYear, SupplierInvoice); OData v2 named predicates are order-independent so this is safe.
apps/sim/tools/sap_s4hana/create_purchase_order.ts body parameter changed from optional to required with runtime validation for non-empty to_PurchaseOrderItem; validation logic is correct.
apps/sim/tools/sap_s4hana/types.ts Added GetMaterialDocumentParams interface; made body non-optional in CreatePurchaseOrderParams to match runtime enforcement.
apps/sim/blocks/blocks/sap_s4hana.ts New tool wired into dropdown, subBlocks conditions, switch case, and inputs schema; all integration points covered correctly.
apps/sim/tools/registry.ts getMaterialDocumentTool imported and registered under correct key sap_s4hana_get_material_document.
apps/sim/tools/sap_s4hana/index.ts getMaterialDocumentTool re-exported at correct alphabetical position in the barrel file.
apps/docs/content/docs/en/tools/sap_s4hana.mdx Documentation added for get_material_document tool; body parameter for create_purchase_order updated to reflect new required status.
apps/docs/content/docs/en/tools/slack.mdx Documentation additions for four Slack canvas tools (get, list, lookup sections, delete); unrelated to stated PR focus but documentation-only, no code risk.
apps/sim/app/(landing)/integrations/data/integrations.json SAP operationCount incremented from 37→38 and Slack from 25→29 (+4 canvas tools); both counts are arithmetically correct.

Sequence Diagram

sequenceDiagram
    participant UI as Block UI (sap_s4hana.ts)
    participant Registry as Tool Registry
    participant Tool as get_material_document.ts
    participant Proxy as SAP Proxy
    participant SAP as SAP S/4HANA Cloud

    UI->>Registry: operation = sap_s4hana_get_material_document
    Registry->>Tool: invoke(materialDocument, materialDocumentYear, ...)
    Tool->>Proxy: POST SAP_PROXY_URL {service: API_MATERIAL_DOCUMENT_SRV, path: /A_MaterialDocumentHeader(MaterialDocument=...,MaterialDocumentYear=...), method: GET}
    Proxy->>SAP: GET /A_MaterialDocumentHeader(MaterialDocument=...,MaterialDocumentYear=...)
    SAP-->>Proxy: 200 OK + entity JSON
    Proxy-->>Tool: {status, data}
    Tool-->>UI: {status, data: A_MaterialDocumentHeader}
Loading

Reviews (2): Last reviewed commit: "fix(sap_s4hana): align material doc key ..." | Re-trigger Greptile

Comment thread apps/sim/tools/sap_s4hana/get_material_document.ts
Comment thread apps/sim/tools/sap_s4hana/types.ts
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 5be41b7. Configure here.

@waleedlatif1 waleedlatif1 merged commit c400e59 into staging Apr 28, 2026
14 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/chennai-v1 branch April 28, 2026 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant