3 ABAP 4 6 Basic Functions

Embed Size (px)

Citation preview

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    1/38

    ABAP Basic Functions3-ABAP 4_6 Basic Functions.1This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.

    You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material toother employees of PricewaterhouseCoopers.

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    2/38

    ABAP Basic Functions3-ABAP 4_6 Basic Functions.2This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.

    You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material toother employees of PricewaterhouseCoopers.

    List of Topics

    Objectives

    Terminology and GUI Enhancements

    ABAP Editor/Debugger

    Internal Table Types

    Open SQL Enhancements

    Runtime Errors

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    3/38

    ABAP Basic Functions3-ABAP 4_6 Basic Functions.3This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.

    You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material toother employees of PricewaterhouseCoopers.

    Module Map

    Objectives

    Terminology and GUI Enhancements

    ABAP Editor/Debugger

    Internal Table Types

    Open SQL Enhancements

    Runtime Errors

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    4/38

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    5/38

    ABAP Basic Functions3-ABAP 4_6 Basic Functions.5This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.

    You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material toother employees of PricewaterhouseCoopers.

    Module Map

    Objectives

    Terminology and GUI Enhancements

    ABAP Editor/Debugger

    Internal Table Types

    Open SQL Enhancements

    Runtime Errors

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    6/38

    ABAP Basic Functions3-ABAP 4_6 Basic Functions.6This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.

    You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material toother employees of PricewaterhouseCoopers.

    Release 3.0 Release 4.6

    Terminology Changes

    ABAP/4 Development

    Workbench

    Object Browser

    ABAP/4 Editor

    ABAP/4 Dictionary

    ABAP/4 Query

    Function Library

    Field Strings

    ABAP Workbench

    Object Navigator

    ABAP Editor

    ABAP Dictionary

    ABAP Query

    Function Builder

    Program Structures

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    7/38ABAP Basic Functions3-ABAP 4_6 Basic Functions.7This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.

    You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material toother employees of PricewaterhouseCoopers.

    Refresh

    Object List

    Favorites

    Close

    Browser

    Object

    Menu

    Workbench GUI Enhancements

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    8/38ABAP Basic Functions3-ABAP 4_6 Basic Functions.8This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.

    You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material toother employees of PricewaterhouseCoopers.

    Module Map

    Objectives

    Terminology and GUI Enhancements

    ABAP Editor/Debugger

    Internal Table Types

    Open SQL Enhancements

    Runtime Errors

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    9/38ABAP Basic Functions3-ABAP 4_6 Basic Functions.9This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.

    You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material toother employees of PricewaterhouseCoopers.

    ABAP Workbench Enhancements

    As of release 4.6 the enjoyABAP Workbench isavailable Redesigned with an

    emphasis on usability,

    and simplified navigation

    The following tools aredisplayed within the workarea: ABAP Dictionary Class Builder ABAP Editor Function Builder Screen Painter Menu Painter Text Element

    Maintenance

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    10/38ABAP Basic Functions3-ABAP 4_6 Basic Functions.10This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.

    You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material toother employees of PricewaterhouseCoopers.

    ABAP Editor Enhancements

    As of release 4.0 the following settings are available in the

    Settings menu of the ABAP Editor: Compress/decompress code blocks Setting case of code to KEYWORD LARGE The Edit Locally option

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    11/38ABAP Basic Functions3-ABAP 4_6 Basic Functions.11This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.

    You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material toother employees of PricewaterhouseCoopers.

    Edit Control Mode

    As of release 4.6 the Edit Control Mode allows for editing

    in the front-end using the ABAP Editor

    ABAP source code is transferred to the front-end for

    editing

    Edit Control mode can be used to maintain the following

    objects: ABAP programs (ABAP Editor) Method implementations (Class Builder) Function module source code (Function Builder) Screen flow logic (Screen Painter) Type groups (ABAP Dictionary)

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    12/38ABAP Basic Functions3-ABAP 4_6 Basic Functions.12This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.

    You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material toother employees of PricewaterhouseCoopers.

    Single

    Step

    Continue

    Next Page

    Execute

    Debugger GUI Enhancements

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    13/38ABAP Basic Functions3-ABAP 4_6 Basic Functions.13This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.

    You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material toother employees of PricewaterhouseCoopers.

    Create Watchpoint

    Debugger

    New functions have been added to the debugger in release 4.0

    making it easier to use

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    14/38ABAP Basic Functions3-ABAP 4_6 Basic Functions.14This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.

    You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material toother employees of PricewaterhouseCoopers.

    Breakpoints

    Breakpoints

    By clicking on the Breakpoints pushbutton, a scrollable display

    of the breakpoints defined in the program is displayed

    Can set up to 30 breakpoints

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    15/38ABAP Basic Functions3-ABAP 4_6 Basic Functions.15This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.

    You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material toother employees of PricewaterhouseCoopers.

    Watchpoints

    Watchpoint processing in the debugger has been significantly

    improved

    It is now possible to define multiple watchpoints, attach

    conditions to them and link two or more watchpoints using a

    relational operator

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    16/38ABAP Basic Functions3-ABAP 4_6 Basic Functions.16This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.

    You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material toother employees of PricewaterhouseCoopers.

    Modification Assistant

    The Modification Assistant offers support in the following

    areas: Customizing Personalization

    Customer exits Customer developments

    These tools are all supported by corresponding

    tools such as the IMG, Business Add-Ins,

    transaction CMOD and the development

    environment

    Modifications made to those ABAP Workbench objects

    not supported by the Modification Assistant are logged

    and displayed in an overview

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    17/38ABAP Basic Functions3-ABAP 4_6 Basic Functions.17

    This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material to

    other employees of PricewaterhouseCoopers.

    Module Map

    Objectives

    Terminology and GUI Enhancements

    ABAP Editor/Debugger

    Internal Table Types

    Open SQL Enhancements

    Runtime Errors

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    18/38ABAP Basic Functions3-ABAP 4_6 Basic Functions.18

    This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material to

    other employees of PricewaterhouseCoopers.

    Summary of Changes

    In previous releases there was only one type of internal

    table

    As of release 4.6 there are three types of internal tables

    Standard Sorted Hashed

    The type of table used determines the way in which the

    entries in the table are accessed by the system

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    19/38ABAP Basic Functions3-ABAP 4_6 Basic Functions.19

    This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material to

    other employees of PricewaterhouseCoopers.

    Table Types

    Standard tables are the same tables available in release

    3.x The time for key access to entries is in linear relation

    to the number of entries in the table

    Sorted tables are ones that are always sorted correctly The time for key access to entries is in logarithmic

    relation to the number of entries in the table

    Hashed tables contain records that all have a unique key The time for key access to entries is constant

    regardless of the number of entries in the table. Key access can only be used to read entries in a

    hashed table Index operations are not allowed

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    20/38ABAP Basic Functions3-ABAP 4_6 Basic Functions.20

    This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material to

    other employees of PricewaterhouseCoopers.

    Line Type

    Key Sequence

    Uniqueness Attribute

    Index Access

    Key Access

    UA 0007)

    Properties of Internal Tables

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    21/38ABAP Basic Functions3-ABAP 4_6 Basic Functions.21

    This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material to

    other employees of PricewaterhouseCoopers.

    Table Types

    Uniqueness UNIQUE| NON-UNIQUE UNIQUE

    Access Time

    For n Entries

    PredominantlyKey

    NON-UNIQUE

    PredominantlyIndex

    Remains Constant

    (O(1))

    Key Only

    Increases Logarithmically

    (O(log(n))Increases Linearly

    (O(n))

    Hash FunctionBinary SrchTable Scan

    Access Using

    Key Access

    HashedSortedStandard

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    22/38

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    23/38

    ABAP Basic Functions3-ABAP 4_6 Basic Functions.23This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.

    You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material toother employees of PricewaterhouseCoopers.

    DATA: TYPE HASHED TABLE of WITH [UNIQUE | NON-UNIQUE] [INITIAL SIZE ] [WITH HEADER LINE].

    REPORT TYPES: BEGIN OF line_type,

    f1, f2,END OF line_type.

    DATA: tab1 TYPE HASHED TABLE OF line_type WITH UNIQUE KEY f1WITH HEADER LINE.

    tab1-f1 = Y. Tab1-f2 = 1. INSERT TABLE tab1.tab1-f1 = X. Tab1-f2 = 1. INSERT TABLE tab1.tab1-f1 = A. Tab1-f2 = 1. INSERT TABLE tab1.

    READ TABLE tab1 WITH TABLE KEY f1 = A.

    SORT tab1 by f1.LOOP AT tab1.WRITE:/ tab1-f1, tab1-f2.

    ENDLOOP.

    Hashed Table Example

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    24/38

    ABAP Basic Functions3-ABAP 4_6 Basic Functions.24This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.

    You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material toother employees of PricewaterhouseCoopers.

    TYPES: BEGIN OF line_type,f1, f2, f3,

    END OF line_type.

    DATA: tab1 TYPE STANDARD TABLE OF line_type WITH KEY f1 f2,wa type line_type.

    wa-f1 = 'B'.wa-f2 = '5'.wa-f3 = '12.45'.

    READ TABLE tab1 FROM wa INTO wa.READ TABLE tab1 WITH TABLE KEY f1 = 'B'

    f2 = '5' INTO wa.

    WA before read

    WA after read

    Work area WA

    Internal Table tab1

    Using the Key in the READStatement

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    25/38

    ABAP Basic Functions3-ABAP 4_6 Basic Functions.25This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.

    You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material toother employees of PricewaterhouseCoopers.

    Summary of Internal TableOperations

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    26/38

    ABAP Basic Functions3-ABAP 4_6 Basic Functions.26This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.

    You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material toother employees of PricewaterhouseCoopers.

    Ranges Table Types

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    27/38

    ABAP Basic Functions3-ABAP 4_6 Basic Functions.27This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.

    You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material toother employees of PricewaterhouseCoopers.

    Module Map

    Objectives

    Terminology and GUI Enhancements

    ABAP Editor/Debugger

    Internal Table Types

    Open SQL Enhancements

    Runtime Errors

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    28/38

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    29/38

    ABAP Basic Functions3-ABAP 4_6 Basic Functions.29This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.

    You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material toother employees of PricewaterhouseCoopers.

    SELECT INTO FROM AS INNER JOIN AS ON ~ = ~AND ~ = ~AND

    WHERE ENDSELECT.

    REPORT SELECT t1~carrid t1~connid t2~customid INTO (carrid, connid, custid)FROM sflight AS t1INNER JOIN sbook AS t2

    ON t1~carrid = t2~carridWHERE t1~connid = t2~connidAND t1~fldate = t2~fldate.WRITE:/ carrid, connid, custid

    ENDSELECT.

    Inner Join

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    30/38

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    31/38

    ABAP Basic Functions3-ABAP 4_6 Basic Functions.31This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.

    You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material toother employees of PricewaterhouseCoopers.

    SELECT INTO FROM AS LEFT OUTER JOIN AS ON ~ = ~AND ~ = ~AND

    WHERE ENDSELECT.

    REPORT SELECT t1~carrid t1~connid t2~customid INTO (carrid, connid, custid)FROM sflight AS t1LEFT OUTER JOIN sbook AS t2

    ON t1~carrid = t2~carridWHERE t1~connid = t2~connidAND t1~fldate = t2~fldate.WRITE:/ carrid, connid, custid

    ENDSELECT.

    Left Outer Join

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    32/38

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    33/38

    ABAP Basic Functions3-ABAP 4_6 Basic Functions.33This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.

    You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material toother employees of PricewaterhouseCoopers.

    SELECT INTO FROM

    WHERE = GROUP BY HAVING

    ENDSELECT.

    REPORT SELECT connid count(*) SUM( luggweight )

    INTO (connid, counter, luggweight) FROM sbookWHERE carrid = LH AND fldate = 19991231GROUP BY connid.

    IF luggweight > 100WRITE:/ connid, counter, luggweight.

    ENDIF.

    ENDSELECT.

    SELECT connid count(*) SUM( luggweight )INTO (connid, counter, luggweight) FROM sbookWHERE carrid = LH AND fldate = 19971129GROUP BY connid.HAVING SUM( luggweight ) > 100.

    WRITE:/ connid, counter, luggweight.

    ENDSELECT.

    Having Clause

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    34/38

    ABAP Basic Functions3-ABAP 4_6 Basic Functions.34This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.

    You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material toother employees of PricewaterhouseCoopers.

    SELECT INTO FROM AS

    WHERE IN( SELECT FROM

    WHERE = ~ )

    ENDSELECT.

    Sub-Select Clause

    Sub-queries were introduced in release 4.0 to provide a more

    efficient method of performing complex select statements

    Select records at database layer Data transferred to program is significantly reduced

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    35/38

    ABAP Basic Functions3-ABAP 4_6 Basic Functions.35This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.

    You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material toother employees of PricewaterhouseCoopers.

    Module Map

    Objectives

    Terminology and GUI Enhancements

    ABAP Editor/Debugger

    Internal Table Types

    Open SQL Enhancements

    Runtime Errors

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    36/38

    ABAP Basic Functions3-ABAP 4_6 Basic Functions.36This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.

    You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material toother employees of PricewaterhouseCoopers.

    CATCH Keyword

    As of release 4.0 the CATCH keyword is available for

    processing runtime errors

    The CATCHENDCATCH block allows the programmer

    to catch ABAP runtime errors and assign these to a SY-SUBRC

    This functionality allows errors to be reported in a

    controlled manner (rather than a short dump)

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    37/38

    ABAP Basic Functions3-ABAP 4_6 Basic Functions.37This is PricewaterhouseCoopersPROPRIETARY MATERIAL (hereafter, the Material) intended for internal use only.

    You may not rent, lease or distribute the Material to clients or other third parties, but you may transfer the Material toother employees of PricewaterhouseCoopers.

    DATA: int type I,

    char(3) type C value ABC.

    [..]

    CATCH SYSTEM-EXCEPTIONS

    CONVERSION_ERRORS = 1.

    [..]

    MOVE char TO int. MOVE keyword to trigger CATCH

    [..]ENDCATCH.

    IF SY-SUBRC = 1.

    WRITE: / Conversion error has occurred.

    ENDIF.

    CATCH Keyword

    To code the first part of a CATCHENDCATCH block it is necessary to codeCATCH SYSTEM - EXCEPTIONS and specify one of the following: Error Class Specific error ID OTHERS, which traps all catchable runtime errors

  • 8/4/2019 3 ABAP 4 6 Basic Functions

    38/38

    Module Review

    Objectives

    Terminology and GUI Enhancements

    ABAP Editor/Debugger

    Internal Table Types

    Open SQL Enhancements

    Runtime Errors