0
点赞
收藏
分享

微信扫一扫

check的3种用法


首先要说明,SAP推荐将check用于循环中

1.check 用于循环中,如果条件不成立则结束下面的操作直接进入下一次循环

program:

 

DO 10 TIMES.
  check sy-index between 4 and 7.
  write: 'the index value is: ', sy-index.
ENDDO. 

 

result:

the index value is:           4
the index value is:           5
the index value is:           6
the index value is:           7 

 

2.check用于块中,如果条件不成立直接结束块

program:

parameters p_local type i default -1.
start-of-selection.
perform f_getdata.
perform f_dispaly_data.
end-of-selection.
*&---------------------------------------------------------------------*
*&      Form  F_GETDATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form F_GETDATA .
  check p_local eq 1.
  write: / 'subroutine 1'.
endform.                    " F_GETDATA
*&---------------------------------------------------------------------*
*&      Form  F_DISPALY_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form F_DISPALY_DATA .
  write: / 'subroutine 2'.
endform.                    " F_DISPALY_DATA

 

result:

 

3.check 用于GET事件中

program:

NODES sflight.
SELECT-OPTIONS: s_max FOR sflight-seatsmax,
                s_occ FOR sflight-seatsocc.
GET sflight.
  WRITE: / sflight-carrid, sflight-connid.
  CHECK SELECT-OPTIONS.
  WRITE: sflight-seatsmax, sflight-seatsocc.

举报

相关推荐

0 条评论