SAP Sales and Distribution (SD) · Arazzo Workflow

SAP SD Credit Memo Approval

Version 1.0.0

Create a credit memo request, read it, then accept or reject its approval by amount.

1 workflow 1 source API 1 provider
View Spec View on GitHub DistributionERPODataS/4HANASalesSAPArazzoWorkflows

Provider

sap-sales-and-distribution-sd

Workflows

credit-memo-approval
Create a credit memo request and accept or reject it by total amount.
Creates a credit memo request, retrieves its total net amount, and accepts the approval when the amount is within the threshold or rejects it otherwise.
4 steps inputs: autoApproveMaxAmount, creditMemoRequestType, csrfToken, distributionChannel, material, organizationDivision, requestedQuantity, salesOrganization, sdDocumentReason, soldToParty outputs: creditMemoRequest, totalNetAmount
1
createRequest
createCreditMemoRequest
Create a credit memo request with one deep-inserted item for the sold-to party.
2
getRequest
getCreditMemoRequest
Read the credit memo request back to capture its total net amount for the approval decision.
3
acceptApproval
acceptCreditMemoApprovalRequest
Accept the approval request for a credit memo within the threshold.
4
rejectApproval
rejectCreditMemoApprovalRequest
Reject the approval request so a larger credit memo is re-routed.

Source API Descriptions

Arazzo Workflow Specification

sap-sales-and-distribution-sd-credit-memo-approval-workflow.yml Raw ↑
arazzo: 1.0.1
info:
  title: SAP SD Credit Memo Approval
  summary: Create a credit memo request, read it, then accept or reject its approval by amount.
  description: >-
    Drives the approval decision for a credit memo request in SAP Sales and
    Distribution. The workflow creates a credit memo request, reads it back to
    capture its total net amount, and branches on that amount: requests at or
    below the auto-approval threshold are accepted, while larger requests are
    rejected so they can be re-routed for manual handling. Each step inlines its
    OData request so the flow reads and runs without opening the underlying
    OpenAPI descriptions. The creation and approval POSTs require an
    X-CSRF-Token header supplied as a workflow input.
  version: 1.0.0
sourceDescriptions:
- name: creditMemoRequestApi
  url: ../openapi/sap-sd-credit-memo-request-openapi.yml
  type: openapi
workflows:
- workflowId: credit-memo-approval
  summary: Create a credit memo request and accept or reject it by total amount.
  description: >-
    Creates a credit memo request, retrieves its total net amount, and accepts
    the approval when the amount is within the threshold or rejects it
    otherwise.
  inputs:
    type: object
    required:
    - csrfToken
    - salesOrganization
    - soldToParty
    - material
    - requestedQuantity
    - autoApproveMaxAmount
    properties:
      csrfToken:
        type: string
        description: X-CSRF-Token fetched from the OData service for write operations.
      creditMemoRequestType:
        type: string
        description: Credit memo request document type (e.g. CR).
      salesOrganization:
        type: string
        description: Sales organization.
      distributionChannel:
        type: string
        description: Distribution channel.
      organizationDivision:
        type: string
        description: Division.
      soldToParty:
        type: string
        description: Sold-to party customer number.
      sdDocumentReason:
        type: string
        description: Order reason explaining the credit memo request.
      material:
        type: string
        description: Material for the credit memo request item.
      requestedQuantity:
        type: string
        description: Quantity for the credit memo request item.
      autoApproveMaxAmount:
        type: number
        description: Total net amount at or below which the request is auto-approved.
  steps:
  - stepId: createRequest
    description: >-
      Create a credit memo request with one deep-inserted item for the sold-to
      party.
    operationId: createCreditMemoRequest
    parameters:
    - name: X-CSRF-Token
      in: header
      value: $inputs.csrfToken
    requestBody:
      contentType: application/json
      payload:
        CreditMemoRequestType: $inputs.creditMemoRequestType
        SalesOrganization: $inputs.salesOrganization
        DistributionChannel: $inputs.distributionChannel
        OrganizationDivision: $inputs.organizationDivision
        SoldToParty: $inputs.soldToParty
        SDDocumentReason: $inputs.sdDocumentReason
        to_Item:
          results:
          - Material: $inputs.material
            RequestedQuantity: $inputs.requestedQuantity
    successCriteria:
    - condition: $statusCode == 201
    outputs:
      creditMemoRequest: $response.body#/d/CreditMemoRequest
  - stepId: getRequest
    description: >-
      Read the credit memo request back to capture its total net amount for the
      approval decision.
    operationId: getCreditMemoRequest
    parameters:
    - name: CreditMemoRequest
      in: path
      value: $steps.createRequest.outputs.creditMemoRequest
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      creditMemoRequest: $response.body#/d/CreditMemoRequest
      totalNetAmount: $response.body#/d/TotalNetAmount
    onSuccess:
    - name: withinThreshold
      type: goto
      stepId: acceptApproval
      criteria:
      - context: $response.body
        condition: $.d.TotalNetAmount <= $inputs.autoApproveMaxAmount
        type: jsonpath
    - name: overThreshold
      type: goto
      stepId: rejectApproval
      criteria:
      - context: $response.body
        condition: $.d.TotalNetAmount > $inputs.autoApproveMaxAmount
        type: jsonpath
  - stepId: acceptApproval
    description: Accept the approval request for a credit memo within the threshold.
    operationId: acceptCreditMemoApprovalRequest
    parameters:
    - name: X-CSRF-Token
      in: header
      value: $inputs.csrfToken
    - name: CreditMemoRequest
      in: query
      value: $steps.getRequest.outputs.creditMemoRequest
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      creditMemoRequest: $response.body#/d/CreditMemoRequest
    onSuccess:
    - name: accepted
      type: end
  - stepId: rejectApproval
    description: Reject the approval request so a larger credit memo is re-routed.
    operationId: rejectCreditMemoApprovalRequest
    parameters:
    - name: X-CSRF-Token
      in: header
      value: $inputs.csrfToken
    - name: CreditMemoRequest
      in: query
      value: $steps.getRequest.outputs.creditMemoRequest
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      creditMemoRequest: $response.body#/d/CreditMemoRequest
  outputs:
    creditMemoRequest: $steps.getRequest.outputs.creditMemoRequest
    totalNetAmount: $steps.getRequest.outputs.totalNetAmount