1 / 113

ITEC3612

ITEC3612. Enterprise Architecture and Resource Planning (Lab) ABAP Programming (1). What is ABAP ?. ABAP = Advanced Business Application Programming Similarities with Cobol and Pascal Established in 1980 Since 1998 object oriented ABAP objects established Fully compatible to older versions

alyssa
Télécharger la présentation

ITEC3612

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. ITEC3612 Enterprise Architecture and Resource Planning (Lab) ABAP Programming (1)

  2. What is ABAP ? • ABAP = Advanced Business Application Programming • Similarities with Cobol and Pascal • Established in 1980 • Since 1998 object oriented ABAP objects established • Fully compatible to older versions • Multilanguage support • Embedded SQL statements • Platform independent • Database independent • Reusability of code fragments

  3. Historical view on ABAP 1950 Machine code …. Assembler 1954 Fortran Cobol LISP PL1 …. Pascal Smalltalk 1968 …. ABAP 1980 C++ …. Java 1992 ABAP Objects Source: Following SAP AG

  4. Compiling ABAP SAPGui SAPGui Presentation layer SAPGui Short message about compiling Calls program for the first time Runs program Application server Application server Application layer Application server Compiling Database server Database server Database layer Database server Program has to be compiled Return compilation ABAP Source code ABAP Compilation Source: Following SAP AG

  5. Development tools in SAP  Every tool can be accessed in Object Navigator

  6. Tools (1) • Menu path Tools • ABAP workbench • Development • ABAP Editor • Transaction code: SE38 • Run, view, edit, activate, check ABAP code • Integrated into Object Navigator

  7. Tools (2) Function Builder: • Menu path Tools • ABAP workbench • Development • Function Builder (SE37) • Create and edit function modules / groups Class Builder: • Menu path Tools • ABAP workbench • Development • Class Builder (SE24) • Create and edit new global classes

  8. Tools (3) Screen Painter: • Menu path Tools • ABAP workbench • Development • User Interface • Screen Painter (SE51) • Create and edit DynPro’s • Separate programs which is only installed when using SAPGui for Windows Menu Painter: • Menu path Tools • ABAP workbench • Development • User Interface • Menu Painter (SE41) • Create, edit menu’s, header's and toolbar’s in ABAP programs

  9. Tools (4) Debugger: • Execution of ABAP program step-by-step • Variable values during runtime • Breakpoint: program execution will be paused when getting to breakpoint • Watchpoint: program execution is paused only when variable has defined value • Debugging can be activated by suffix /h • Test program: Program • Test • Debugging

  10. Tools (5) Dictionary : SE11

  11. ABAP System Fields : Structure SYST (SE11)

  12. Tools (6) • Object Navigator integrates all development tools (SE80) Toolbar (context sensitive) Browsers (independent) Navigation tree (independent) Working space (context sensitive)

  13. editor Transaction Code : SE38

  14. Editor (1)

  15. Editor (2)

  16. Editor (3)

  17. Editor (4)

  18. Editor (5)

  19. Editor (6) • Ctrl + F2 = Check Syntax • F8 = Direct Processing • Ctrl + S = Save • Ctrl + F3 = Activate • Ctrl + F1 = Change <-> Display

  20. Editor (7) • Long running programs may decrease the system performance • Sometimes infinite loops • Termination of long running dialog program: • Click on SAP icon • Choose ‘Stop Transaction’

  21. Debugging

  22. Debugging (2) • Single step F5 • Execute F6 • Return F7 • Run F8

  23. Structure of Language • Each statement must end with a period DATA tmp TYPE I. WRITE ‘Hello World’. WRITE ‘OK’.

  24. Structure of Language (2) • Successive statements that have the same string segment can be combined to form a single chained statement • To do so, you specify the identical starting segment once and conclude it with a colon (:), the remaining segments are then listed, separated by commas (,) and concluded with a period (.)

  25. Structure of Language (3) • Comments • Full Line Comment (*) • Partial Line Comment (“) • ABAP command is notcase sensitive • SAP Program Name must use Y or Z at thefirst character.

  26. Data Objects in ABAP Memory Space Variable Structure Internal Table Table Structure Constants <Field-symbols>

  27. Variable • Variables can be declared at any point in a program • Variables can be up to 30 characters in length REPORT ZTEST. DATA firstname TYPE STRING. firstname = ‘John’.

  28. Predefined ABAP Data Types Type Description Initial Value Length Space ‘00000000’ 0.0 0 ‘0’ 0 ‘000000’ ’00’ Space Blank string 1 – 65535 8 characters 8 bytes 4 bytes 1 – 65535 1 – 16 bytes 6 characters 1 – 65535 Variable Variable Character Date Floating Point Integer Numeric Text Packed Decimal Time Hexadecimal Variable-length Variable-length Hexadecimal C D F I N P T X String xstring

  29. Defining Variable with DATA Statement * Syntax DATA var[(length)] [Type type] [Decimalsnumber]. DATA var LIKE Table-Field [VALUE initial value].

  30. Defining Variable with DATA Statement * Data Declaration DATA: tmp(10) TYPE C, tmp1 TYPE I, tmp2(8) TYPE P DECIMALS 2 VALUE ‘1.50’. DATA: tmp3(5) TYPE N, tmp4.

  31. Defining Variable with DATA Statement * Data Declaration DATA customerno LIKE customers-id. DATA matnr LIKE mara-matnr. DATA customerno TYPE customers-id. DATA matnr TYPE mara-matnr.

  32. Variable • Data Type C,N and X length between 1 – 65535 (Default 1) • Data Type P length between 1 – 16 (Default 8) and decimals length between 0 – 31 • Data Type I value between – 231 to 231 – 1 or –2,147,483,648 to 2,147,483,647

  33. Data Declaration & Value Assignment • DATA tmp(5) TYPE C value 'Hello World'. • DATA tmp2 TYPE P DECIMALS 4. • DATA tmp3 TYPE I. • : tmp2 = '12345.45345', tmp3 = 30. • write tmp. • write: / 'tmp2', tmp2 , tmp2 DECIMALS 2. • Write: / 'tmp3 ' ,tmp3. • data tmp4(5) type N. • tmp4 = 'Xca9yy23K6'. • Write / tmp4.

  34. Data Declaration & Value Assignment TYPES tname(10) TYPE c. DATA: fname TYPE tname, lname TYPE tname. DATA: tmp1 TYPE i, tmp2 TYPE i. tmp1 = tmp2 = 10. : fname = 'uraiporn' , lname = 'jettanachai'. write : / 'firstname => ' , fname. write : 'lastname =>' ,lname. write : /'tmp1 => ' , tmp1 ,'tmp2 => ',tmp2.

  35. DATE * Fixed Length 8 * Include Representation ‘YYYYMMDD’ DATA today TYPE D. today = sy-datum. WRITE today. today = ‘19991231’. WRITE today.

  36. TIME • * Fixed Length 6 • * Format ‘HHMMSS’ • DATA times TYPE T. • times = sy-uzeit. • WRITE times.

  37. xx • * Value assignment • DATA: name1(30), • first_num TYPE I, • next_num TYPE I. • MOVE ‘XXXX’ TO name1. • MOVE 5 TO first_num. • COMPUTE next_num = first_num + 5. • name1 = ‘SAP’. • ADD 1 TO next_num.

  38. Structure • * Syntax • DATA BEGIN OF <structure name>. • DATA field1. • DATA field2. … … • DATA END OF <structure name>.

  39. Structure wa • * Syntax • DATA BEGIN OF wa. • DATAid LIKE customers-id. • DATAname LIKE customers-name. • DATAcity LIKE customers-city. • DATA END OF wa. • MOVE 9 TO wa-id. • WRITE wa-id. id name city

  40. Defining Structure (Include Structure) • * Include Structure • DATA BEGIN OF wa. • INCLUDE STRUCTURE customers. • DATA tel(7). • DATA END OF wa. • wa-id = 10. • wa-tel = 1234567. • write : / wa-id , wa-tel. wa id name city tel

  41. Defining Structure • * LIKE option • DATA wa LIKE customers. • wa-id = 1. • wa-name = ‘John’. • WRITE: wa-id, wa-name.

  42. Constants • * Constant variable • CONSTANTS max_no TYPE I VALUE 999. • DATA counter TYPE I VALUE max_no. • WRITE: max_no, counter.

  43. Constants Using Example • * Constant variable • CONSTANTS ctext(11)TYPE C VALUE ‘Hello World’. • WRITE ctext. • WRITE ctext. • WRITE ctext. • WRITE ctext. • WRITE ctext.

  44. System Fields • The system fields (structure syst) are filled by the runtime environment. You can use them to query the system status in an ABAP program • You should access them only for reading • sy-datum = Current date of application server • sy-uzeit = Current time of application server • sy-datlo = Current date of SAP GUI • sy-timlo = Current time of SAP GUI • sy-mandt = Current client logon • sy-subrc = Return value of ABAP statement

  45. MOVE Statement • DATA wa LIKE customers. • DATA vender LIKE customers. • wa-id = ‘1234’. • wa-name = ‘Test#1’. • MOVE wa TO vender. • WRITE: vender-id, vender-name. “vender = wa.

  46. MOVE-CORRESPONDING Statement DATA: begin of wa1, f1,f2,f4, end of wa1. DATA: begin of wa2, f2,f1,f3, end of wa2. wa1-f1 = 'A'. wa1-f2 = 'B'. wa1-f4 = 'C'. wa2-f2 = 'D'. wa2-f1 = 'E'. wa2-f3 = 'F'. MOVE-CORRESPONDING wa1 TO wa2. WRITE : wa2-f2,wa2-f3 .

  47. Field-symbols Data: name(4) Value 'Test', num Type I Value 10, today Type D Value '19980429'. Field-symbols <temp>. Assign name To <temp>. Write <temp>. Assign num To <temp>. Write <temp>. Assign today To <temp>. Write <temp>.

  48. Field-symbols : UNASSIGN data: name(4) Value ‘Test’, field-symbols <temp>. assign name To <temp>. write <temp>. unassign <temp>. write <temp>.

  49. CLEAR Statement CLEAR <data object>. DATA tmp type i value 9. tmp = 10. CLEAR tmp.

More Related