我正在通过 pyrfc 和 python 使用 SAP 功能模块 L_TO_CANCEL 来取消仓库管理补货转移订单 (TO)。这适用于某些 TO,但对于其他 TO(还有补货)会给出错误 X 不允许存储类型的负库存。虽然这是真的,但 TO 还没有工作。尚未从源存储类型中移除库存。因此,取消不应导致目标存储类型出现负库存,这在这种情况下会在错误消息中指示。这是怎么回事,或者为什么我认为有问题。如果我通过 SAP GUI 从 SE37 运行 L_TO_CANCEL,传递相同的参数 I_LGNUM、I_TANUM、I_CANCL,即使 TO 与 rfc 调用相同的 TO 无法取消并且收到不允许消息的负库存,它也会取消有问题的 TO。
s = RfcConnection(sysrfc="QE2")
result = s.delete_to(lgnum="220", tanum="9592250", cancl="X", commit_work="X")
def delete_to(self, lgnum=None, tanum=None, solex=None, cancl=None, subst=None, qname=username, update_task=None, commit_work=None, t_ltap_cancl=None):
return_msg = None
assert (lgnum is not None and tanum is not None), "Warehouse number as lgnum and Transfer Order as tanum are required for function delete_to"
if cancl is None:
cancl = "X"
try:
if t_ltap_cancl is None:
return_msg = self.conn.call("L_TO_CANCEL",
I_LGNUM=lgnum,
I_TANUM=pad(tanum, 10, "0"),
I_CANCL=cancl)
elif t_ltap_cancl is not None:
return_msg = self.conn.call("L_TO_CANCEL",
I_LGNUM=lgnum,
I_TANUM=pad(tanum, 10, "0"),
T_LTAP_CANCL=t_ltap_cancl)
except pyrfc._exception.ABAPApplicationError as e:
if e.msg_class == "L3" and e.msg_number == "354":
return_msg = self.get_error_code(Language="EN", Area=e.msg_class, Message=e.msg_number)[0][0].replace("&", "{}".format(tanum))
else:
return_msg = self.get_error_code(Language="EN", Area=e.msg_class, Message=e.msg_number)
except pyrfc._exception.ABAPRuntimeError as e:
if e.msg_class == "L3" and e.msg_number == "037":
return_msg = self.get_error_code(Language="EN", Area=e.msg_class, Message=e.msg_number)[0][0].replace("&", "{}".format(e.msg_v1))
else:
return_msg = self.get_error_code(Language="EN", Area=e.msg_class, Message=e.msg_number)
except Exception as e:
return_msg = e
return return_msg