1.36k likes | 1.73k Views
ABAP Training. Odin Lee 6/2005. Agenda. ABAP Program Flow ( 30 Mins ) ABAP Dictionary – Data type ( 90 Mins ) ABAP Program ( 300 Mins ) ABAP Editor ( 30 Mins ) Selection Screen ( 90 Mins ) Query Database ( 90 Mins ) ABAP List ( 90 Mins ). ABAP Program Flow.
E N D
ABAP Training Odin Lee 6/2005
Agenda • ABAP Program Flow ( 30 Mins ) • ABAP Dictionary – Data type ( 90 Mins ) • ABAP Program ( 300 Mins ) • ABAP Editor ( 30 Mins ) • Selection Screen ( 90 Mins ) • Query Database ( 90 Mins ) • ABAP List ( 90 Mins )
ABAP Program Flow • ABAP Program Flow ( 30 Mins ) • ABAP Dictionary – Data type ( 90 Mins ) • ABAP Program ( 300 Mins ) • ABAP Editor ( 30 Mins ) • Selection Screen ( 90 Mins ) • Query Database ( 90 Mins ) • ABAP List ( 90 Mins )
Program Repository Start Database Table Report Program Flow – 1.Program Start
Program ABAP Program Repository Start Selection Screen Data Objects Database Table ABAP Processing Block ABAP Runtime System 2.System Load Program Context
Program ABAP Program Start Data Objects Database Table ABAP Processing Block ABAP Runtime System 3.Runtime System Sends Selection screen
Program ABAP Program Start Data objects Database Table ABAP Processing Block ABAP Runtime System 4.Selection Screen Entries Insert into Data Object
Program ABAP Program Start Data objects Database Table ABAP Processing Block ABAP Runtime System 5.Program Requests Data Record from Database
Program Program ABAP Program ABAP Program Start Start Data objects Data objects Database Database Table Table ABAP ABAP Processing Processing Block Block ABAP Runtime System ABAP Runtime System 6.Database Returns Data Record to Program
Program ABAP Program Start Data objects Database Table ABAP Processing Block ABAP Runtime System 7.Runtime System Sends List
ABAP Dictionary – Data Type • ABAP Program Flow ( 30 Mins ) • ABAP Dictionary – Data type ( 90 Mins ) • ABAP Program ( 300 Mins ) • ABAP Editor ( 30 Mins ) • Selection Screen ( 90 Mins ) • Query Database ( 90 Mins ) • ABAP List ( 90 Mins )
Packed Number Declear length Output length no decimals Output length with decimals
Types can be defined locally in a program or centrally in the Dictionary Local Types in program: ABAP Dictionary Technical Attributes Only ABAP Program ABAP Global Types in ABAP Dictionary: Source Technical and Semantic Attribute Code Interface Subroutine Global and Local Data Types
DB objects Type definitions Structure Table, View DB table Table type Data elements Services Poss. values Screen F4 Help F1 Function of ABAP Dictionary
View Objects are automatically created in the DB and Table 2 Table 1 adjusted to changes ABAP Dictionary Database View Table 2 Table 1 Database Object in the ABAP Dictionary
Address Book Telephone Address Name Address Phone No. Last name First name Town Town name House no. Street ZIP • There are three different type categories in the ABAP Dictionary: • Data elements: Describe an elementary type by defining the data type, length and possibly decimal places. • Structures: Consist of components that can have any type. • Table types: Describe the structure of an internal table. Type Definition in the ABAP Dictionary
Internal table type – line type 輸入table name或是structure name
Internal table type – table type 輸入想使用的table access 方式
Maintenance of flights LH Carrier F4 Flight number . . . F1 Code of the flight connection Code defining a flight connection between two cities, e.g. 0400 Frankfurt - New York. Services of the ABAP Dictionary
Development environment Screen Reads structure of Painter database objects ABAP Editor ABAP Dictionary Read type definitions Database Runtime environment interface Screen Interpreter ABAP Interpreter Linking to the Development and Runtime Environment
Field Label Input Field Data Element: Technical Type Field Label Field Documentation (for F1 Help) Search Help (for F4 Help) F1 Global Data Type-Using Data Element
S_CARR_ID. DATA wa_carrid TYPE F1 Data element Structure Type S_CARR_ID SBC405_S_SFLIGHT Fields Field type Double-Click Double-Click CARRID S_CARR_ID CONNID ... Finding ABAP Dictionary Types
Help for Local Data Type Declaration F1 <type>. TYPES Types: <user_defined_type> TYPE Double-Click Help for Local Data Object Declaration Navigates to Local F1 Data Type Declaration or ABAP Dictionary <type>. TYPE DATA DATA: <data_object> Type Declaration F1 Keyword Documentation for Built-In Types Double-Click Local Data Types in Program
ABAP Editor • ABAP Program Flow ( 30 Mins ) • ABAP Dictionary – Data type ( 90 Mins ) • ABAP Program ( 300 Mins ) • ABAP Editor ( 30 Mins ) • Selection Screen ( 90 Mins ) • Query Database ( 90 Mins ) • ABAP List ( 90 Mins )
1 2 3 Create a Report Program
Comment and Chained Statement REPORT yrep_create_01 . DATA wa_flight TYPE sflight. " work area for SFLIGHT *read data from DB table SFLIGHT SELECT * FROM sflight INTO CORRESPONDING FIELDS OF wa_flight. NEW-LINE. WRITE : wa_flight-carrid, wa_flight-connid, wa_flight-fldate, wa_flight-seatsocc, wa_flight-seatsmax. ENDSELECT. Comment Comment Chained Statement
Navigation in the Editor and Keyword Documention REPORT yrep_create_01 . DATA wa_flight LIKE sflight. SELECT * FROM sflight INTO CORRESPONDING FIELDS OF wa_flight. NEW-LINE. WRITE: wa_flight-carrid, wa_flight-connid, wa_flight-fldate, wa_flight-seatsocc, wa_flight-seatsmax. ENDSELECT. Definition of Structure In the Program Double Click Double Click F1 Definition of Database Table in the ABAP Dictionary Keyword Documentation
ABAP Program <user-defined-type>. DATA: <varname> TYPE <ABAP-dictionary-type>. ABAP Dictionary DATA: <varname> LIKE <data-object>. Reference Data Object Defining Data Object
Declaring Data Objects ABAP Program carrid counter Data Element Tmp_carrid S_carr_id DATA: Carrid TYPE s_carr_id, carr counter TYPE I, ABAP Basic Type Tmp_carrid LIKE carrid. Data Object
Numeric literal Literals and Constants CONSTANTS <constants> TYPE <type> VALUE <literal>. CONSTANTS: C_PI TYPE P DECIMALS 4 VALUE '3.1415', C_NAME(4) TYPE C VALUE 'Hugo'. 1234, -987 Whole number (a minus sign is placed in front of negative numbers) Text literal 'abdc' , '2.17', '1.213E15', ‘HELLO', 'A''B' Character sequence set off by single quotation marks, 255 characters max.
CONCATENATE f1 ... fn INTO g. J o h n DATA: ONE(10) VALUE ' John ', TWO(3) VALUE 'F.', THREE(10) VALUE ' Kennedy', NAME(20). FIRST TYPE STRING. CONCATENATE ONE TWO THREE INTO NAME. NAME then contains the value ' JohnF. Kennedy'. F . K e n n e d y J o h n F . K e n n e d y Concatenate Statement
Data Declarations: CONSTANTS c_id TYPE s_carr_id VALUE 'AA‘ . DATA: d_id1 TYPE s_carr_id , d_id2 TYPE s_carr_id VALUE 'LH ', counter TYPE i . d_id1 d_id2 counter Program Start c_id AA LH 0000 AA LH 0000 MOVE MOVE c_id TO d_id1 AA AA 0000 d_id2 = d_id1. AA AA 0001 ADD 1 TO counter. CLEAR CLEAR: gd _carrid1, gd _carrid2, 0000 counter. ABAP Program ABAP Runtime System Chang Variable Value – Copy and Initialization
Watchpoint Debugger - Watchpoint
Structure Definition wa _ spfli Sdyn_conn _ ABAP Program ABAP Source Code DATA: w_spfli TYPE spfli. TABLES: sdyn_conn. Defining Structure with Dictionary Type Reference
ABAP _ WA_SPFLI Program mandt carrid CONNID CITYFROM Fields in structures are always addressed by ABAP Source Code <structure>-<field_name> DATA: w_spfli TYPE spfli. TABLES: sdyn_conn. sdyn_conn-carrid = 'AA'. SELECT * FROM spfli INTO w_spfli WHERE carrid = sdyn_conn-carrid. WRITE: / w_spfli-connid, w_spfli-cityfrom, w_spfli-cityto. ENDSELECT. Addressing Fields in Structures
MOVE-CORRESPONDING <rec1> TO <rec2>. DATA: wa _ sflight TYPE sflight , wa _sbc400focc TYPE sbc400focc. ... MOVE-CORRESPONDING wa _ sflight TO wa _sbc400focc. MOVE-CORRESPONDING wa _ sflight TO wa _sbc400focc. MANDT CARRID CONNID FLDATE ... SEATSMAX SEATSOCC ... wa _ sflight 401 LH 0400 20000513 ... 280 100 ... PERCENTAGE SEATSMAX SEATSOCC CARRID CONNID FLDATE 280 100 0400 20000513 LH Moving Values Fields for Field
Double-Click Debugger - Structure
CARRID CONNID DISTANCE CARRID CONNID DISTANCE Line Type Line Type Key Key Fields Key Sequence AA 0017 2,572 Unique / Non-Unique Key LH 0400 6,162 LH 0400 6,162 Table Kind Table Kind QF 0005 10,000 Access with Index 5 5 SQ 0866 1,625 Data Access Type UA 0007 2,572 UA 0007 UA 0007 Access with Key You do not have to determine the number of lines in your table; the ABAP runtime system automatically determines this at runtime (dynamic table expansion). Internal Table
ANY TABLE ANY TABLE INDEX TABLE HASHED TABLE INDEX TABLE HASHED TABLE STANDARD TABLE STANDARD TABLE Access with n n n n Index Access with Key Unique / NON- UNIQUE UNIQUE | NON-UNIQUE UNIQUE Non-Unique Key SORTED TABLE SORTED TABLE Access Using Mainly Index Mainly Keys Keys Only Table Types
ABAP IT_flight Program DATA it_flight TYPE SBC405_T_SFLIGHT Defining Internal Table Reference to Dictionary Type
Append APPEND APPEND wa _ itab to itab . Insert INSERT INSERT wa _ itab INTO itab <condition>. Read READ READ TABLE itab INTO wa _ itab <condition>. Change MODIFY MODIFY TABLE itab <condition>. Delete DELETE DELETE itab <condition>. Processing Single Record