可能会出现额定负载的退出程序吗?

发布于 2025-02-05 04:21:32 字数 1248 浏览 3 评论 0原文

如果不允许用户执行该程序,我将在程序启动中实施一些检查,主要是授权,并希望中止程序。通过SE93的明确验证对象分配不适合我,因为它缺乏灵活性。

我试图通过两种方式在事件中进行此操作:

  • 通过返回语句
  • ,用类型e typer messation

均导致了dump 事件加载程序的非法中断,确实对应于 abap docu

必须完全执行事件块,否则会发生运行时错误

这意味着可以指定退出事件块而无需返回事件。

我解释了段落这意味着可以指定语句以不返回事件块而不会返回其的方式,以免在此块中允许两个退出语句。我的理解正确吗?

现在,我在初始化块中进行堕胎/验证:

INITIALIZATION.
 IF do_validate( ) = abap_false.
  MESSAGE 'You are busted!' TYPE 'E'.
 ENDIF

问题是我的程序具有多个选择屏幕,并且初始化块被几次触发。是的,当然,我可以按屏幕编号区分它们,但是在promogram中执行此操作似乎更合乎逻辑,因为它仅执行每个程序一次。

问题:在LOP事件或其他最佳实践中,有什么方法可以实现这一目标吗?

I am implementing some checks, mainly authorization, on program start and want to abort the program if the user is not allowed to execute it. Explicit auth object assignment via SE93 does not fit for me because it lacks flexibility.

I tried to do it in LOAD-OF-PROGRAM event in two ways:

  • through RETURN statement
  • by throwing message with type E

Both resulted to dump Illegal interruption of the event LOAD-OF-PROGRAM, which is indeed corresponds to ABAP docu:

The event block must be fully executed, otherwise a runtime error occurs

This means that statements can be specified that exit the event block without returning to it.

I interpret the passage This means that statements can be specified that exit the event block without returning to it in the way that neither of the exit statements are allowed in this block. Is my understanding correct?

Now I do abortion/validation in INITIALIZATION block:

INITIALIZATION.
 IF do_validate( ) = abap_false.
  MESSAGE 'You are busted!' TYPE 'E'.
 ENDIF

The problem is that my program has multiple selection screens and INITIALIZATION block is triggered several times. Yes, of course I can differentiate them by screen number, but doing this in LOAD-OF-PROGRAM seems more logical as it is executed only once per program.

The question: is there some way to achieve that in LOP event or other best practice and why?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无语# 2025-02-12 04:21:32

我不知道这是否是最佳实践,但是可以使用休假计划来实现这一目标。

LOAD-OF-PROGRAM.

IF ...
   LEAVE PROGRAM.
ENDIF.

noreferrer“ /en-us/abapleave_program.htm

“语句离开程序可以在任何处理块中出现在任何地方。无论执行程序或内部会话的程序组如何,它都会结束程序。 “

I don't know if it is best practice, but LEAVE PROGRAM can be used to achieve this goal.

LOAD-OF-PROGRAM.

IF ...
   LEAVE PROGRAM.
ENDIF.

https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abapleave_program.htm

"The statement LEAVE PROGRAM can appear anywhere within any processing block. It ends the program regardless of the program or object in which it is executed or in which program group of the internal session."

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文