22 abap objects

Upload: arkadev-chakrabarti

Post on 01-Jun-2018

257 views

Category:

Documents


5 download

TRANSCRIPT

  • 8/9/2019 22 ABAP Objects

    1/31

     ABAP objects

  • 8/9/2019 22 ABAP Objects

    2/31

     

    BAP Objects

    Objectives

    In this Chapter you will learn...

    •About ABAP Objects

    •About Object orientation

  • 8/9/2019 22 ABAP Objects

    3/31

     

    ABAP Objects

    ABAP Objects is fairly a new concept in R/3. The ter has two

    eanin!s.

    •It stan"s for the entire ABAP runtie environent.

    an"

    • It represents the object#oriente" e$tension of the ABAP

    lan!ua!e

  • 8/9/2019 22 ABAP Objects

    4/31

     

    ABAP Objects

    • ABAP Runtie %nvironent

    • The ABAP &or'bench allows you to create R/3

    Repository objects such as pro!ras( authori)ation

    objects( loc' objects( Custoi)in! objects( an" so on.• *sin! function o"ules( you can encapsulate

    functions in separate pro!ras with a "efine"

    interface.

    • The Business Object Repository +BOR, allows you to

    create -AP Business Objects for internal an" e$ternaluse +CO/CORBA,.

  • 8/9/2019 22 ABAP Objects

    5/31

     

    ABAP Objects

    • The Object#oriente" 0an!ua!e %$tension

    • ABAP Objects is a coplete set of object#oriente"

    stateents that has been intro"uce" into the ABAP

    lan!ua!e.• This object#oriente" e$tension of ABAP buil"s on the

    e$istin! lan!ua!e( an" is fully copatible with it.

    •  1ou can use ABAP Objects in e$istin! pro!ras( an"

    can also use 2conventional2 ABAP in new ABAP Objects

    pro!ras.

  • 8/9/2019 22 ABAP Objects

    6/31

     

    • The Object#oriente" 0an!ua!e %$tension...

    • ABAP Objects supports object#oriente" pro!rain!

    • The object#oriente" enhanceent of ABAP is base" on the

    o"els of ava an" C44. It is copatible with e$ternalobject interfaces such as CO an" CORBA

    • -AP Business Objects an" 5*I objects # alrea"y object#

    oriente" theselves # will also profit fro bein!

    incorporate" in ABAP Objects.

    ABAP Objects

  • 8/9/2019 22 ABAP Objects

    7/31

     

    ABAP Objects

    Object#Orientation.

    • Object orientation +OO,( or to be ore precise( object#oriente" pro!rain!( is a proble#solvin! etho" in

    which the software solution reflects objects in the real

    worl" .

    •Objects

    • An object is a section of source co"e that contains

    "ata an" provi"es services.

    • The "ata fors the attributes of the object.

    • The services are 'nown as etho"s +also 'nown as

    operations or functions,.

  • 8/9/2019 22 ABAP Objects

    8/31

     

    ABAP Objects

    *ses of OO.

    • The ain "ifference between real object orientation an"

    function !roups is that althou!h a pro!ra can wor' with

    the instances of several function !roups at the sae

    tie( it cannot wor' with several instances of a sin!le

    function !roup.• This re6uireent is et by object orientation. ABAP

    Objects allows you to "efine "ata an" functions in

    classes instea" of function !roups. *sin! classes( an

    ABAP pro!ra can wor' with any nuber of instances

    +objects, base" on the sae teplate. 

  • 8/9/2019 22 ABAP Objects

    9/31

     

    ABAP Objects

    •Classes

    •  Classes "escribe objects.

    •  7ro a technical point of view( objects are runtie

    instances of a class.

    •  In theory( you can create any nuber of objects base"

    on a sin!le class.

    •  %ach instance +object, of a class has a uni6ue i"entityan" its own set of values for its attributes.

  • 8/9/2019 22 ABAP Objects

    10/31

     

    ABAP Objects

    •Classes

    • Classes "escribe objects.

    • 7ro a technical point of view( objects are runtie

    instances of a class.

    • In theory( you can create any nuber of objects base"

    on a sin!le class.

    • %ach instance +object, of a class has a uni6ue i"entityan" its own set of values for its attributes.

  • 8/9/2019 22 ABAP Objects

    11/31

     

    ABAP Objects

    • To Create a Class

    •5o to Transaction -%89

     

  • 8/9/2019 22 ABAP Objects

    12/31

     

    ABAP Objects

    • To Create a Class:

      •Then specify whether you want to create a class or interface.

  • 8/9/2019 22 ABAP Objects

    13/31

     

    ABAP Objects

    • To Create Class:

     Instance is nothin! but a copy of class which is calle" as

    object. &e will "iscuss about the Public( private class in

    the followin! sli"e.

    Class declaration

    Instance of class

  • 8/9/2019 22 ABAP Objects

    14/31

     

    ABAP Objects

    • -tructure of a Class

     

    • A class contains coponents

    • %ach coponent is assi!ne" to a visibility section

    • Classes ipleent etho"s

  • 8/9/2019 22 ABAP Objects

    15/31

     

    ABAP Objects

    • Class Coponents

     • The coponents of a class a'e up its contents.

    • All coponents are "eclare" in the "eclaration part of

    the class.

    • The coponents "efine the attributes of the objects in a

    class.

    • &hen you "efine the class( each coponent is assi!ne"

    to one of the three visibility sections( which "efine the

    e$ternal interface of the class.

    • All of the coponents of a class are visible within theclass. All coponents are in the sae naespace.

    • This eans that all coponents of the class ust have

    naes that are uni6ue within the class.

  • 8/9/2019 22 ABAP Objects

    16/31

     

    ABAP Objects

    • Attributes

     

    • Attributes are internal "ata fiel"s within a class that

    can have any ABAP "ata type.

    • The state of an object is "eterine" by the contents ofits attributes.

    • One 'in" of attribute is the reference variable.

    • Reference variables allow you to create an" a""ress

    objects. Reference variables can be "efine" in classes(

    allowin! you to access objects fro within a class. 

    ABAP Obj

  • 8/9/2019 22 ABAP Objects

    17/31

     

    ABAP Objects

    • etho"

     •etho"s are internal proce"ures in a class that "efine

    the behavior of an object.

    •They can access all of the attributes of a class. This

    allows the to chan!e the "ata content of an object.

    •They also have a paraeter interface( with which

    users can supply the with values when callin! the(

    an" receive values bac' fro the

    •The private attributes of a class can only be chan!e"

    by etho"s in the sae class. 

    ABAP Obj t

  • 8/9/2019 22 ABAP Objects

    18/31

     

    ABAP Objects

    • etho"...

     •etho"s are internal proce"ures in a class that "efine

    the behavior of an object.

    •They can access all of the attributes of a class. This

    allows the to chan!e the "ata content of an object.

    •They also have a paraeter interface( with which

    users can supply the with values when callin! the(

    an" receive values bac' fro the

    •The private attributes of a class can only be chan!e"

    by etho"s in the sae class.

     

    ABAP Obj t

  • 8/9/2019 22 ABAP Objects

    19/31

     

    ABAP Objects

    • etho":

    • The "efinition an" paraeter interface of a etho" is

    siilar to that of function o"ules.• 1ou "efine a etho" ;et< in the "efinition part of a

    class an" ipleent it in the ipleentation part usin!

    the followin! processin! bloc'=

    %T>O ;ethO.

    • 1ou can "eclare local "ata types an" objects in

    etho"s in the sae way as in other ABAP proce"ures

    +subroutines an" function o"ules,. 1ou call etho"s

    usin! the CA00 %T>O stateent.

    ABAP Obj t

  • 8/9/2019 22 ABAP Objects

    20/31

     

    ABAP Objects

    • etho":

    • The "efinition an" paraeter interface of a etho" is

    siilar to that of function o"ules.• 1ou "efine a etho" ;et< in the "efinition part of a

    class an" ipleent it in the ipleentation part usin!

    the followin! processin! bloc'=

    %T>O ;ethO.

    • 1ou can "eclare local "ata types an" objects in etho"s

    in the sae way as in other ABAP proce"ures +subroutines

    an" function o"ules,. 1ou call etho"s usin! the CA00

    %T>O stateent.

    • CA00 %T>O ;Obj?ae< #< ;etho"<

    ABAP Obj t

  • 8/9/2019 22 ABAP Objects

    21/31

     

    ABAP Objects

    • etho":

    • Instance Methods

     1ou "eclare instance etho"s usin! the %T>O-

    stateent. They can access all of the attributes of a

    class( an" can tri!!er all of the events of the class

    • Static Methods

     1ou "eclare static etho"s usin! the C0A--#

    %T>O- stateent. They can only access static

    attributes an" tri!!er static events.

    ABAP Obj t

  • 8/9/2019 22 ABAP Objects

    22/31

     

    ABAP Objects

    • Classes @isibility -ection.

     1ou can "ivi"e the "eclaration part of a class into up to three

    visibility areas=

     C0A-- ;class< %7I?ITIO?.

    P*B0IC -%CTIO?.

    ... PROT%CT% -%CTIO?.

    ...

     PRI@AT% -%CTIO?.

    ...

    %?C0A--.

     

    ABAP Objects

  • 8/9/2019 22 ABAP Objects

    23/31

     

    ABAP Objects

    • To Create a etho".

    •ouble clic' on the object ?ae+?C, an" it will ta'e

    you the followin! -creen( where you "efine the level(

    visibility( escription etc. for particular etho" in a

    class.

     

    ABAP Objects

  • 8/9/2019 22 ABAP Objects

    24/31

     

    ABAP Objects

    • To Ipleent your etho".

    ouble clic' on the etho" to ipleent youretho".

     Click to implement your

    method

    ABAP Objects

  • 8/9/2019 22 ABAP Objects

    25/31

     

    ABAP Objects

    • To Ipleent your etho".

     

    ABAP Objects

  • 8/9/2019 22 ABAP Objects

    26/31

     

    ABAP Objects

    • Classes @isibility -ection.

    •Public -ection

     All of the components declared in the

    public section are accessible to all

    users of the class, and to the methodsof the class and any classes that inherit

    from it. The public components of the

    class form the interface between the

    class an" its users.

     

    ABAP Objects

  • 8/9/2019 22 ABAP Objects

    27/31

     

    ABAP Objects

    • Classes @isibility -ection.

    •Private -ection

    Components that you declare in the

    private section are only visible in the

    methods of the same class. The privatecomponents are not part of the

    e$ternal interface of the class.

     

    ABAP Objects

  • 8/9/2019 22 ABAP Objects

    28/31

     

    ABAP Objects

    • Classes @isibility -ection.

    • Protecte" -ection

     All of the components in the protected section can

    access the components from the public section. In

    turn, they can be accessed by the components of

    the private section.

    ABAP Objects

  • 8/9/2019 22 ABAP Objects

    29/31

     

    ABAP Objects

    • Classes @isibility -ection.

    •Public -ection

    ABAP Objects

  • 8/9/2019 22 ABAP Objects

    30/31

     

    ABAP Objects

    Public Section of the Class, which is visible accessible to all users of the class.

    ABAP Objects

  • 8/9/2019 22 ABAP Objects

    31/31

    ABAP Objects

    -uary

    • ABAP Objects represents OO e$tension of ABAP

    Pro!rain!

    0an!ua!e

    • Class "escribes a Object

    • Object is a instance of a class

    • %ach object provi"es services throu!h etho"s