在 ABAP 中使用自定义消息引发异常 [英] Raise Exception with custom message in ABAP
问题描述
我正在编写一个通过 RFC 调用的函数,我想找到在 ABAP 中使用自定义消息引发异常的最简单方法.如果可以在一行中尽可能短地完成此操作,那就太好了.
I am coding a function which gets called via RFC and I want to find the most simple way to raise an exception with a custom message in ABAP. It would be great, if this could be done as short as possible, if possible on one line.
我想要这个用于调试,而不是用于运行生产代码.
I want this for debugging, not for running production code.
背景:
过去我使用 Python 编程语言.我喜欢在没有调试器的情况下进行调试.我在代码中加入了一些 assert 0, myvar
行并执行代码.对我来说,这感觉比传统调试器更快,而且可以跨过或进入代码行.我正在 ABAP 中寻找等效于 assert 0, mvar
的内容.
In the past I used the Python programming language. I like to debug without a debugger. I put some assert 0, myvar
lines in to the code and execute the code. For me this feels faster then tradition debugger with stepping over or into code lines. I am searching for an equivalent to assert 0, mvar
in ABAP.
提出异常只是我目前想到的策略.欢迎使用所有其他实现总体目标的策略.
Raising an exception is just the strategy I have on my mind at the moment. Every other strategy to get to the overall goal is welcome.
推荐答案
我发现这有效:
message my_string_var type 'E'.
我将 MESSAGE TYPE 'E' 临时添加到代码中.我从外部测试我的 ABAP 代码(通过 PyRFC).
I add the MESSAGE TYPE 'E' only temporary into the code. I test my ABAP code from outside (via PyRFC).
这篇关于在 ABAP 中使用自定义消息引发异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!