转 Starting Workflow from Messages

本文介绍如何通过特定错误消息触发SAP系统中的工作流。以创建采购订单为例,详细展示了从获取错误消息到创建并激活工作流定义的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Trigger Workflow from Messages

By Suresh Kumar Parvathaneni from Link

 

This document details about the procedure in triggering the workflows from a message (For e.g., error or warning message). 
For our demo purpose, let us consider the transaction ME21 (Create Purchase Order). Without entering any values on the screen, press ENTER. You would get the error message “Enter Purchasing Org.” (as shown below)
 

Now double-click on the message, to get the long text and the message details. 

 

Now click on the technical information. 

 

The above screenshot provides us with the message details (Message Class: ME) and Message Number 083. 

Now we need to create a workflow which needs to be triggered from this message. 

Go to transaction SWUY. Following wizard appears.

 

Click on “Continue”.

 

Enter the message details, as obtained earlier. Click on “Continue”.
 

Click on “Complete” again. Pop-up screen regarding the package (Development class) appears. Assign the package, you would like to have. Press ENTER. You would be automatically navigated to the “Workflow Template” screen shown below: 

 

Enter the Work item text and click on “Workflow Builder”. We are now in the “Workflow Builder” screen. 

 

For our demo purpose, let’s create a simple email step in our workflow definition. (To know about how to include an email step in the Workflow definition, click here)

 

Activate the Workflow definition. 

Testing the application

 Go to transaction ME21.

Without entering any values, press ENTER. The error message “Enter Purchasing Org.” appears. Double-click on the message and the long text appears. See the screenshot below. 

 

As highlighted in the screenshot above, the button “Workflow” is now enabled (before attaching a workflow definition to this message, this button was disabled”. Click on the button “Workflow”. The workflow definition created earlier, in this case WS99900061, is now triggered. See the screenshot below. 

from langgraph.graph import StateGraph, END from langgraph.types import Command, interrupt from langgraph.checkpoint.memory import InMemorySaver from typing_extensions import TypedDict # Define your state class AgentState(TypedDict): messages: list # Define a node that requires human approval def human_approval_node(state: AgentState): # Prompt the human for approval print("==== flag ====") # 中断恢复时会从该函数开头重新执行 response = interrupt("Do you approve this action? (yes/no)") # Process the human's response if response.lower() == "yes": return {"messages": state["messages"] + ["Human approved."]} else: return {"messages": state["messages"] + ["Human denied."]} # Build the graph builder = StateGraph(AgentState) builder.add_node("action_to_approve", lambda x: {"messages": x["messages"] + ["Performing action to be approved."]}) builder.add_node("human_approval", human_approval_node) builder.add_node("final_step", lambda x: {"messages": x["messages"] + ["Action completed or denied."]}) builder.add_edge("action_to_approve", "human_approval") builder.add_edge("human_approval", "final_step") builder.set_entry_point("action_to_approve") builder.set_finish_point("final_step") # Configure the graph with a checkpointer memory = InMemorySaver() graph = builder.compile(checkpointer=memory) # Initial state thread_id = {"configurable": {"thread_id": "1"}} initial_state = AgentState(messages=["Starting workflow."]) 这段代码如何结合langserve,使得可以用户在浏览器中与该langgraph服务交互
最新发布
08-16
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值