SAP ABAP

参考英文原版教程请移步 Tutorialspoint

一、初识ABAP语句

  • NOT case sensitive
1
2
3
REPORT [Program_Name].
[Statements...].

二、基本准则

  • 所有包含在 引号内 的字符串都会输出
  • 所有语句自动转换为 大写 格式
  • 自由使用缩进 提高代码可读性
  • 单行可有多条语句,单条语句可 跨行

三、Colon Notation

1
2
3
4
5
6
7
8
9
WRITE 'Hello'.
WRITE 'ABAP'.
WRITE 'World'.
//Use Colon Notation
WRITE: 'Hello',
'ABAP',
'World'.
//The following style is OK as well
WRITE: 'Hello','ABAP','World'.

四、注释

1
2
//* This is the comment line
WRITE 'Hello'. //"The partial comment

五、NO-ZERO 空格补全

  • The NO-ZERO command follows the DATA statement.
1
2
3
4
REPORT Z_Test123_01.
DATA: W_NUR(10) TYPE N.
MOVE 50 TO W_NUR.
WRITE W_NUR NO-ZERO.
  • 由于使用了 NO-ZERO 命令,以上程序输出 50 ,否则输出 0000000050

六、SKIP 插入空行

1
2
3
WRITE 'This is the 1st line'.
SKIP.
WRITE 'This is the 2nd line'.
  1. 插入多条空行 SKIP number_of_lines.
  2. 跳转至某一行 SKIP TO LINE line_number.

七、ULINE 插入水平线

  • 使用方法
1
2
WRITE 'This is Underlined'.
ULINE.
  • 输出结果
1
2
This is Underlined.
———————————————————

八、Messages 提示信息

Message Type Consequences
E Error 消息显示,程序暂停
W Warning 消息显示,Enter方可继续
I Information 消息弹出,Enter方可继续
A Abend 取消当前进程
S Success 显示成功信息
X Abort Aborts the program and generates an ABAP short dump.