1 / 38

ABAP Dictionary

ABAP Dictionary. What is ABAP Dictionary ? Domain Value Range Data Element Table Table Fields Technical Settings Data Class, Size Category, Buffering, Logging Foreign Keys. 1. What is ABAP Dictionary ?. 集中管理 R/3 系統中被使用到的所有資料定義 建立使用者定義型態、定義 Database objects Defining an input help

wilona
Download Presentation

ABAP Dictionary

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ABAP Dictionary • What is ABAP Dictionary ? • Domain • Value Range • Data Element • Table • Table Fields • Technical Settings • Data Class, Size Category, Buffering, Logging • Foreign Keys

  2. 1. What is ABAP Dictionary ? • 集中管理R/3系統中被使用到的所有資料定義 • 建立使用者定義型態、定義Database objects • Defining an input help • Search Help (F4 help:輸入部分資料時,按此鍵會顯示所有可能值供選擇) • Attaching a field help (F1 help:欄位說明)

  3. 按F1看看 Table 輸入部分值*,按F4看看 (例如sbo*,按f4) Data element Domain ABAP Dictionary:Initial Screen • Transaction Code: SE11 • 或Tools→ ABAP Workbench→ Development→ ABAP Dictionary

  4. Table Table field Data element uses Domain uses ABAP Dictionary Basic Objects 描述在一特定企業背景下,一domain所 代表的意義。包含基本的field help (F1 documentation)及field labels。 定義資料型態及長度,以描述一field之value range

  5. TableSBOOK TableSFLIGHT . . . . . . FORCURAM . . . . . . . . . . . . . . . . . PRICE . . . . . . Data element S_F_CUR_PR Data element S_PRICE Domain S_PRICE Two-Level Domain Concept • Domain reuse:可套用系統預先定義的domains • 不同的data elements可能指定給同一domain • 同理,不同的fields可能指定給同一data element。 票價 運費 長度15,小數2

  6. SBook

  7. 2. Domain • Table 欄位的技術定義 • 獨立存在於ABAP Dictionary • 設定資料型態及長度,以描述一field之value range • 控制fields外觀:output length、uppercase/ lowercase letters

  8. Create a Domain • SE11 • 勾選Domain,輸入欲定義之Domain名稱 (例如zyy**_domain1。yy為民國年,**為自己編號) • 按create按鈕,即可進入編輯畫面 (見下頁) • Short text:簡短敘述 (如zyy**_domain1 domain) • Data type:選擇資料型態(如char) • No. characters:長度 • Decimal Place:小數點位置 • 按Save,選local object(暫時留在本台機器,測試) • 記得save後,一定要按Activate,才會存至底層DB

  9. Domain編輯畫面 Save Activate Enter a description (short text). Enter data type and length. 控制fields外觀.

  10. 2.1 Value Range • Fixed Value • 將fields的值限定在一有限集合內 • 個別設定(Single vals.):以列舉方式設定,例如定義性別之domain,其值可設為M及F • 區間設定(Intervals):設定Lower limit及Upper limit,例如年資為(0,40) • Value Table • 搭配foreign key的定義,value table可變成check table,而具有check之作用 (見p.31-33)

  11. Value Range標籤畫面

  12. 練習:請先建立下表之Domain PS:Domain WAERS為SAP內建之Domain直接套用之即可。

  13. 練習 (Cont.) PS:每完成一object的設定,務必存檔並Activate之,方為正確完成設定。

  14. 練習:建立Domain之Fixed Value • 在Domain zyy**E_SEX下建Fixed value,如下:

  15. 3. Data Element • Table fields的語義定義 • 描述在一特定企業背景下,一domain所代表的意義 • Create a Data Element • SE11 • 勾選Data type,輸入欲定義之Data Element名稱 (如zyy**_id1) • 按create按鈕,即可進入編輯畫面 (見下頁) • Short text:簡短敘述 (如zyy**_id1 data element) • Data type選Elementary type(基本型態) • 若要參考先前定義之Domain,選Domain再輸入Domain名稱 • 若要自行定義,則勾選Built-in type • 按Save,再Activate

  16. Enter a description (short text). Enter domain name. Data Element編輯畫面

  17. 練習 • 請建立p.11-12之Data Element。

  18. Table Fields Foreign Keys Technical Settings Field 2 Field 3 Field 1 Field 4 Indexes 4. Table

  19. Create a Table • SE11 • 勾選Database table,輸入欲定義之Table名稱 (例如zyy**_table1) • 按create按鈕,即可進入編輯畫面 (見下頁) • Short description:簡短敘述 (如zyy**_table1 table) • 在Delivery Class按F4,選Application table (master and transaction data) • 將Table maintenance allowed打勾,表示允許使用者直接輸入資料 (通常不勾,而由程式維護) • Save後,再按Activate

  20. Enter a description (short text). Maintain delivery class Table maintenance allowed Table編輯畫面

  21. 4.1 Table Fields • Domain (建議使用此方式) • 在domain設定data type,指定domain給data element,再指定data element給field。 • Build-in type • 在data element設定data type (即未定義Domain),再指定data element給field。 • Direct type (儘量避免此方式) • 直接在field設定data type,不指定data element。

  22. Maintain field attributes 非空值 見上頁,可輸入data element Data element與直接輸入之切換 輸入欄位名稱 主鍵 Table Fields編輯畫面 見4.2

  23. 4.2 Technical Settings • Data Class • logically defines the physical area of the database in which your table should be stored (存放內容)。 • Size Category • describes the expected storage requirements for the table on the database (預期貯存空間)。 • Buffering • define whether and how the table should be buffered。 • Logging • define whether changes to the table entries should be logged (DB異動是否都記錄下來)。

  24. Maintain Data class Maintain Size category Technical Settings編輯畫面

  25. (1) Data Class • APPL0 (Master data): Data is seldom changed. • Ex: the data contained in an address file, such as name, address, and telephone number. • APPL1 (Transaction data): Data is frequently changed. • Ex: the goods in a warehouse, which change after each purchase order. • APPL2 (Organizational data): Customizing data that is defined when the system is installed and seldom changed. • Ex: the table with country codes.

  26. Technical Settings Size category TABA 1 TABB 3 Initial First Second TABC 4 Extent Extent Extent Database TABA TABA TABB TABB TABC TABC (2) Size Category

  27. (3) Buffering • 直接自application server 的local buffer 讀取table records,排除費時的資料庫存取 • 先勾選buffering switched on,再選以下一種方式: • Full buffering • all the table records are loaded into the buffer when one record of the table is accessed。 • Generic buffering • all the records whose left-justified part of the key is the same are loaded into the buffer when a table record is accessed。 • Single-record buffering • only the record that was accessed is loaded into the buffer。 (buffer最小,但是存取費時)

  28. Buffering實例說明 • 以右下圖Table為例,執行以下SQL指令:SELECT * FROM SCOUNTER WHERE MANDT = ‘001’ AND CARRID = ‘LH’ AND COUNTNUM =‘000004’ • 選full_buffering:整個table的資料都放進buffer contents • 選generic buffering:先判斷generic key為何者,假設為MANDT與CARRID,則放進buffercontents的是001    LH      000001   BER001    LH      000002   FRA001    LH      000004   LCY • 選single-record buffering:僅放 一筆入buffer contents001    LH      000004   LCY

  29. ABAP Dictionary Log TAB Log TAB Application transaction TAB Field 2 Field 3 Field 5 Change a record Database System profiles ... rec /client =ALL TAB Log table ... Field 1 Field 2 Field 3 (4) Logging Logging • 記錄並儲存table內容的修改。

  30. 練習 • 請建立p.11-12之Table及其Fields。

  31. 4.3 Foreign Keys Foreign • A foreign key連結兩個tables • 在Foreign key table輸入資料,必先與另一Check table中已存在的資料核對,以確保資料的一致性。 Foreign

  32. Foreign Keys的必要條件 • The foreign key field and the primary key of the check table must share the same domain. • A value table must exist for that domain.

  33. Enter a description (short text). Enter check table. Maintain Cardinality Foreign Key設定畫面 (A) (B)

  34. 練習 • Domain之Value table • 在Domain zyy**D_ID下,建Value table zyy**_DEP • Table之Foreign Keys • 在Table zyy**_EMP下,設定Foreign Key: • Field DEPID 指到Table zyy**_DEP的DEPID。 • Field CLASS 指到Table zyy**_WAG的CALSS。

  35. Using a Table in Program Code TABLES: SPFLI. SELECT * FROM SPFLI. WRITE: / SPFLI-CONNID, SPFLI-CARRID, SPFLI-CITYFROM, SPFLI-CITYTO. ENDSELECT.

  36. 練習:輸入欄位值 • 手動輸入方法 • 進入Table後,選功能表Utilities → Table Contents → Create Entries 。輸入後save、activate。 A1

  37. 實例練習:實驗室table

  38. 實例練習:老師table

More Related