ABAP中的IF语句怎么用?

 我来答
isunflowerzz
2012-05-20 · 超过12用户采纳过TA的回答
知道答主
回答量:35
采纳率:0%
帮助的人:30.7万
展开全部
语法:
IF <condition1>.
<statement block>
ELSEIF <condition2>.
<statement block>
ELSEIF <condition3>.
<statement block>
.....
ELSE.
<statement block>
ENDIF.
范例:
DATA: TEXT1(30) VALUE 'This is the first text',
TEXT2(30) VALUE 'This is the second text',
TEXT3(30) VALUE 'This is the third text',
STRING(5) VALUE 'eco'.
IF TEXT1 CS STRING.
WRITE / 'Condition 1 is fulfilled'.
ELSEIF TEXT2 CS STRING.
WRITE / 'Condition 2 is fulfilled'.
ELSEIF TEXT3 CS STRING.
WRITE / 'Condition 3 is fulfilled'.
ELSE.
WRITE / 'No condition is fulfilled'.
ENDIF.
产生如下输 出:
Condition 2 is fulfilled.
这里,第二 个逻辑表达 式 TEXT2 CS STRING 是真,因为 字符串“eco” 存在于 TEXT2 中。
shownbb
推荐于2016-09-24 · TA获得超过289个赞
知道小有建树答主
回答量:876
采纳率:0%
帮助的人:339万
展开全部
举个简单的例子:
C = 1+2 = 3,
这个时候判断C是不是等于3,等于3就出正确,不等于3就告诉用户,错了
IF C = 3.
正确。
ELSE.
错了。
ENDIF.
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
稚的会1b
2012-05-22 · 贡献了超过187个回答
知道答主
回答量:187
采纳率:0%
帮助的人:19万
展开全部
就一个逻辑判断而以, 请参考
IF log_exp1.
[statement_block1]
[ELSEIF log_exp2.
[statement_block2]]
...
[ELSE.
[statement_blockn]]
ENDIF.

Effect

These statements define a control structure which can contain multiple statement blocks statement_block of which a maximum of one will be executed in conjunction with logical expressions log_exp.

After IF and ELSEIF any logical expressions log_exp can be executed while the expressions statement_block stand for any statement blocks.

The logical expressions, beginning with the IFstatement, are checked from top to bottom and the statement block after the first is executed during the logical expression. If none of the logical expressions are true, the statement block after the ELSE statement is executed.
When the end of the statement block is reached or if no statement block is to be executed, the processing is continued after ENDIF.
Example

Converting a time output into the 12-hour format (see also country-specific formats).

DATA time TYPE t.

fltime = sy-time.

IF time < '120000'.
WRITE: / time, 'AM' .
ELSEIF time > '120000' AND
time < '240000'.
time = time - 12 * 3600.
WRITE: / time, 'PM' .
ELSE.
WRITE / 'High Noon'.
ENDIF.
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
zhoufeng1006
2012-05-18 · 超过14用户采纳过TA的回答
知道答主
回答量:32
采纳率:0%
帮助的人:36.8万
展开全部
简单的语法就是:
if xxx.
else.(有时候会用到elseif xxx.)
ednif.

具体的可以参照sap help.
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式