CHECK,EXIT,STOP etc...

本文详细介绍了 ABAP 编程语言中的关键控制语句,包括 CHECK、EXIT、STOP 和 RETURN 的用法及区别。CHECK 用于循环或事件块中条件判断,未满足条件时跳过后续代码执行;EXIT 用于立即退出当前事件块或循环;STOP 用于停止事件块处理,并直接跳转到 END-OF-SELECTION;RETURN 则用于退出子程序或停止整个程序运行。

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

CHECK
If the check statement appears in a LOOP process block, the unfufilled condition check will stop processing rest codes and do next loop.
If the check statement appears in a EVENT block, the unfufilled condition check will stop current event process and jump to next evetn.

EXIT
If you use the EXIT statement within an event block but not in a loop, the system stops processing the block immediately.If the EXIT statement occurs in a loop using DO, WHILE, or LOOP, it is the loop that terminates, not the processing block.

STOP
If you use the STOP statement within an event block, the system stops processing the block immediately.Before and during selection screen processing, the next event in the prescribed sequence is always called. From the AT SELECTION-SCREEN event onwards, the system always jumps from a STOP statement directly to the END-OF-SELECTION statement. Once the corresponding event block has been processed, the system displays the list.

RETURN
If the return occurs in a subroutine, the system will jump out the subroutine processing. If the return occurs in event block processing, system will stop the program directly.
e.g.
START-OF-SELECTION.
  PERFORM frm_test.
  return.
  WRITE / 'start of selection'.

END-OF-SELECTION.
  WRITE / 'end of selection'.
*&---------------------------------------------------------------------*
*&      Form  frm_test
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM frm_test.
  DO 5 TIMES.
    IF sy-index = 2.
      RETURN.
      WRITE 'IF STATEMENT'.
    ENDIF.
    WRITE: 'DO', sy-index.
  ENDDO.
  WRITE / 'END'.
ENDFORM.                    "frm_test

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值