Popular Posts
javax.net.ssl.SSLHandshakeException: Connection closed by peer in Android 5.0 Lollipop Recently, there is a error occurs when access website via ssl connection like below although it worked fine several days ago. // Enable SSL... Enable SSL connection for Jsoup import org.jsoup.Connection; import org.jsoup.Jsoup; import javax.net.ssl.*; import java.io.IOException; import java.security.KeyManagement... set/remove cookie using applet jdk/jre 1.4 later, the library is included in plugin.jar file. import java.applet.Applet; import java.util.ArrayList; import java.util.Date;...
Stats
Text Symbols
  1. *&---------------------------------------------------------------------*
  2. *& Report ZA000020 *
  3. *& *
  4. *&---------------------------------------------------------------------*
  5. *& *
  6. *& *
  7. *&---------------------------------------------------------------------*
  8.  
  9. report ZA000020 .
  10.  
  11. write / TEXT-A01. " 文字元件, 類似Resource, 需先建立定義
  12. write / 'Default text value'(A02). " 同上, 可不先建立定義, 若未建立文字內容, 以引號內的內容為預設值
  13.  
  14. *
建立文字內容的方式有
  1. 在source code中, 雙擊文字元件變數, 會跳出對話窗
    按yes即可建立
  2. 在ABAP Editor(SE38)中, 選擇Text elements建立
text elements 編輯畫面
Introductory Statements for Programs
Program Type Introductory Statement
Executable Program REPORT
Module Pool PROGRAM
Function Group FUNCTION-POOL
Class Pool CLASS-POOL
Interface Pool INTERFACE-POOL
Subroutine Pool PROGRAM
Type Group TYPE-POOL
Include Program -
Internal Table: header line
  1. types: begin of POW,
  2. NUM type I,
  3. NUM2 type I,
  4. end of POW.
  5. data: ITAB type POW occurs 0,
  6. ROW type POW.
  7.  
  8. do 5 times.
  9. ROW-NUM = SY-INDEX.
  10. ROW-NUM2 = SY-INDEX ** 2.
  11. append ROW to ITAB.
  12. enddo.
  13.  
  14. * ======================================================================
  15. * "ITAB" is a table without a header line and therefore has no component
  16. * ======================================================================
  17. *do 5 times.
  18. * ITAB-NUM = SY-INDEX + 5.
  19. * ITAB-NUM2 = ITAB-NUM ** 2.
  20. * append ITAB.
  21. *enddo.
  22.  
  23. loop at ITAB into ROW.
  24. write: / 'num:', ROW-NUM left-justified, ', num2:', ROW-NUM2.
  25. endloop.
  1. types: begin of POW,
  2. NUM type I,
  3. NUM2 type I,
  4. end of POW.
  5. data: ITAB type POW occurs 0 with header line,
  6. ROW type POW.
  7.  
  8. do 5 times.
  9. ROW-NUM = SY-INDEX.
  10. ROW-NUM2 = SY-INDEX ** 2.
  11. append ROW to ITAB.
  12. enddo.
  13.  
  14. do 5 times.
  15. ITAB-NUM = SY-INDEX + 5.
  16. ITAB-NUM2 = ITAB-NUM ** 2.
  17. append ITAB.
  18. enddo.
  19.  
  20. loop at ITAB into ROW.
  21. write: / 'num:', ROW-NUM left-justified, ', num2:', ROW-NUM2.
  22. endloop.
Internal Table: declare
  1. types ARR type I occurs 10. " 定義長度為10的數值table/array
  2.  
  3. types: begin of CONTACT, " 定義CONTACTwork area, 並以CONTACT定義內表
  4. FIRST_NAME(15),
  5. LAST_NAME(15),
  6. EMAIL(30),
  7. TEL type N length 12,
  8. end of CONTACT,
  9. CTAB type CONTACT occurs 0.
  10.  
  11.  
  12. data S1 type I occurs 10 with header line. " 宣告包含header line(work area)的表變數
  13. data S2 type I occurs 10. " 宣告無header line的表變數
  14. data S3 type standard table of I. " 取代舊occurs語法的宣告方式
  15.  
  16. data: begin of EMPLOYEE occurs 10, " 宣告EMPLOYEE的表變數, 並定義其欄位
  17. FIRST_NAME(15),
  18. LAST_NAME(15),
  19. TEL type N length 12,
  20. end of EMPLOYEE.
Flow control: loop (while)
  1. data: NUM type I,
  2. STR(1).
  3.  
  4. while SY-INDEX < 10.
  5. STR = SY-INDEX.
  6. NUM = NUM + SY-INDEX.
  7. if SY-INDEX > 1.
  8. write '+'.
  9. endif.
  10. write STR.
  11. endwhile.
  12.  
  13. write: '=', NUM.
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 =          45
Flow control : loop (do)
  1. data: N1(1),
  2. N2(1),
  3. N3(2).
  4.  
  5. do 9 times.
  6. N1 = SY-INDEX.
  7. do 9 times.
  8. N2 = SY-INDEX.
  9. N3 = N1 * N2.
  10. write: N1, 'x', N2, '=', N3, '|'.
  11. enddo.
  12. write SY-ULINE.
  13. enddo.
  1. data: begin of TEXT,
  2. WORD1(4) value 'This',
  3. WORD2(4) value 'is',
  4. WORD3(4) value 'a',
  5. WORD4(4) value 'loop',
  6. end of TEXT.
  7.  
  8. data: STRING1(4), STRING2(4).
  9.  
  10. do 4 times varying STRING1 from TEXT-WORD1 next TEXT-WORD2.
  11. write STRING1.
  12. if STRING1 = 'is'.
  13. STRING1 = 'was'. " TEXT-WORD2的值也會變更
  14. endif.
  15. enddo.
  16. skip.
  17.  
  18. skip.
  19.  
  20. do 2 times varying STRING1 from TEXT-WORD1 next TEXT-WORD3
  21. varying STRING2 from TEXT-WORD2 next TEXT-WORD4.
  22. write: STRING1, STRING2.
  23. enddo.
This is   a    loop

This was  a    loop
  1. data: begin of WORD,
  2. W1(1) value 'a',
  3. W2(1) value 'b',
  4. W3(2) value 'c',
  5. W4(3) value 'd',
  6. W5(4) value 'e',
  7. end of WORD.
  8.  
  9. data LEN type I.
  10. describe field WORD length LEN in character mode. " 以文字模式計算物件長度
  11.  
  12. data STR2(1).
  13. do len times varying STR2 from WORD-W1 next WORD-W2. " STR2, WORD-W1, WORD-W2的類型及長度需相同
  14. write: '(' no-gap, STR2 no-gap, ')'.
  15. enddo.
(a) (b) (c) ( ) (d) ( ) ( ) (e) ( ) ( ) ( )
Flow control : if / case
if ... elseif ... else ... endif
  1. data AGE type I value '12'.
  2.  
  3. if AGE < 0.
  4. write 'Illegal value'.
  5. elseif AGE >= 0 and AGE < 18.
  6. write 'Sorry, this is adult only.'.
  7. else.
  8. write 'Hi, wellcome.'.
  9. endif.
case ... when .... when others ... endcase
  1. data S(2) value 'F'.
  2.  
  3. case S. " case sensitive
  4. when 'F'.
  5. write / 'Hi, girl.'.
  6. when 'M'.
  7. write / 'Hi, boy.'.
  8. when others.
  9. write / 'Who it is?'.
  10. endcase.
Call by value
  1. data: NAME(20) value 'source',
  2. SOURCE(10) value 'Bruce',
  3. TARGET(10).
  4.  
  5. write (NAME) to TARGET. " write ('source') to TARGET.
  6. write / TARGET. " 'Bruce' will be printed
assign value
  1. data: S1(10) value '0123456789',
  2. S2(10).
  3.  
  4. S2 = S1. " move S1 to S2.
  5. write / S2.
  6. clear S2.
  7.  
  8. S2 = S1+5(5). " move S1+5(5) to S2.
  9. write / S2.
  10.  
  11. S2+5(5) = S1(5). " move S1(5) to S2+5.
  12. write / S2.
  13. clear S2.
0123456789
56789
5678901234
  1. data: begin of ADDRESS,
  2. FIRST_NAME(10) value 'Bruce',
  3. LAST_NAME(10) value 'Tsai',
  4. TEL(12) value '28883912',
  5. end of ADDRESS.
  6.  
  7. data: begin of ACCOUNT,
  8. FIRST_NAME(10),
  9. LAST_NAME(10),
  10. EMAIL(50),
  11. end of ACCOUNT.
  12.  
  13. move-corresponding ADDRESS to ACCOUNT.
  14. write / ACCOUNT-FIRST_NAME.
  15. write / ACCOUNT-LAST_NAME.
Bruce
Tsai
Math function
函數 說明
ABS(N) 絕對值
SIGN(N) N>0 : 1, N=0 : 0, N<0 : -1
CEIL(N) 大於N的最小整數值
FLOOR(N) 小於N的最大整數值
TRUNC(N) 整數部份
FRAC(N) 小數部份
COS(N) 餘弦
SIN(N) 正弦
TAN(N) 正切
EXP(N) eN
LOG(N) logeN
LOG10(N) logN
SQRT(N) N的平方根
symbol & icon
  1. include .
  2. include .
  3. write: / 'Phone Symbole:', SYM_PHONE as symbol.
  4. write: / 'Alarm Icon:', ICON_ALARM as icon.
write
語法:
  1. write at [/][<pos>][(<len>)] output
用法:
  1. write 'Bruce'. " 輸出常數
Bruce
  1. data CNAME(10) value 'James'.
  2. write: / CNAME, 'is busy.'. " 輸出變數, 多個值
James      is busy.
  1. data NUM(10) value '0123456789'.
  2. write / NUM. " 輸出變數
  3. write /5 NUM. " 在位置5的地方輸出變數
  4. write /(5) NUM. " 輸出5字元變數
  5. write /5(5) NUM. " 在位置5的地方輸出5字元變數
0123456789  
     0123456789  
01234
     01234
declare
定義資料類型(EMPLOYEE):
TYPES dtype [TYPE type|LIKE dobj] ...
  1. types: begin of EMPLOYEE, " type definition
  2. WID(10) type C,
  3. FIRST_NAME(15) type C,
  4. LAST_NAME(15) type C,
  5. AGE type I,
  6. end of EMPLOYEE.
  7. data EMP1 type EMPLOYEE. " declare variant
  8. types EMP like EMP1. " type definition using exist variant
  9. data EMP2 like EMP1. " declare variant using exist variant
宣告變數(EMPLOYEE):
DATA var [{TYPE type}|{LIKE dobj}] ...
  1. data: begin of EMPLOYEE, " declare variant with structs
  2. WID(10) type C,
  3. FIRST_NAME(15) type C,
  4. LAST_NAME(15) type C,
  5. AGE type I,
  6. end of EMPLOYEE.
  7. data EMP3 like EMPLOYEE. " declare variant using exist variant
宣告常數:
  1. constants: CNAME(10) value 'Bruce',
  2. BIRTHDAY type D value '19650201'.
  3.  
  4. constants: begin of MYADDRESS,
  5. NAME type C length 20 value 'Fred Flintstone',
  6. STREET type C length 20 value 'Cave Avenue',
  7. NUMBER type P value 11,
  8. POSTCODE type N length 5 value 98765,
  9. CITY type C length 20 value 'Bedrock',
  10. end of MYADDRESS.
宣告表格:
  1. tables: SPFL. " load from ABAP/4 Dictionary
  2. select * from SPFL. " iterator data
  3. write: SPFL-MANDT,
  4. SPFL-CARRID,
  5. SPFL-CONNECTION.
  6. endselect.