2010/11/25

ABAP程式設計師要懂的103個問題

1. What is the typical structure of an ABAP program? 
2. What are field symbols and field groups.? Have you used "component idx of structure" clause with field groups? 
3. What should be the approach for writing a BDC program? 
4. What is a batch input session? 
5. What is the alternative to batch input session? 
6. A situation: An ABAP program creates a batch input session. We need to submit the program and the batch session in background. How to do it? 
7. What is the difference between a pool table and a transparent table and how they are stored at the database level? 
8. What are the problems in processing batch input sessions? How is batch input process different from processing on line? 
9. What do you define in the domain and data element? 
10. What are the different types of data dictionary objects? 
11. How many types of tables exists and what are they in data dictionary? 
12. What is the step by step process to create a table in data dictionary? 
13. Can a transparent table exist in data dictionary but not in the data base physically? 
14. What are the domains and data elements? 
15. Can you create a table with fields not referring to data elements? 
16. What is the advantage of structures? How do you use them in the ABAP programs?
17. What does an extract statement do in the ABAP program? 
18. What is a collect statement? How is it different from append? 
19. What is open sql vs native sql? 
20. What does an EXEC SQL stmt do in ABAP? What is the disadvantage of using it? 
21. What is the meaning of ABAP editor integrated with ABAP data dictionary? 
22. What are the events in ABAP language? 
23. What is an interactive report? What is the obvious diff of such report compared with classical type reports? 
24. What is a drill down report? 
25. How do you write a function module in SAP? describe. 
26. What are the exceptions in function module? 
27. What is a function group? 
28. How are the date abd time field values stored in SAP? 
29. What are the fields in a BDC_Tab Table. 
30. Name a few data dictionary objects? 
31. What happens when a table is activated in DD? 
32. What is a check table and what is a value table? 
33. What are match codes? describe? 
34. What transactions do you use for data analysis? 
35. What is table maintenance generator? 
36. What are ranges? What are number ranges? 
37. What are select options and what is the diff from parameters? 
38. How do you validate the selection criteria of a report? And how do you display initial values in a selection screen? 
39. What are selection texts? 
40. What is CTS and what do you know about it? 
41. When a program is created and need to be transported to prodn does selection texts always go with it? if not how do you make sure? Can you change the CTS entries? How do you do it? 
42. What is the client concept in SAP? What is the meaning of client independent? 
43. Are programs client dependent? 
44. Name a few system global variables you can use in ABAP programs? 
45. What are internal tables? How do you get the number of lines in an internal table? How to use a specific number occurs statement?
46. How do you take care of performance issues in your ABAP programs? 
47. What are datasets? 
48. How to find the return code of a stmt in ABAP programs? 
49. What are interface/conversion programs in SAP? 
50. Have you used SAP supplied programs to load master data? 
51. What are the techniques involved in using SAP supplied programs? Do you prefer to write your own programs to load master data? Why?
52. What are logical databases? What are the advantages/disadvantages of logical databases? 
53. What specific statements do you using when writing a drill down report? 
54. What are different tools to report data in SAP? What all have you used? 
55. What are the advantages and disadvantages of ABAP query tool? 
56. What are the functional areas? User groups? and how does ABAP query work in relation to these? 
57. Is a logical database a requirement/must to write an ABAP query? 
58. What is the structure of a BDC sessions. 
59. What are Change header/detail tables? Have you used them? 
60. What do you do when the system crashes in the middle of a BDC batch session? 
61. What do you do with errors in BDC batch sessions? 
62. How do you set up background jobs in SAP? What are the steps? What are the event driven batch jobs? 
63. Is it possible to run host command from SAP environment? How do you run? 
64. What kind of financial periods exist in SAP? What is the relavent table for that? 
65. Does SAP handle multiple currencies? Multiple languages? 
66. What is a currency factoring technique? 
67. How do you document ABAP programs? Do you use program documentation menu option? 
68. What is SAPscript and layout set? 
69. What are the ABAP commands that link to a layout set? 
70. What is output determination? 
71. What are IDOCs? 
72. What are screen painter? menu painter? Gui status? ..etc. 
73. What is screen flow logic? What are the sections in it? Explain PAI and PBO. 
74. Overall how do you write transaction programs in SAP? 
75. Does SAP has a GUI screen painter or not? If yes what operating systems is it available on? What is the other type of screen painter called? 
76. What are step loops? How do you program pagedown pageup in step loops? 
77. Is ABAP a GUI language? 
78. Normally how many and what files get created when a transaction program is written? What is the XXXXXTOP program? 
79. What are the include programs? 
80. Can you call a subroutine of one program from another program? 
81. What are user exits? What is involved in writing them? What precations are needed? 
82. What are RFCs? How do you write RFCs on SAP side? 
83. What are the general naming conventions of ABAP programs? 
84. How do you find if a logical database exists for your program requrements? 
85. How do you find the tables to report from when the user just tell you the transaction he uses? And all the underlying data is from SAP structures? 
86. How do you find the menu path for a given transaction in SAP? 
87. What are the different modules of SAP? 
88. What is IMG in SAP? 
89. How do you get help in ABAP? 
90. What are different ABAP editors? What are the differences? 
91. What are the different elements in layout sets? 
92. Can you use if then else, perform ..etc statements in sap script? 
93. What type of variables normally used in sap script to output data? 
94. How do you number pages in sapscript layout outputs? 
95. What takes most time in SAP script programming? 
96. How do you use tab sets in layout sets? 
97. How do you backup sapscript layout sets? Can you download and upload? How? 
98. What are presentation and application servers in SAP? 
99. In an ABAP program how do you access data that exists on a presentation server vs on an application server? 
100. What are different data types in ABAP? 
101. What is difference between BDC and Call Transaction? 
102. Setting up a BDC program where you find information from? 
103. What has to be done to the packed fields before submitting to a BDC session. 


Quoted from: http://aspromise.pixnet.net/blog/post/19896714

Fields of Internal Tables

SY-TABIX 
Current line of an internal table. SY-TABIX is set by the statements below, but only for index tables. The field is either not set or is set to 0 for hashed tables. 

APPEND sets SY-TABIX to the index of the last line of the table, that is, it contains the overall number of entries in the table. 

COLLECT sets SY-TABIX to the index of the existing or inserted line in the table. If the table has the type HASHED TABLE, SY-TABIX is set to 0.

LOOP AT sets SY-TABIX to the index of the current line at the beginning of each loop lass. At the end of the loop, SY-TABIX is reset to the value that it had before entering the loop. It is set to 0 if the table has the type HASHED TABLE. 

READ TABLE sets SY-TABIX to the index of the table line read. If you use a binary search, and the system does not find a line, SY-TABIX contains the total number of lines, or one more than the total number of lines. SY-INDEX is undefined if a linear search fails to return an entry. 

SEARCH FOR sets SY-TABIX to the index of the table line in which the search string is found.

SY-TFILL
After the statements DESCRIBE TABLE, LOOP AT, and READ TABLE, SY-TFILL contains the number of lines in the relevant internal table. 

SY-TLENG
After the statements DESCRIBE TABLE, LOOP AT, and READ TABLE, SY-TLENG contains the length of the lines in the relevant internal table. 

SY-TOCCU
After the statements DESCRIBE TABLE, LOOP AT, and READ TABLE, SY-TLENG contains the initial amount of memory allocated to the relevant internal table.

Quoted from: http://www.sap-img.com/ab009.htm

Internal table in ABAP

*An internal table is a run time instance.  It get created when program starts execution.
*It get destroyed when program terminates. it has two different parts.  HeaderLine(optional) & Body(Compulsory).
*Any value that comes to or goes from interanal table , that travels through headerline.\

*A related program is .
*declaration.


data: begin of inernaltable occurs 0,
         x type c,
         y type i,
      end of itab.


*initializing headerline
   internaltable-x = 'd'.
   internaltable-y = 34.
  
*storing value into internal table
appene internaltable . 
appene internaltable .
appene internaltable .


*reading internal table
loop at itab .
   write: / internaltable-x, internaltable-y.  "writes to output list
endloop.


Quoted from: http://www.sap-img.com/ab009.htm

ABAP基礎知識學習

資料類型
C :字串
D :日期型 格式為 YYYYMMDD 例:'1999/12/03'
F : 浮點數 長度為8
I :整數
N :數值組成的字串 如:011,'302'
P : PACKED數 用於小數點數值 如:12.00542
T : 時間 格式為:HHMMSS 如:'14:03:00'
X : 16進制數 如:'1A03'
*-------------------------------------------------------------------------------------*
變數宣告

DATA [] [][decimals]
變數名稱
變數類型 及 長度
初值
小數位數

exp:
DATA : COUNTER TYPE P DECIMALS 3.
NAME(10) TYPE C VALUE 'DELTA'.
S_DATE TYPE D VALUE '19991203'.
exp:
DATA : BEGIN OF PERSON,
NAME(10) TYPE C,
AGE TYPE I,
WEIGHT TYPE DECIMALS 2,
END OF PERSON.
另外,有關DATA宣告的指令還有: CONSTANTS(宣告常數)、STATICS(臨時變數宣告).
exp:
CONSTANTS PI TYPE P DECIMALS 5 VALUE '3.14159'.
STATICS 敘述
宣告的變數僅在目前的程式中使用, 結束後會自動釋放
語法:
STATICS [] [] []

系統專用變數說明
系統內部專門創建了SYST這個STRUCTURE,裏面的欄位存放系統變數,常用的系統變數有:
SY-SUBRC : 系統執行某指令後,表示執行成功與否的變數,'0' 表示成功
SY-UNAME: 當前使用者登入SAP的USERNAME;
SY-DATUM: 當前系統日期;
SY-UZEIT: 當前系統時間;
SY-TCODE: 當前執行程式的Transaction code
SY-INDEX : 當前LOOP循環過的次數
SY-TABIX: 當前處理的是internal table 的第幾筆
SY-TMAXL: Internal table的總筆數
SY-SROWS: 螢幕總行數;
SY-SCOLS: 螢幕總列數;
SY-MANDT: CLIENT NUMBER
SY-VLINE: 畫豎線
SY-ULINE: 畫橫線

TYPE 敘述
用來指定資料型態或宣告自定資料型態
Example:
TYPES: BEGIN OF MYLIST,
NAME(10) TYPE C,
NUMBER TYPE I,
END OF MYLIST.
DATA LIST TYPE MYLIST.

LIKE 敘述
跟TYPE敘述使用格式相同, 如
DATA TRANSCODE LIKE SY-TCODE.
不同的是 LIKE 用在已有值的資料項, 如系統變數, 而TYPE敘述則是用
在指定資料型態。

*-------------------------------------------------------------------------------------*
輸出

一. WRITE 語句
ABAP/4用來在螢幕上輸出資料的指令是WRITE指令,例如:
WRITE: 'USER NAME IS:', SY-UNAME.
二. 指定螢幕輸出位置
指定輸出位置的語句格式為:
WRITE: [AT] [ / ] [] [()] 資料項 []
其中: / : 在下一行輸出
: 指定輸出的行號;
():指定輸出位數(長度)
: 指定顯示格式參數,參數有:
LEFT-JUSTIFIED 資料*左對齊
CENTERED 資料*中間對齊
RIGHT-JUSTIFIED 資料*右對齊
UNDER 正對在資料項的下麵顯示
NO-GAP 緊接著顯示,不留空格
USING EDIT MASK : 使用內嵌子元顯示, 如 12:03:20
USING NO EDIT MASK: 不使用內嵌子元
NO-ZER 數字前面 0 的部分不顯示
NO-SIGN: 不顯示正負號
DECIMALS : 顯示 位小數
EXPOENT : F(浮點數)指數的值
ROUND : 四捨五入至小數點後位
CURRENCY : 幣別顯示
DD/MM/YY : 日期顯示格式
MM/DD/YY:
YY/MM/DD:
YY/DD/MM
MM/DD/YYYY:
DD/MM/YYYY
YYYY/MM/DD:
YYYY/DD/MM:
例如1: WRITE: /10(6) 'ABCDEFGHIJK'.
輸出結果為: ABCDEF
例如2: DATA: X TYPE I VALUE '11:20:30',
A(5) TYPE C VALUE 'AB CDE'.
WRITE: / X USING EDIT MASK '__:__:__'.
WRITE: / X USING EDIT MASK '$___,___'.
WRITE: / Y NO-GAP.
輸出結果為:
11:20:30
$112,030
ABCDEF

例如3: DATA: LEN TYPE I VALUE 10,
POS TYPE I VALUE 11,
TEXT(10) VALUE '1234567890'
WRITE 'The text ------------ appears in the text.'.
WRITE AT POS(LEN) TEXT.

WRITE TO 語句的基本 形式
要將值(文 字)或源字 段內容寫入 目標欄位, 可以使用 WRITE TO 語句:
語法
WRITE TO [].

DATA: NUMBER TYPE F VALUE '4.3',
TEXT(10),
FLOAT TYPE F,
PACK TYPE P DECIMALS 1.
WRITE NUMBER.
WRITE NUMBER TO TEXT EXPONENT 2.
WRITE / TEXT.
WRITE NUMBER TO FLOAT.
WRITE / FLOAT.
WRITE NUMBER TO PACK.
WRITE / PACK.
MOVE NUMBER TO PACK.
WRITE / PACK.

exp:
DATA: NAME(10) VALUE 'SOURCE',
SOURCE(10) VALUE 'Antony',
TARGET(10).
...
WRITE (NAME) TO TARGET.
WRITE: TARGET.

exp :

DATA: COUNTER TYPE I.
COMPUTE COUNTER = COUNTER + 1.
COUNTER = COUNTER + 1.
ADD 1 TO COUNTER.
在此,三條 運算語句進 行相同算術 運算

輸出螢幕上 的線和空行

用下列語法 ,可以在輸 出螢幕上生 成水平線:
語法
ULINE [AT [/][][()]].
它等同於
WRITE [AT [/][][()]] SY-ULINE.
AT 後的格式規 範,與在 在螢幕上定 位元 WRITE 輸出 (頁 28) 中為 WRITE 語句說明的 格式規範完 全一樣。
如果沒有格 式規範,系 統則開始新 的一行,並 用水平線填 充該行。否 則,只按指 定輸出水準 線。
生成水平線 的另一種方 法,是在 WRITE 語句中鍵入 恰當數量的 連字元,如 下所示:
WRITE [AT [/][][()]] '-----...'.
垂直線
用下列語法 ,可以在輸 出螢幕上生 成垂直線:
語法
WRITE [AT [/][]] SY-VLINE.

WRITE [AT [/][]] '|'.
空行
用下列語法 ,可以在輸 出螢幕上生 成空行:
語法
SKIP [].
該語句從當 前行開始, 在輸出螢幕 上生成 個空行。如 果沒有指定 的值,就輸 出一個空行 。
要將輸出定 位元在螢幕的 指定行上, 請使用:
語法
SKIP TO LINE .
該語句允許 將輸出位置 向上或向下 移動。


四. 顯示圖示:
語法: WRITE: AS SYMBOL.
WRITE: AS ICON.
例如: INCLUDE .
INCLUDE .
WRITE: / 'Phone symbol:', SYM_PHONE AS SYMBOL.
WRITE: / 'Alarm Icon:', ICON_VOICE_OUTPUT AS ICON.
要查看系統所提供有那些符號及圖示,可選擇'EDIT'下的'Insert Statement',選擇'Write',接下來選擇要查看的群組,如SYMBOL 或ICON, 接下來按'Display'即可.
*-------------------------------------------------------------------------------------*

一. Internal Table 的宣告
ABAP/4中的Internal Table是一種Data Structure,類似於其他語言中的STRUTURE,它可以由幾個不同類型的欄位(field)組成,用來表示具有不同屬性的某一事物,單獨一筆資料表示某個事物,多筆資料表示具有相同屬性的多個事物.

Internal table 的定義有以下幾種格式:
格式一. DATA: BEGIN OF OCCURS ,
TYPE ,
[ TYPE ,
TYPE ,
… ]
END OF .
語法:
DATA OCCURS [WITH HEADER LINE]
Example:
DATA VECTOR TYPE I OCCURS 10 WITH HEADER LINE.

格式二. TYPES: BEGIN OF ,
TYPE ,
[ TYPE ,
TYPE ,
… ]
END OF .
TYPES TYPE OCCURS .

格式三. DATA: BEGIN OF .
INCLUDE STRUCTURE .
DATA: END OF .
DATA: LIKE OCCURS .

exp:

TYPES VECTOR TYPE I OCCURS 10.
TYPES: BEGIN OF LINE,
COLUMN1 TYPE I,
COLUMN2 TYPE I,
COLUMN3 TYPE I,
END OF LINE.
TYPES ITAB TYPE LINE OCCURS 10.
TYPES: BEGIN OF DEEPLINE,
TABLE1 TYPE VECTOR,
TABLE2 TYPE ITAB,
END OF DEEPLINE.
TYPES DEEPTABLE TYPE DEEPLINE OCCURS 10.
本示例創建 與上例相同 的內表資料 類型(VECTOR 和 ITAB) 。然後創建 資料類型 DEEPLINE 作為欄位串 ,包含這些 內表作為組 件。通過該 欄位串,數 據類型 DEEPTABLE 被創建為內 表。因此該 內表的元素 本身就是內 表。
exp :
TYPES: BEGIN OF LINE,
COLUMN1 TYPE I,
COLUMN2 TYPE I,
COLUMN3 TYPE I,
END OF LINE.
TYPES ITAB TYPE LINE OCCURS 10.
DATA TAB1 TYPE ITAB.
DATA TAB2 LIKE TAB1 WITH HEADER LINE.
同 創建內表數 據類型 (頁 99) 中所示,該 示例創建數 據類型 ITAB 作為內表。 通過使用 DATA 語句的 TYPE 參數引用 ITAB, 使資料物件 TAB1 與 ITAB 結構相同。 通過使用 DATA 語句的 LIKE 參數引用 TAB1, 使資料物件 TAB2 結構相同。 創建的 TAB2 帶表頭行。 因此,可以 在程式中使 用 TAB2-COLUMN1、 TAB2-COLUMN2 和 TAB2-COLUMN3 等定位表格 工作區域 TAB2。
exp :

DATA FLIGHT_TAB LIKE SFLIGHT OCCURS 10.
本示例創建 資料物件 FLIGHT_TAB, 其結構與數 據庫表格 SFLIGHT 相同。

本示例介紹 如何採用兩 種不同的步 驟創建同一 內表。
TYPES VECTOR_TYPE TYPE I OCCURS 10.
DATA VECTOR TYPE VECTOR_TYPE WITH HEADER LINE.
在此創建一 個內表資料 類型 VECTOR_TYPE, 其行包含首 先創建的基 本類型 I 欄位。然後 ,通過引用 VECTOR_TYPE 創建資料對 象 VECTOR。 通過使用 WITH HEADER LINE 選項還創建 表格工作區 域 VECTOR。 在這種情況 下,表格工 作區域包含 一種類型 I 欄位,可以 通過名稱 VECTOR 定位。
DATA VECTOR TYPE I OCCURS 10 WITH HEADER LINE.
在這種情況 下,通過直 接在 DATA 語句中使用 OCCURS 選項創建完 全一樣的數 據類型 VECTOR。
*-------------------------------------------------------------------------------------*
1. TYPES type.
2. TYPES type(len).
3. TYPES: BEGIN OF structype ...
END OF structype.
4. TYPES itabtype {TYPE tabkind OF linetype LIKE tabkind OF lineobj}
[WITH [UNIQUE|NON-UNIQUE] keydef] [INITIAL SIZE n].
5. TYPES itabtype TYPE RANGE OF type.
TYPES itabtype LIKE RANGE OF f.
6. TYPES itabtype {TYPE linetype|LIKE lineobj} OCCURS n.

*-------------------------------------------------------------------------------------*

APPEND LINE
格式:APPEND TO

舉例一:(使用WORK AREA)
DATA : BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA ITAB LIKE LINE OCCURS 10.
DO 2 TIMES.
LINE-COL1 = SY-INDEX.
LINE-COL2 = SY-INDEX ** 2.
APPEND LINE TO ITAB.
ENDDO.
LOOP AT ITAB INTO LINE.
WRITE : / LINE-COL1,LINE-COL2.
ENDLOOP.

舉例二 (不使用WORK AREA)
DATA : BEGIN OF ITAB OCCURS 10,
COL1 TYPE I,
COL2 TYPE I,
END OF ITAB.
DO 2 TIMES.
ITAB-COL1 = SY-INDEX.
ITAB-COL2 = SY-INDEX ** 2.
APPEND ITAB.
ENDDO.
LOOP AT ITAB.
WRITE : / ITAB-COL1,ITAB-COL2.
ENDLOOP.

exp:

DATA: BEGIN OF ITAB OCCURS 10,
COL1 TYPE C,
COL2 TYPE I,
END OF ITAB.
DO 3 TIMES.
APPEND INITIAL LINE TO ITAB.
ITAB-COL1 = SY-INDEX. ITAB-COL2 = SY-INDEX ** 2.
APPEND ITAB.
ENDDO.
LOOP AT ITAB.
WRITE: / ITAB-COL1, ITAB-COL2.
ENDLOOP.

舉例三. (加入另一個Internal table的元素)
格式: APPEND LINES OF [FROM ] [TO ] TO .
將的元素加入至中,可選取自至的範圍.
APPEND LINES OF ITAB TO JTAB.

COLLECT LINE
COLLECT 指令也是將元素加入Internal table中,與APPEND 的區別是: COLLECT指令在非數值欄位相同的情況下,將數值欄位匯總.
格式: COLLECT [ INTO ]
DATA: BEGIN OF ITAB OCCURS 3,
COL1(3) TYPE C,
COL2 TYPE I,
END OF ITAB.
ITAB-COL1 = 'ABC'. ITAB-COL2 = 10.
COLLECT ITAB.
ITAB-COL1 = 'XYZ'. ITAB-COL2 = 20.
COLLECT ITAB.
ITAB-COL1 = 'ABC'. ITAB-COL2 = 80.
COLLECT ITAB.
此時, internal table中放的是2筆數據, 分別為:
ITAB-COL1 ITAB-COL2
'ABC' 90
'XYZ' 20
*-------------------------------------------------------------------------------------*

INSERT LINE
將元素插入在指定的internal table位置之前.
格式: INSERT [ INTO] [INITIAL LINE INTO ] [INDEX ]
或者: INSERT LINES OF [FROM TO ] INTO INDEX
其中: 即work area,工作區中的元素.
[INITIAL LINE INTO] :插入一筆初始化的記錄.
: internal table
[INDEX ]: internal table 的記錄號.(新加入的元素放在此記錄前面)

Example:
DATA: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA ITAB LIKE LINE OCCURS 10.
DO 3 TIMES.
LINE-COL1 = SY-INDEX *10.
LINE-COL2 = SY-INDEX *20.
APPEND LINE INTO ITAB.
ENDDO.
LINE-COL1=100.
LINE-COL2=200.
INSERT LINE INTO ITAB INDEX 2. "插入在位置2之前
LOOP AT ITAB INTO LINE.
WRITE: / SY-TABIX,LINE-COL1,LINE-COL2. "SY-TABIX為Table位置
ENDLOOP.
執行結果:
1 10 20
2 100 200 "插入的元素
3 20 40
4 30 60

插入另一Internal Table元素
語法:
INSERT LINES OF [FROM TO ] TO INDEX
將的元素插入至中, 位置在 之前, 可選取自至的範圍
Example:
APPEND LINES OF ITAB TO JTAB INDEX 3.
將ITAB所有元素插入JTAB中, 位置在第三個元素之前
*-------------------------------------------------------------------------------------*
讀取internal table
格式一:
LOOP AT [INTO ][FROM TO ][WHERE ]

ENDLOOP.

Example:
LOOP AT ITAB INTO LINE WHERE COL1 >100.
WRITE: / SY-TABIX,LINE-COL1.
ENDLOOP.
僅讀取 COL1 > 100 的元素

格式二:
READ TABLE [INTO ] [INDEX / WITH KEY ]
舉例. (格式二)
DATA: BEGIN OF ITAB OCCURS 10,
COL1 TYPE I,
COL2 TYPE I,
END OF ITAB.
DO 10 TIMES.
ITAB-COL1 = SY-INDEX.
ITAB-COL2 = SY-INDEX * 2.
APPEND ITAB.
ENDDO.
READ TABLE ITAB INDEX 3.
(或者: READ TABLE ITAB WITH KEY COL1 = 3.)
WRITE: / 'ITAB-COL1 = ', ITAB-COL1, 'ITAB-COL2 = ', ITAB-COL2.
執行結果同樣是:
ITAB-COL1 = 3
ITAB-COL2 = 6.

Example:
READ TABLE ITAB INTO LINE INDEX 5
讀取 ITAB的第5個元素資料, 放入 LINE的欄位中

根據欄位內容尋找
語法:
READ TABLE INTO
Example:
ITAB-COL1 = 'ABC'.
READ TABLE ITAB INTO LINE.
找出ITAB 中 COL1 欄位內容是 ABC 的元素, 找到的值放入 LINE 中
若找到 SY-SUBRC傳回0, 找不到則傳回 4, 必須宣告有 work area
*-------------------------------------------------------------------------------------*

修改internal table 中的值
格式: MODIFY [FROM ][INDEX ][TRANSPORTING …][WHERE ]
舉例一. READ TABLE ITAB INDEX 3.
LINE-COL1 = 29.
MODIFY ITAB FROM LINE TRANSPORTING COL1.
將第三筆記錄的COL1欄位的值修改為29.
舉例二. T_SALARY - salary = 50.
MODIFY T_SALARY TRANSPORTING salary WHERE birthday = '1999/12/06'.

DELETE internal table中的欄位
格式: DELETE INDEX .
或: DELETE [FROM TO ] [WHERE ]

Internal table 排序
SORT [][BY …]
其中: 有DESCENDING 和ASCENDING, Default 為ASCENDING.
: 為指定排序的欄位.
Example:
SORT ITAB DESCENDING BY COL2.
將 ITAB 根據 COL2欄位遞減排序
*-------------------------------------------------------------------------------------*
確定內表屬 性
如果在處理 過程中想知 道內表一共 包含多少行 ,或者想知 道定義的 OCCURS 參數的大小 ,請使用 DESCRIBE 語句,用法 如下:
語法
DESCRIBE TABLE [LINES ] [OCCURS ].
如果使用 LINES 參數,則將 填充行的數 量寫入變數 。 如果使用 OCCURS 參數,則將 行的初始號 寫入變數 。

DATA: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA ITAB LIKE LINE OCCURS 10.
DATA: LIN TYPE I, OCC TYPE I.
DESCRIBE TABLE ITAB LINES LIN OCCURS OCC.
WRITE: / LIN, OCC.
DO 1000 TIMES.
LINE-COL1 = SY-INDEX.
LINE-COL2 = SY-INDEX ** 2.
APPEND LINE TO ITAB.
ENDDO.
DESCRIBE TABLE ITAB LINES LIN OCCURS OCC.
WRITE: / LIN, OCC.
其輸出為:
0 10
1.000 10
在此創建內 表 ITAB。 在填充表格 前後執行 DESCRIBE 語句。更改 當前行號, 但無法更改 初始行號。
*-------------------------------------------------------------------------------------*
加總
SUM.
總和計算存放與work area中,但只能在LOOP 中使用.
例: LOOP AT ITAB INTO LINE.
SUM.
ENDLOOP.
WRITE: / LINE-COL1, LINE-COL2.
LINE-COL1 和 LINE-COL2 存數值總和初始化internal table

REFRESH . 清空中的值.使用在沒有 HEADER LINE 的 Internal Table中, 清除所有元素
CLEAR . 清空的Header Line.使用在有 HEADER LINE 的 Internal Table中, 清除所有元素
FREE . 釋放記憶體空間.釋放(Release) Internal Table所佔的記憶體空間, 用在 REFRESH和 CLEAR指令之後

將值重置為 預設值

可以用 CLEAR 語句重置任 何資料物件 值,如下所 示:
語法
CLEAR .

exp:
DATA NUMBER TYPE I VALUE '10'.
WRITE NUMBER.
CLEAR NUMBER.
WRITE / NUMBER.
輸出為:
10
0
CLEAR 語句將欄位 NUMBER 的內容從10 重置為默認 值 0。
*-------------------------------------------------------------------------------------*

添加欄位 順序並將結 果賦給另一 個欄位
語法
ADD THEN UNTIL GIVING .
如果 、 、 ... 、 是在記憶體中 相同類型和 長度的等距 欄位序列, 則進行求和 計算並將結 果賦給
添加欄位 順序並將結 果添加到另 一個欄位的 內容中
語法
ADD THEN UNTIL TO .
該語句除了 將欄位總和 添加到 的舊內容中 之外,與上 面語句的工 作方式相同 。
有關其他相 似變體的信 息,參見有 關 ADD 語句的關鍵 字文檔。

DATA: BEGIN OF SERIES,
N1 TYPE I VALUE 10,
N2 TYPE I VALUE 20,
N3 TYPE I VALUE 30,
N4 TYPE I VALUE 40,
N5 TYPE I VALUE 50,
N6 TYPE I VALUE 60,
END OF SERIES.
DATA SUM TYPE I.
ADD SERIES-N1 THEN SERIES-N2 UNTIL SERIES-N5 GIVING SUM.
WRITE SUM.
ADD SERIES-N2 THEN SERIES-N3 UNTIL SERIES-N6 TO SUM.
WRITE / SUM.
輸出如下:
150
350
在此,將 N1 到 N5 元件內容求 和並將其值 賦給欄位 SUM。然 後,將 N2 到 N6組件求 和並將其添 加到 SUM 的值中。
*-------------------------------------------------------------------------------------*

螢幕輸入命令

在ABAP/4中要從螢幕輸入變量, 使用的命令是 PARAMETERS 及SELECTION-OPTIONS:
1. PARAMETER: 輸入一個變量或欄位內容
2. SELECTION-OPTIONS: 使用條件篩選畫面來輸入數據

PARAMETERS 指令
基本的輸入命令, 類似如BASIC的INPUT命令, 但無法使用F格式(浮點數)
語法:
PARAMETERS
[DEFAULT ] [LOWER CASE]
[OBLIGATORY] [AS CHECKBOX]
[RADIOBUTTON GROUP ]
Example:
PARAMETERS: NAME(8),
AGE TYPE I,
BIRTH TYPE D.
執行結果:
在日期的輸入格式上為 MM/DD/YY , MM/DD/YYYY, MMDDYY或MMDDYYYY , 如輸入 020165表 1965年02月01日, 與02/01/65的輸入是一樣的, 日期輸入範圍為西元1950年至2049年
1. DEFAULT
設定輸入的預設值
Example:
PARAMETERS: COMPANY(20) DEFAULT 'DELTA',
BIRTH TYPE D DEFAULT '19650201'.
2. LOWER CASE
ABAP/4預設是將字串輸入值自動轉換為大寫, 加上此參數會將輸入的資料轉成小寫,
3. OBLIGATORY
強制要求輸入, 螢幕上會出現一個 ? , 使用者必須要輸入才可.
4. AS CHECKBOX
輸入 CHECKBOX的格式
Example:
PARAMETERS: TAX AS CHECKBOX DEFAULT 'X',
NTD AS CHECKBOX.
執行結果:

5. RADIOBUTTON GROUP
輸入 RADIO BUTTON GROUP 的方式
Example:
PARAMETERS: BOY RADIOBUTTON GROUP SEX DEFAULT 'X',
GIRL RADIOBUTTON GROUP SEX.
exp :
TABLES SPLFI.
PARAMETERS: LOW LIKE SPFLI-CARRID,
HIGH LIKE SPFLI-CARRID.
SELECT * FROM SPLFI WHERE CARRID BETWEEN LOW AND HIGH.
........
ENDSELECT.
*-------------------------------------------------------------------------------------*

SELECTION-OPTIONS
SELECTION-OPTIONS所輸入的值實際上是放在internal table中的,該Internal table 有四個欄位,分別是:SIGN,OPTION,LOW,HIGH.. 條件篩選檢查條件輸入畫面指令, 輸入條件後可配合SELECT指令自TABLE讀取符合條件的資料, 直接執行或放入 Internal Table中, 條件有四個參數:
1. SIGN:
I: 表篩選條件符合的資料
E: 表篩選條件不符合的資料
2. OPTION: 比較的條件符號
EQ(等於),NE(不等於),GT(大於),LE(小於),CP(包含),NP(不包含)
3. LOW: 最小值
4. HIGH: 最大值
語法:
SELECTION-OPTIONS FOR
Example:
TABLES SPFLI.
SELECT-OPTIONS AIRLINE FOR SPFLI-CONNID.
將條件的輸入值存放入 AIRLINE, 篩選選擇為SPFLI中的CONNID欄位

改變條件輸入格式
1. DEFAULT TO
設定開始結束範圍輸入預設值
Example:
SELECT-OPTIONS AIRLINE FOR SPFLI-CONNID DEFAULT '2042' TO '4555'.
2. NO-EXTENSION
設定不要Multi-Option輸入畫面
3. NO INTERVALS
設定不要區間範圍輸入畫面
4. LOWER CASE
輸入轉換成大寫
5. OBLIGATORY
強制要求輸入



配合 SELECT 命令
條件輸入完後要將符合條件的資料篩選出來, 可配合使用 SELECT 指令
1.使用WHERE <條件式>
Example:
TABLES SPFLI.
SELECT-OPTIONS AIRLINE FOR SPFLI-CONNID.
SELECT * FROM SPFLI WHERE CONNID IN AIRLINE.
WRITE: / SPFLI-CONNID,SPFLI-CITYFROM,SPFLI-CITYTO.
ENDSELECT.
2.使用CHECK參數
Example:
TABLES SPFLI.
SELECT-OPTIONS AIRLINE FOR SPFLI-CONNID.
SELECT * FROM SPFLI.
CHECK AIRLINE.
WRITE: / SPFLI-CONNID,SPFLI-CITYFROM,SPFLI-CITYTO.
ENDSELECT.
*
exp:
TABLES SPFLI.
SELECT-OPTIONS: S_CARRID FOR SPFLI-CARRID,
S_CITYFR FOR SPFLI-CITYFROM,
S_CITYTO FOR SPFLI-CITYTO,
S_CONNID FOR SPFLI-CONNID.
SELECT * FROM SPFLI.
CHECK: SPFLI-CARRID IN S_CARRID,
SPFLI-CITYFR IN S_CITYFR,
SPFLI-CITYTO IN S_CITYTO,
SPFLI-CONNID IN S_CONNID.
WRITE: / SPFLI-CARRID, SPFLI-CONNID,
SPFLI-CITYFROM, SPFLI-CITYTO.
ENDSELECT.

3.使用 IF … IN 敘述
Example:
SELECT-OPTIONS AIRLINE FOR SPFLI-CONNID.
SELECT * FROM SPFLI.
IF SPFLI-CONNID IN AIRLINE.
WRITE: / SPFLI-CONNID,SPFLI-CITYFROM,SPFLI-CITYTO.
ENDIF.
ENDSELECT.
*-------------------------------------------------------------------------------------*

SELECTION-SCREEN
1.產生空白列
語法:
SELECTION-SCREEN SKIP []
Example:
SELECTION-SCREEN SKIP 2.
產生兩列空白列
2.產生底線
語法:
SELECTION-SCREEN ULINE / (length)
Example:
SELECTION-SCREEN ULINE /10(30).
自第10格開始產生長度30的底線
3.印出備註說明
語法:
SELECTION-SCREEN COMMENT / (length)
Example:
REMARK = 'Pls enter your name'.
SELECTION-SCREEN COMMENT /10(30) REMARK.
4. 同一列中輸入數個資料項
語法:
SELECTION-SCREEN BEGIN OF LINE.
……
SELECTION-SCREEN END OF LINE.
Example:
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 20.
PARAMETERS NAME(10).
SELECTION-SCREEN POSITION 40.
PARAMETERS BIRTH TYPE D.
SELECTION-SCREEN END OF LINE.
在20格輸入NAME內容, 40格輸入 BIRTH的內容

5. 繪出BLOCK PANEL
語法:
SELECTION-SCREEN BEGIN OF BLOCK
[WITH FRAME [TITLE

Quote from: http://aspromise.pixnet.net/blog/post/19896724#trackback

2010/11/23

Saint Seiya Soldier Dream Live

聖闘士星矢 (聖闘士星矢北歐編OP 主音影山ヒロノブ)



作詞:只野菜摘/作曲:松澤浩明/編曲:BROADWAY/歌:影山ヒロノブ、BROADWAY/演奏:影山ヒロノブ、BROADWAY

空高くかかげよう
路(みち)を照らす命のきらめき
運命にひかれる\r
それは星座の神話さ ソルジャー.ドリーム
★解き放てよ 燃えるコスモ
 勝利をいだく 明日のために
 聖闘士星矢
 めざす希望の彩(いろ)は
 気高いほど美しい
 聖闘士星矢
 翼は天を駆ける
 選ばれた申し子のように

汚れなき瞳は
暗い闇を つらぬく流星
友情の証は
同じロマンを 求める ソルジャー.ドリーム
立ち止まるな 若き勇者
未来をはばむ ものはないさ
聖闘士星矢
おおらかな ペガサスよ
情熱ほど麗しい
聖闘士星矢
勇気 力 真実
舞い上がれ 導きのままに

★Repeat


Sora takaku kakageyou
Michi o terasu inochi no kirameki
Unmei ni hikareru
Sore wa seiza no shinwa sa Soldier Dream

Toki hanatte yo moeru kosumo
Shoori o idaku asu no tame ni
Saint Seiya
Mezasu kiboo no iro wa
Kedakai hodo utsukushii
Saint Seiya
Tsubasa wa ten wo kakeru
Erabareta moushigo no you ni

Kegare naki hitomi wa
Kurai yami o tsuranuku ryuusei
Yuujou no akashi wa
Onaji roman wo motomeru Soldier Dream

Tachi tomaruna wakaki yuusha
Mirai o habamu mono wa nai sa
Saint Seiya
Ooroka na Pegasasu yo
Jyoonetsu hodo uruwashii
Saint Seiya
Yuuki chikara shinjitsu
Maiagare michibiki no mama ni

Toki hanatte yo moeru kosumo
Shoori o idaku asu no tame ni
Saint Seiya
Mezasu kiboo no iro wa
Kedakai hodo utsukushii
Saint Seiya
Tsubasa wa ten wo kakeru
Erabareta moushigo no you ni

Saint Seiya Pegasus Fantasy Live

ペガサス幻想(pegasus fantasy) Live, 小宇宙燃燒吧!!!
原唱Make-Up樂隊主音山田信夫 (左面) w/ 遠藤正明 (右面)



作詞:竜 真知子、松沢浩明
作曲:山田信夫
歌/編曲:make-up

抱きしめた 心の小宇宙
熱く 燃やせ 奇跡を起こせ
傷ついたままじゃないと
誓いあった 遥かな銀河
*ペガサス幻想 そうさ 夢だけは
誰も奪えない 心の翼だから
聖闘士星矢 少年はみんな
聖闘士星矢 明日の勇者
聖闘士星矢 ペガサスのように
聖闘士星矢 今こそ はばだけ

どこまでも 輝く空に
お前だけの 星座を目指せ
その日まで 負けられないさ
命賭けて 挑んだ バドル
ペガサス幻想 誰もが夢見える
自由という翼広げ 駆けてゆけ
聖闘士星矢 少年はみんな
聖闘士星矢 孤独な戦士
聖闘士星矢 ペガサスのように
聖闘士星矢 今こそ はばだけ

*REPEAT
---------------------------------

dakishimeta kokoro no KOSUMO
atsuku moyase kiseki wo okose
kizutsuita mama ja inai to
chikai atta haruka na ginga

*PEGASASU FANTAJI- sou sa yume dake wa
daremo mo ubaenai kokoro no tsubasa dakara
SEINTO Seiya shounen wa minna
SEINTO Seiya ashita no yuusha oh yeah
SEINTO Seiya PEGASASU no you ni
SEINTO Seiya ima koso habatake

doko made mo kagayaku sora ni
omae dake no seiza wo mezase
sono hi made makerarenai sa
inochi kakete idonda BATORU

PEGASASU FANTAJI- daremo ga yume miru
jiyuu to iu tsubasa hiroge kakete yuke
SEINTO Seiya shounen wa minna
SEINTO Seiya kodoku na senshi oh yeah
SEINTO Seiya PEGASASU no you ni
SEINTO Seiya ima koso habatake

*REPEAT

-------------------------------------------------
緊緊擁抱 心靈的小宇宙
熾熱燃燒 喚發奇跡
不能就這樣受著傷
互相發誓過的 遙遠的銀河
天馬的幻想 不錯,只有夢想
是誰也奪不走的 因為是心靈之翼
聖鬥士星矢 少年都是
聖鬥士星矢 明天的勇士
聖鬥士星矢 就象天馬一樣
聖鬥士星矢 現在就展翅高飛

無限閃爍的天空中
向著只屬於你的星座拼命地挑戰
那一刻為止 決不能輸
拼命地挑戰
天馬的幻想 誰都在夢想
展開自由的翅膀 翱翔吧
聖鬥士星矢 少年都是
聖鬥士星矢 孤獨的戰士
聖鬥士星矢 就象天馬一樣
聖鬥士星矢 現在就展翅高飛

2010/11/10

《明朝那些事兒卷貳: 萬國來朝》簡介

More about 明朝那些事兒(貳)

今集主角落在永樂大帝朱棣身上, 經歷「靖難之役」後,成功奪得皇位, 為鞏固其帝位, 親征驅除韃靼, 修書《太祖實錄》歌頌老子朱元璋及篡改親母以正視聽. 更修築長城, 遷都北京並建成今日的紫禁城, 及功德最高莫過於編纂《永樂大典》的百科全書, 以當時的技術內容包羅萬有, 不止四書五經, 天文地理科學農務集於一身, 比現代維基百科有系統. 為偵查惠帝下落及派遣鄭和七次下西洋, 亦因此建立宏大的海上艦隊, 但並非侵略霸佔其他地方, 只是宣揚大明帝國皇恩浩蕩.

另外其他篇幅包括一代明臣于謙, 「土木堡之變」後為保京城力挽狂瀾.

內容不下於首篇的洪武時代, 絕對令人拍案叫絕.

SAP Basis Training Material

SAP ABAP Troubleshooting