SAP ABAP - Operators

这篇博客详细介绍了SAP ABAP中的四种操作符类别:算术操作符、比较操作符、位操作符和字符字符串操作符。通过示例展示了它们在不同场景下的用法,包括自动类型转换规则和各种比较操作符的使用。
摘要由CSDN通过智能技术生成

ABAP provides a rich set of operators to manipulate variables. All ABAP operators are classified into four categories −

  • Arithmetic Operators
  • Comparison Operators
  • Bitwise Operators
  • Character String Operators

Arithmetic Operators

Arithmetic operators are used in mathematical expressions in the same way that they are used in algebra. The following list describes arithmetic operators. Assume integer variable A holds 20 and variable B holds 40.

S.No. Arithmetic Operator & Description
1

+ (Addition)

Adds values on either side of the operator. Example: A + B will give 60.

2

− (Subtraction)

Subtracts right hand operand from left hand operand. Example: A − B will give -20.

3

* (Multiplication)

Multiplies values on either side of the operator. Example: A * B will give 800.

4

/ (Division)

Divides left hand operand by right hand operand. Example: B / A will give 2.

5

MOD (Modulus)

Divides left hand operand by right hand operand and returns the remainder. Example: B MOD A will give 0.

Example

REPORT YS_SEP_08. 
DATA: A TYPE I VALUE 150, 
B TYPE I VALUE 50, 
Result TYPE I. 
Result =  A / B. 
WRITE / Result.

The above code produces the following output −

3

Comparison Operators

Let’s discuss the various types of comparison operators for different operands.

S.No. Comparison Operator & Description
1

= (equality test). Alternate form is EQ.

Checks if the values of two operands are equal or not, if yes then condition becomes true. Example (A = B) is not true.

2

&

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值