DATA: gv_1 TYPE c.
DATA: gv_2 TYPE i.
gv_2 = 60.
IF gv_2 >= 0 AND gv_2 < 60 .
gv_1 = ‘A‘.
ELSEIF gv_2 >= 60 AND gv_2 < 70.
gv_1 = ‘B‘.
ELSEIF gv_2 >= 70 AND gv_2 < 80.
gv_1 = ‘C‘.
ELSEIF gv_2 >= 80 AND gv_2 < 90.
gv_1 = ‘D‘.
ELSEIF gv_2 >= 90 AND gv_2 <= 100.
gv_1 = ‘E‘.
else.
gv_1 = ‘F‘.
ENDIF.
CASE gv_1.
WHEN ‘A‘.
* MESSAGE ‘.BACK.‘ TYPE ‘i‘.
WRITE: / gv_2 ,‘不及格‘.
WHEN ‘B‘.
* MESSAGE ‘.CANCEL.‘ TYPE ‘i‘.
WRITE: / gv_2,‘及格‘.
WHEN ‘C‘.
* MESSAGE ‘.exit.‘ TYPE ‘1‘.
WRITE: / gv_2,‘中‘.
WHEN ‘D‘.
* MESSAGE ‘.CANCEL.‘ TYPE ‘i‘.
WRITE: / gv_2,‘良好‘.
WHEN ‘E‘.
* MESSAGE ‘.CANCEL.‘ TYPE ‘i‘.
WRITE: / gv_2,‘優秀‘.
WHEN ‘F‘.
* MESSAGE ‘.CANCEL.‘ TYPE ‘i‘.
WRITE: / gv_2,‘大於100,請輸入0~100中間的數值!‘.
* WHEN OTHERS.
** MESSAGE ‘.OTHERS.‘ TYPE ‘i‘.
* WRITE: / gv_2 ,‘大於100,請輸入0~100中間的數值!‘.
ENDCASE.
abap case when 例子,布布扣,bubuko.com
原文:http://www.cnblogs.com/raywwen/p/3804648.html