目录

1,Scenario

2,Create Project

1-1,Create > Build Process Automation

1-2,添加API Trigger

a,添加一些Data Types,后面会用来当作API Trigger的Input参数

b,绑定Data Type到Input Parameter

1-3,添加Approval Form

a,设置Recipients(受信者)

b,设置期限(Due Date)

c,编辑Approval Form

1-4,添加Approved Form - 承认之后显示的Form

1-5,添加Reject Mail

1-6,看一下Console,有无错误消息

1-7,Release

3,Deploy

3-1,Deploy 某个Release Version

3-2,查看Deploy


下面是详细内容。

1,Scenario

- 销售代表 (Sales Rep)在S4 下单 (Sales Order)

- S4下单之后自动启动了BPA,进入承认流程

- BPA里面通过填写Form,发送给Manager,点承认或否认,然后结束流程

下面做一部分步骤,并没有完成这个流程,完整流程以后再说。

2,Create Project

1-1,Create > Build Process Automation

1-2,添加API Trigger

a,添加一些Data Types,后面会用来当作API Trigger的Input参数

截一个Data types用途的图

b,绑定Data Type到Input Parameter

回到Sales Order Approval,点任意空白处,然后点 Variable Tab的 +

然后加1个变量,注意的是Type要选 Sales Order Header

然后就一下子把Sales Order Header下面的子变量都加进来了

点一下API Trigger,右侧 Outputs会显示变量

1-3,添加Approval Form

然后点+ > Approval

点Blank Approval

输入Form名称,点Create

这样就生成了Approve的Form,并且给出了2个分支,Approve/ Reject

a,设置Recipients(受信者)

b,设置期限(Due Date)

超过期限,给受信者送的信,就会从他的Inbox里面被删除

c,编辑Approval Form

保存之后,回到上一页,设置Mapping

Output里面也已经有了

因为咱们在Approval Form里面设定了Approver要填这两项

- Work Item

- Context

1-4,添加Approved Form - 承认之后显示的Form

把General,Input 2个Tab中的自动给Mapping一下

编辑Form

1-5,添加Reject Mail

Reject的时候,也可以显示一个Form,但是咱们这里就不显示Form了,只发送一个邮件

填写Mail To/ Subject

还可以加CC,BCC,咱们这里就不加了哈

点Edit Mail Body

可以在这里写一下邮件模板

1-6,看一下Console,有无错误消息

1-7,Release

我是已经点过一次了,第二次开始就是下面这个Layout

Release是干啥用的呢?

其实就是打个包,这样Deploy的时候,就是把这个包给放到服务器而已。

3,Deploy

3-1,Deploy 某个Release Version

只有先Release,打好包,然后才能Deploy

选好某个Release 版本,点Deploy按钮

我这里选的CF Shared Environment

这个默认没有,需要手动添加,如何添加,可以参照这篇文章

https://blog.csdn.net/shi_ly/article/details/160039479

现在Public还能用,但是选的话,会出警告

让你Deploy到Shared Environment上面去

3-2,查看Deploy

选环境

点Triggers Tab,然后点 ... > View

这里有URL,Payload

URL:调用咱们这个Trigger API的入口

https://spa-api-gateway-bpi-us-prod.cfapps.us10.hana.ondemand.com/workflow/rest/v1/workflow-instances?environmentId=cfsharedenv01

PayLoad:这就是Context,其他人想调用执行我的Trigger API,就需要传值过来

{
    "definitionId": "us10.b3f18d90trial.salesorderapproval.salesOrderApproval",
    "context": {
        "salesorderheader": {
            "customerGroup": "",
            "distributionChannel": 0,
            "orientationDevision": "",
            "salesOrder": "",
            "salesOrderDate": "",
            "salesOrderType": "",
            "salesOrgination": "",
            "soldToParty": "",
            "totalNetAmount": 0,
            "transactionCurrency": ""
        }
    }
}

点一下Download Open API Configuration: 

你可以下载下来分享给其他人,如果他们想集成这个Process Automation到他们的App

可以认为是该API的说明文档

{
  "openapi": "3.0.3",
  "info": {
    "title": "Trigger Process via API Trigger",
    "version": "1.0.0"
  },
  "externalDocs": {
    "description": "SAP Build Process Automation Workflow APIs",
    "url": "https://api.sap.com/api/SPA_Workflow_Runtime/resource/"
  },
  "servers": [
    {
      "url": "https://spa-api-gateway-bpi-us-prod.cfapps.us10.hana.ondemand.com"
    }
  ],
  "components": {
    "schemas": {
      "TechnicalError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "description": "The error category."
              },
              "message": {
                "type": "string",
                "description": "The error message."
              },
              "logId": {
                "type": "string",
                "description": "The log ID referring to the error."
              },
              "details": {
                "items": {
                  "type": "object",
                  "properties": {
                    "severity": {
                      "type": "string",
                      "description": "The severity of the error."
                    },
                    "message": {
                      "type": "string",
                      "description": "The detailed error message."
                    }
                  }
                },
                "type": "array"
              }
            },
            "required": [
              "message"
            ]
          }
        }
      },
      "UnauthorizedError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "The error name."
          },
          "error_description": {
            "type": "string",
            "description": "The error description."
          }
        },
        "required": [
          "error",
          "error_description"
        ]
      },
      "ConflictError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "message": {
                "type": "string",
                "description": "The error message."
              },
              "logId": {
                "type": "string",
                "description": "The log ID referring to the error."
              }
            },
            "required": [
              "message"
            ]
          }
        }
      },
      "WorkflowInstance": {
        "type": "object",
        "properties": {
          "definitionId": {
            "type": "string",
            "description": "The ID of the workflow definition for which the instance was started. The ID is at most 255 characters long.",
            "maxLength": 255
          },
          "definitionVersion": {
            "type": "string",
            "description": "The version of the workflow definition for which the instance was started."
          },
          "id": {
            "type": "string",
            "description": "The workflow instance ID. The ID is at least 36 characters long.",
            "minLength": 36,
            "maxLength": 255
          },
          "startedAt": {
            "format": "date-time",
            "type": "string",
            "description": "The time when the workflow instance started."
          },
          "startedBy": {
            "type": "string",
            "description": "The user who started the workflow instance. The user ID is at most 255 characters long.",
            "maxLength": 255
          },
          "completedAt": {
            "type": "string",
            "format": "date-time",
            "description": "The time when the workflow instance status changed to COMPLETED."
          },
          "status": {
            "enum": [
              "RUNNING",
              "ERRONEOUS",
              "SUSPENDED",
              "CANCELED",
              "COMPLETED"
            ],
            "type": "string",
            "description": "The status of the workflow instance. The status values as returned by this API have the following corresponding terms in user interfaces of SAP Build Process Automation:\n* RUNNING - Running\n* ERRONEOUS - Error\n* SUSPENDED - On Hold\n* CANCELED - Canceled\n* COMPLETED - Completed"
          },
          "businessKey": {
            "type": "string",
            "description": "The business key of the workflow instance. The business key of a workflow instance is limited to 255 characters.",
            "maxLength": 255
          },
          "subject": {
            "type": "string",
            "description": "The subject of the workflow instance. The subject of a workflow instance is limited to 255 characters.",
            "maxLength": 255
          },
          "rootInstanceId": {
            "type": "string",
            "description": "The workflow root instance ID. The root ID is at least 36 characters long.",
            "minLength": 36,
            "maxLength": 255
          },
          "parentInstanceId": {
            "type": "string",
            "description": "The workflow parent instance ID. The parent ID can be null or at least 36 characters long.",
            "maxLength": 255
          },
          "projectId": {
            "type": "string",
            "description": "The project ID  of the SAP Build Process Automation project to which workflowinstance belongs to. It has the format of region.subaccount.projectName. The projectid is limited to 255 characters.",
            "maxLength": 255
          },
          "projectVersion": {
            "type": "string",
            "description": "The project version of SAP Build Process Automation project to which workflowinstance belongs to. The projectversion is limited to 64 characters.",
            "maxLength": 64
          }
        }
      }
    }
  },
  "paths": {
    "/workflow/rest/v1/workflow-instances": {
      "post": {
        "summary": "Starts a new workflow instance.",
        "description": "Starts a new workflow instance of the provided workflow definition. Specify the ID of the workflow definition in the body.\nThe workflow instance automatically starts based on the latest deployed version of the definition.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "title": "WorkflowInstanceStartRequest",
                "properties": {
                  "definitionId": {
                    "type": "string",
                    "example": "us10.b3f18d90trial.salesorderapproval.salesOrderApproval",
                    "description": "Specify the ID of the workflow definition for which an instance should be started. The ID is at most 255 characters long."
                  },
                  "context": {
                    "type": "object",
                    "properties": {
                      "salesorderheader": {
                        "refName": "Sales Order Header",
                        "title": "SalesOrderHeader",
                        "description": "",
                        "$schema": "http://json-schema.org/draft-07/schema#",
                        "type": "object",
                        "properties": {
                          "customerGroup": {
                            "type": "string",
                            "uid": "d4cfef5f-7c3d-4d5b-8fe1-5e9ce22b6a5b",
                            "required": []
                          },
                          "distributionChannel": {
                            "type": "number",
                            "uid": "88ae0d06-f6cd-47e6-872e-a7bed924f3d2"
                          },
                          "orientationDevision": {
                            "type": "string",
                            "uid": "51c9f25a-6f3a-474d-bb36-52e3c41cafc3"
                          },
                          "salesOrder": {
                            "type": "string",
                            "uid": "d706a0a0-e828-4bda-a366-988bcb2cfb0b"
                          },
                          "salesOrderDate": {
                            "uid": "7c13741c-8cb6-4246-a19a-81a256aa576f",
                            "type": "string",
                            "format": "date"
                          },
                          "salesOrderType": {
                            "type": "string",
                            "uid": "e8bcecb2-69ea-4390-a7c0-078ad2febede"
                          },
                          "salesOrgination": {
                            "type": "string",
                            "uid": "9d09ad22-b2a6-444a-9acb-ec1ec4fb622d"
                          },
                          "soldToParty": {
                            "type": "string",
                            "uid": "4970e31e-25e5-469d-bcca-9cfdd0930cb8"
                          },
                          "totalNetAmount": {
                            "type": "number",
                            "uid": "4fe5299e-ad47-41bd-8a7c-429fdc27b50b"
                          },
                          "transactionCurrency": {
                            "type": "string",
                            "uid": "b572ca21-7488-46f4-a18c-7a81fdbb9d75"
                          }
                        },
                        "x-sap-extension": {
                          "element-prefix": [],
                          "namespace-blocklist": [],
                          "extension-points": {
                            "EXT1": {
                              "path": "$",
                              "name": "EXT1"
                            }
                          }
                        },
                        "required": [
                          "salesOrder",
                          "customerGroup",
                          "distributionChannel",
                          "orientationDevision"
                        ],
                        "definitions": {
                          "date": {
                            "type": "string",
                            "format": "date"
                          }
                        },
                        "version": 1
                      }
                    },
                    "required": [],
                    "$schema": "http://json-schema.org/draft-07/schema#"
                  }
                },
                "required": [
                  "definitionId"
                ]
              }
            }
          }
        },
        "parameters": [
          {
            "description": "Provides environment identifier.",
            "in": "query",
            "name": "environmentId",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "cfsharedenv01"
              ]
            }
          },
          {
            "description": "API Key. A valid API key that contains the scope API_TRIGGER_EXECUTE. \n API Keys are applicable only when the access is via a technical user.\nHuman users are authorized against the user privileges.",
            "in": "header",
            "name": "api-key",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Returns the newly created workflow instance.\nNote that subject and businessKey are 'null' and are evaluated after the workflow instance was started.\nIf the process has a start event output mapping, the two attributes are evaluated based on the result of the mapping.\nIf the process does not have a start event output mapping, the attributes are evaluated based on the payload that was sent in the request.\nTo receive these values, query the instance by ID after the mapping is done.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowInstance"
                },
                "example": {
                  "id": "13",
                  "definitionId": "LeaveRequestWorkflow",
                  "definitionVersion": "2",
                  "subject": "Leave Request for Alice",
                  "businessKey": "s021445",
                  "status": "RUNNING",
                  "startedAt": "2016-11-01T19:59:59.000Z",
                  "startedBy": "Alice",
                  "completedAt": null,
                  "rootInstanceId": "13",
                  "parentInstanceId": null,
                  "projectId": "spaprojectid",
                  "projectVersion": "1.0.1"
                }
              }
            }
          }
        }
      }
    }
  }
}

以上就是本篇的全部内容。

如果大家觉得还行,希望大家多点赞,收藏,转发,感谢!

更多SAP顾问业务知识请点击下面目录链接或东京老树根的博客主页

https://blog.csdn.net/shi_ly/category_12216766.html

东京老树根-CSDN博客

Logo

AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。

更多推荐