Tutorialspoint ABAP教程小結

教程鏈接: https://www.tutorialspoint.com/sap_abap/

本文是讀教程的筆記,因爲主要供自己以後查閱,故採用了中文英文混合的方式

1. Home:

ABAP is a fourth-generation programming language for SAP. Java and ABAP are currently main languages in SAP. This tutorial explains the key concepts of SAP ABAP.


2.Overview:

ABAP: Advanced Business Application Programming

3-tier Client/Server Architecture:

  • Presentation

  • Application

  • Database

ABAP works in application tier. Technical distribution of software is independent of its physical distribution (different levels can be installed in the same computer. A level can be installed in different computers).


ABAP programs reside the SAP database. They execute under the control of the runtime system that is a part of SAP kernel. But unlike java, ABAP programs are not stored in separate external files.


ABAP code exists in two forms:

  • Source

  • Generated Code : binary representation, like byte code in java


3.Environment:

How?

  • Open ABAP editor: SE38

  • Name the program Z……  (Z ensures the customer namespace)

  • Create

  • Execute


4.Basic Syntax:

  • Begin with REPORT

  • End with period.

  • Colon notation: Combine different states.

  • Comments:

Full: *

Partial line: “


  • No-Zero: to delete zero( 00000520 ----> 520)

  • SKIP: inserting blank line on the page

  • Message


5.Data Types

Numeric types, Character types, Hexadecimal type

  • X : byte field     

  • C : Text field     

  • I  : Integer

  • F : Floating point

If you don’t care about rounding error

  • P : Packed number : 壓縮存儲,a number’s every digit are represented as a number.

If you should ensure the accuracy

  • STRING: Text String


6.Variables


Data <f> TYPE <type> VALUE <val> .

Data <val2> LIKE <val>.


Kinds of variables:

  • Static Variables:

  • Reference Variables:

  • System Variables: predefined in SAP


7. Constant & Literal


Literal:

  • Numeric literal: 183, 143

  • Character literal:

Constant:

  • CONSTANT <f> TYPE <type> VALUE <val>

8. Operator:

Four categories;

  • Arithmetic operators :

  • Comparison:

<> NE

A1 BETWEEN a2 AND a3

IS INITIAL

IS NOT INITIAL

  • Bitwise operators:

BIT-NOT

BIT-AND

BIT-XOR

BIT-OR

  • Character String Operator: There are many string operators we can use.


9. Loop control:

  • WHILE

  • Do

  • Nested loop

Loop control statement:

  • Continue

  • CHECK: if the condition is wrong, skip to another loop.

  • EXIT


10. Decisions:

  • IF :


11. String:

  • STRLEN() : length of a string

  • There are also other operations to manipulate strings


12. Date&Time:


13. Formatting data


14. Exception:

TRY…...CATCH


15. Directory:

The directory is used to create and manage data definition and to create Tables, Data Elements, Domains, Views and Types.


Basic Types in ABAP Directory

  • Data elements

  • Structure

  • Table types


16. Domain


17. Structures:



18. Views

A view acts like a database table only. But it will not occupy storage space.


19. Search help


20. Lock Objects

Synchronize access to the same data by more than one program.


21. Modularization

Modularization involves the organization of programs into modular units, also known as logical blocks.

Different types of modulation units called from ABAP program:

  • Macros : 只能在被定義的program裏reuse.

  • Include Program : 在不同的programs裏複用,

  • Subroutine : 一般也是用在同一個program裏, 但是也可以被外部program調用

  • Function module : 儲存在central library. 可以被所有programs調用,甚至可以被外部non-SAP系統調用

  • Methods : 面向對象編程

Different types of modulation units called from ABAP runtime:

  • Event Block :

  • Dialog Modules :


22. Subroutine:

Subroutine在一個program裏定義,可以被自己和其他的program調用(一般只被自己調用)




23. Macros

我們可以在同一個program裏定義宏。一個宏可以有9個佔位符。


24. Function module

  • Build function module: SE37


25. Include Program

Include program不能單獨運行,它在原理上就是複製粘貼。

Include program 不能傳遞參數, 不能調用自身。

用的時候,其實就相當於複製粘貼了一段代碼,既不能傳遞參數,又不能調用自身。


26. Open SQL:

Open SQL 是SAP系統中用於操作SQL數據庫的一組statements(read, modify, delete, etc)。它不依賴與數據庫的種類,可以爲我們提供統一的數據操作指令。

各個操作語句的使用可以參考: http://www.saphub.com/abap-tutorial/

操作語句如下:


27. Internal tables:

Internal tables是一個臨時表(生命週期是從program開始到結束)。 用來臨時存儲數據,操作數據。

定義: 利用DATA + TABLE OF來定義內部表。

我們也可以用APPEND來給內部表直接賦值(定義一個與內部表 I_T結構相同變量 tmp-->填充 tmp --> tmp賦給I_T)


通常內部表用到的場景就是:從數據庫中取出數據放到內部表用來 1)打印 2)進一步處理。我們可以利用Select來進行。

兩種方法:

  • 利用臨時tmp

  • 直接將table導入


可以找到關於內部表的所有操作詳情:

http://www.saphub.com/abap-tutorial/


28. Object Orientation

ABAP開始是過程性語言,但後來按照面向對象進行了改造,像是JAVA和C++一樣有了面向對象的一套東西(類,多態, etc)

  • 聲明類:

  • 創建實例:


  • 繼承

  • 多態

  • 封裝

  • 接口




29. Report programming


30. Dialog programming


31. Smart forms


32. SAPscripts


33. Customer Exits


34. User Exits


35. Business Add-Ins


36. Web Dynpro


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章