Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

oops consept in abap

Former Member
0 Kudos

hi

i just want to know abt oops consept usage in abap...

4 REPLIES 4

Former Member
0 Kudos

Hi,

You can read the book called as ABAP Objects. It is a very good book. You will also get miniSAP CD's along with this book.

You will get lots of material related to ABAP Objects on SDN also. Just type ABAP Objects in the search on SDN. It gives lots of useful links. Also, check out : https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/0a33479c-0b01-0010-7485-dc8c09d6...

Reward points if the answer is helpful.

Regards,

Mukul

Former Member
0 Kudos

Hi,

The object-oriented approach, however, focuses on objects that represent abstract or concrete things of the real world. These objects are first defined by their character and their properties which are represented by their internal structure and their attributes (data). The behaviour of these objects is described by methods (functionality).

Just have a look at these links;

<a href="http://java.sun.com/docs/books/tutorial/java/concepts/">http://java.sun.com/docs/books/tutorial/java/concepts/</a>

Regards,

Gunasree.

uwe_schieferstein
Active Contributor
0 Kudos

Hello Venkat

The following sample report shows the advantage of OO-concepts over classical programming. The report executes completely different functions depending on the selected company code yet the coding in the main program (between START-OF-SELECTION and END-OF-SELECTION) remains the same.

If a new company code with new functionality has to be added you simply extend the factory method LCL_BUKRS=>CREATE and create a new implementing class for this company code. NO changes whatsoever in the main program.

*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_ABAP_OO_CONCEPTS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zus_sdn_abap_oo_concepts.



*CLASS lcl_bukrs_1000 DEFINITION DEFERRED.
*CLASS lcl_bukrs_2000 DEFINITION DEFERRED.
*CLASS lcl_bukrs_3000 DEFINITION DEFERRED.

*---------------------------------------------------------------------*
*       INTERFACE lif_bukrs
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
INTERFACE lif_bukrs.

  .
    DATA:
      md_bukrs    TYPE bukrs.

    METHODS:
      process_data.



  ENDINTERFACE.                    "lif_bukrs



*---------------------------------------------------------------------*
*       CLASS lcl_bukrs DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_bukrs DEFINITION .

PUBLIC SECTION.

  TYPE-POOLS: abap.

  INTERFACES lif_bukrs.

  CLASS-METHODS:
    create
      IMPORTING
        value(id_bukrs)     TYPE bukrs
      RETURNING
        value(ro_instance)  TYPE REF TO lif_bukrs.



ENDCLASS.                    "lcl_bukrs DEFINITION

*---------------------------------------------------------------------*
*       CLASS lcl_bukrs IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_bukrs IMPLEMENTATION.




* Factory method
  METHOD create.
*   define local data
    DATA:
      ld_class(30)    TYPE c.

    CHECK ( cl_reexc_company_code=>exists( id_bukrs ) = abap_true ).

    CONCATENATE 'LCL_BUKRS' id_bukrs INTO ld_class
      SEPARATED BY '_'.
    CONDENSE ld_class NO-GAPS.

    CASE id_bukrs.
      WHEN '1000'.
        CREATE OBJECT ro_instance TYPE (ld_class).

      WHEN '2000'.
        CREATE OBJECT ro_instance TYPE (ld_class).

      WHEN '3000'.
        CREATE OBJECT ro_instance TYPE (ld_class).

      WHEN OTHERS.
    ENDCASE.

    IF ( ro_instance IS BOUND ).
      ro_instance->md_bukrs = id_bukrs.
    ENDIF.

  ENDMETHOD.                    "create


  METHOD lif_bukrs~process_data.
*     no implementation in factory class
  ENDMETHOD.                    "process_data


ENDCLASS.                    "lcl_bukrs IMPLEMENTATION



*---------------------------------------------------------------------*
*       CLASS lcl_bukrs_1000
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_bukrs_1000 DEFINITION.


  PUBLIC SECTION.
    INTERFACES lif_bukrs.

ENDCLASS.                    "lcl_bukrs_1000  INHERITING FRO


*---------------------------------------------------------------------*
*       CLASS lcl_bukrs_1000 IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_bukrs_1000 IMPLEMENTATION.

  METHOD lif_bukrs~process_data.
*   define local data
    DATA:
      ld_msg    TYPE bapi_msg.

    CONCATENATE 'Company Code' lif_bukrs~md_bukrs
      INTO ld_msg SEPARATED BY ' = '.
    MESSAGE ld_msg TYPE 'I'.
  ENDMETHOD.                    "process_data
ENDCLASS.                    "lcl_bukrs_1000 IMPLEMENTATION


*---------------------------------------------------------------------*
*       CLASS lcl_bukrs_2000
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_bukrs_2000 DEFINITION.


  PUBLIC SECTION.
    INTERFACES lif_bukrs.

ENDCLASS.                    "lcl_bukrs_2000  INHERITING FRO


*---------------------------------------------------------------------*
*       CLASS lcl_bukrs_2000 IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_bukrs_2000 IMPLEMENTATION.

  METHOD lif_bukrs~process_data.
*   define local data
    DATA:
      lt_knb1    TYPE STANDARD TABLE OF knb1,
      lo_table   TYPE REF TO cl_salv_table.

    SELECT * FROM knb1 INTO TABLE lt_knb1
      WHERE bukrs = lif_bukrs~md_bukrs.

    TRY.
        CALL METHOD cl_salv_table=>factory
          IMPORTING
            r_salv_table = lo_table
          CHANGING
            t_table      = lt_knb1.
        lo_table->display( ).
      CATCH cx_salv_msg .
    ENDTRY.
  ENDMETHOD.                    "process_data
ENDCLASS.                    "lcl_bukrs_2000 IMPLEMENTATION


*---------------------------------------------------------------------*
*       CLASS lcl_bukrs_3000
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_bukrs_3000 DEFINITION.


  PUBLIC SECTION.
    INTERFACES lif_bukrs.

ENDCLASS.                    "lcl_bukrs_3000  INHERITING FRO


*---------------------------------------------------------------------*
*       CLASS lcl_bukrs_3000 IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_bukrs_3000 IMPLEMENTATION.

  METHOD lif_bukrs~process_data.
    CALL FUNCTION 'VIEW_MAINTENANCE_CALL'
      EXPORTING
        action    = 'S'
        view_name = 'V_T001'
      EXCEPTIONS
        OTHERS    = 15.
    IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

  ENDMETHOD.                    "process_data
ENDCLASS.                    "lcl_bukrs_3000 IMPLEMENTATION



PARAMETER:
  p_bukrs      TYPE bukrs  DEFAULT '1000'.


DATA:
  gif_bukrs    TYPE REF TO lif_bukrs.

<b>START-OF-SELECTION.</b>

  gif_bukrs = lcl_bukrs=>create( p_bukrs ).
  IF ( gif_bukrs IS NOT BOUND ).
    MESSAGE 'No implementation found' TYPE 'S'.
    RETURN.
  ENDIF.

* NOTE: Coding in main program remains the same yet the
*       function executed depends on selected company code
  gif_bukrs->process_data( ).

<b>END-OF-SELECTION.</b>

Regards

Uwe

Former Member
0 Kudos

Hi Venkat,

Welcome to SDN.

Check the below links u will find lot of info on oops concept in abap....

http://www.sapgenie.com/abap/OO/index.htm

http://www.geocities.com/victorav15/sapr3/abap_ood.html

http://www.brabandt.de/html/abap_oo.html

Check this cool weblog:

/people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql

/people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql

http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b6254f411d194a60000e8353423/frameset.htm

http://www.sapgenie.com/abap/OO/

http://www.sapgenie.com/abap/OO/index.htm

http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm

http://www.esnips.com/doc/375fff1b-5a62-444d-8ec1-55508c308b17/prefinalppt.ppt

http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf

http://www.esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt

http://www.allsaplinks.com/

http://www.sap-img.com/

http://www.sapgenie.com/

http://help.sap.com

http://www.sapgenie.com/abap/OO/

http://www.sapgenie.com/abap/OO/index.htm

http://www.sapgenie.com/abap/controls/index.htm

http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf

http://www.esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf

http://www.sapgenie.com/abap/OO/index.htm

http://help.sap.com/saphelp_erp2005/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm

http://www.sapgenie.com/abap/OO/

these links

http://help.sap.com/saphelp_47x200/helpdata/en/ce/b518b6513611d194a50000e8353423/content.htm

For funtion module to class

http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5954f411d194a60000e8353423/content.htm

for classes

http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5c54f411d194a60000e8353423/content.htm

for methods

http://help.sap.com/saphelp_47x200/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm

for inheritance

http://help.sap.com/saphelp_47x200/helpdata/en/dd/4049c40f4611d3b9380000e8353423/content.htm

for interfaces

http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b6254f411d194a60000e8353423/content.htm

For Materials:

1) http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf -- Page no: 1291

2) http://esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt

3) http://esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf

4) http://esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf

5) http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt

6) http://esnips.com/doc/448e8302-68b1-4046-9fef-8fa8808caee0/abap-objects-by-helen.pdf

7) http://esnips.com/doc/39fdc647-1aed-4b40-a476-4d3042b6ec28/class_builder.ppt

😎 http://www.amazon.com/gp/explorer/0201750805/2/ref=pd_lpo_ase/102-9378020-8749710?ie=UTF8

1) http://www.erpgenie.com/sap/abap/OO/index.htm

2) http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm

If ou find it useful plz mark the points

~~Guduri