check 关键字理解

一、check 关键字

CHECK log_exp.

Effect

If the statement CHECK is executed in a loop and log_exp is incorrect, the statement CHECK immediately terminates the current loop pass and the program continues with the next loop pass. You can specify any logical expression for log_exp.

Notes

IF NOT log_exp. 
  CONTINUE. 
ENDIF.

    1. processing block (see CHECK), however we recommend using CHECK only inside loops.

Example

A loop pass is exited using CHECK if the loop index sy-index is an odd number.

DATA remainder TYPE i. 
DO 20 TIMES. 
  remainder = sy-index MOD 2. 
  CHECK remainder = 0. 
  WRITE / sy-index. 
ENDDO.


以上为帮助文档里的解释:

    简单的来说,check 分为loop内和loop外两种使用方法

当在loop内使用的时候,

loop .....

check log_exp.

.....
endloop.

这里当逻辑表达式为假的时候,则会终止check下面的语句,继续进行下一次的循环。

当逻辑表达式为真的时候,则会继续进行执行check 下面的语句。


  CHECK it_vbeln IS NOT INITIAL.  

 

这句话表示:当it_vbeln为空的时候,则会退出当前处理快,否则继续执行下面的语句

 

二、condense 关键字

CONDENSE text [NO-GAPS].

 

In the variable text, leading and closing blanks are completely removed and any other directly consecutive blanks are all replaced by exactly one space character or - if NO-GAPS is specified - are also removed completely.

The data object text must be character-type. If the data object has a fixed length, any space created by the condense operation is filled with blanks on the right. If the data object is of the type string, its length is adapted to the result of the condense operation.

Note

You can also condense a character string in an operand position using a condensation function which covers the functionality of the CONDENSE statement.

对于text字符串,condense的功能就是将两个字符之间的一连串空格用一个空格代替,如果加上 no-gaps 则表示去除所有的空格

posted @ 2014-06-21 16:14  林中白狼-LBG  阅读(352)  评论(0编辑  收藏  举报