ABAP Dictionary n n What is ABAP Dictionary
ABAP Dictionary n n What is ABAP Dictionary ? Domain – Value Range n n Data Element Table – Table Fields – Technical Settings • Data Class, Size Category, Buffering, Logging – Foreign Keys 企業資源規劃 楊子青 1
ABAP Dictionary: Initial Screen n Transaction Code: SE 11 – 或Tools→ ABAP Workbench→ Development→ ABAP Dictionary Table Data element 按F 1看看 輸入部分值*,按F 4看看 (例如sbo*,按f 4) Domain 企業資源規劃 楊子青 3
ABAP Dictionary Basic Objects Table field 描述在一特定企業背景下,一domain所 代表的意義。包含基本的field help (F 1 documentation)及field labels。 uses Data element Domain uses 定義資料型態及長度,以描述一field之value range 企業資源規劃 楊子青 4
Two-Level Domain Concept n Domain reuse:可套用系統預先定義的domains – 不同的data elements可能指定給同一domain – 同理,不同的fields可能指定給同一data element。 Table SBOOK Table SFLIGHT . . . FORCURAM . . . . Data element S_F_CUR_PR . . PRICE . . . Data element 票價 S_PRICE Domain S_PRICE 運費 長度 15,小數 2 企業資源規劃 楊子青 5
2. Domain n Table 欄位的技術定義 – 獨立存在於ABAP Dictionary – 設定資料型態及長度,以描述一field之value range – 控制fields外觀:output length、uppercase/ lowercase letters 企業資源規劃 楊子青 7
Domain編輯畫面 Save Activate Enter a description (short text). Enter data type and length. 控制fields外觀. 企業資源規劃 楊子青 9
練習:請先建立下表之Domain Table zyy**_DEP zyy**_WAG Field Data Element Domain Type DEPID zyy**D_ID zyy**D _ID CHAR 5 DEPNAME zyy**D_NAME Build-in type CHAR 20 CLASS zyy**W_CLS zyy**_CLASS CHAR 2 POST zyy**W_POS zyy**_POST CHAR 16 WAGE zyy**W_WAG zyy**_WAGE DEC 9 2 CURRENCY zyy**W_CUR WAERS CUKY 5 PS:Domain WAERS 為SAP內建之Domain直接套用之即可。 企業資源規劃 楊子青 12
練習 (Cont. ) Table zyy**_EMP Field Data Element Domain Type EMPID zyy**E_ID NUMC 5 DEPID zyy**D_ID CHAR 5 NAME zyy**E_NAME Build-in type CHAR 20 CLASS zyy**E_CLS zyy**_CLASS CHAR 2 SEX zyy**E_SEX zyy**_SEX CHAR 2 BIRTH Direct type DATS 8 ADDRESS Direct type CHAR 50 PS:每完成一object的設定,務必存檔並Activate之, 方為正確完成設定。 企業資源規劃 楊子青 13
練習:建立Domain之Fixed Value n 在Domain zyy**E_SEX下建Fixed value, 如下: 企業資源規劃 楊子青 14
Data Element編輯畫面 Enter a description (short text). Enter domain name. 企業資源規劃 楊子青 16
4. Table Fields Foreign Keys Field 1 Technical Settings Field 2 Field 3 Field 4 Indexes 企業資源規劃 楊子青 18
Create a Table n n n SE 11 勾選Database table,輸入欲定義之Table名稱 ( 例如zyy**_table 1) 按create按鈕,即可進入編輯畫面 (見下頁) – Short description:簡短敘述 (如zyy**_table 1 table) – 在Delivery Class按F 4,選Application table (master and transaction data) – 將Table maintenance allowed打勾,表示允許使用者 直接輸入資料 (通常不勾,而由程式維護) – Save後,再按Activate 企業資源規劃 楊子青 19
Table編輯畫面 Enter a description (short text). Maintain delivery class Table maintenance allowed 企業資源規劃 楊子青 20
4. 1 Table Fields n Domain (建議使用此方式) – 在domain設定data type,指定domain給data element, 再指定data element給field。 n Build-in type – 在data element設定data type (即未定義Domain),再 指定data element給field。 n Direct type (儘量避免此方式) – 直接在field設定data type,不指定data element。 企業資源規劃 楊子青 21
4. 2 Technical Settings n Data Class – logically defines the physical area of the database in which your table should be stored (存放內容)。 n Size Category – describes the expected storage requirements for the table on the database (預期貯存空間)。 n Buffering – define whether and how the table should be buffered。 n Logging – define whether changes to the table entries should be logged (DB異動是否都記錄下來)。 企業資源規劃 楊子青 23
Technical Settings編輯畫面 Maintain Data class Maintain Size category 企業資源規劃 楊子青 24
(1) Data Class n APPL 0 (Master data): Data is seldom changed. – Ex: the data contained in an address file, such as name, address, and telephone number. n APPL 1 (Transaction data): Data is frequently changed. – Ex: the goods in a warehouse, which change after each purchase order. n APPL 2 (Organizational data): Customizing data that is defined when the system is installed and seldom changed. – Ex: the table with country codes. 企業資源規劃 楊子青 25
(2) Size Category Initial Extent First Second Extent Technical Settings Size category Database TABA 1 TABB 3 TABC 4 TABA TABB TABC 企業資源規劃 楊子青 26
(3) Buffering n n 直接自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 最小,但是存取費時) 企業資源規劃 楊子青 27
Buffering實例說明 n 以右下圖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,則放進buffer contents 的是 001 LH 000001 BER 001 LH 000002 FRA 001 LH 000004 LCY – 選single-record buffering:僅放 一筆入buffer contents 001 LH 000004 LCY 企業資源規劃 楊子青 28
(4) Logging n 記錄並儲存table內容的修改。 ABAP Dictionary Log TAB Application transaction TAB Field 2 Field 3 Field 5 Change a record Database System profiles . . . rec /client =ALL . . . TAB Field 1 Field 2 Log table Field 3 企業資源規劃 楊子青 29
Foreign Keys的必要條件 n n 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. 企業資源規劃 楊子青 32
Foreign Key設定畫面 Enter a description (short text). (A) Enter check table. Maintain Cardinality (B) 企業資源規劃 楊子青 33
練習 n Domain之Value table – 在Domain zyy**D_ID下,建Value table zyy**_DEP n Table之Foreign Keys – 在Table zyy**_EMP下,設定Foreign Key: • Field DEPID 指到Table zyy**_DEP的DEPID。 • Field CLASS 指到Table zyy**_WAG的CALSS。 企業資源規劃 楊子青 34
Using a Table in Program Code TABLES: SPFLI. SELECT * FROM SPFLI. WRITE: / SPFLI-CONNID, SPFLI-CARRID, SPFLI-CITYFROM, SPFLI-CITYTO. ENDSELECT. 企業資源規劃 楊子青 35
- Slides: 38