BAPI and ABAP objects 

Why BAPI is not integrated with ABAP objects? 

In general, BAPI is more in the macro level and ABAP objects in the micro. 

I think that the technical reason is that BAPI can be used from outside of R/3. The method this is based on is RFC and therefore all the BAPIs are function modules whereas methods of ABAP objects are not.

Object Oriented BAPI access

Some standard ABAP Object classes encapsulating business objects from the BOR (since BAPI's are the API's of business objects). I don't believe there are many (any) provided by SAP.

However, you can create your own wrapper classes calling methods of business objects using dedicated FM's  starting with SWO_...

Here is a small example:

REPORT ybkpf_swo_test.

*----------------------------------------------------------------------*
*       CLASS LCL_ACCOUNTING_DOCUMENT
*----------------------------------------------------------------------*
CLASS lcl_accounting_document DEFINITION.

   PUBLIC SECTION.

     TYPES BEGIN OF ac_doc_key.
     TYPES company_code  TYPE bukrs.
     TYPES doc_number    TYPE belnr_d.
     TYPES fiscal_year   TYPE gjahr.
     TYPES END OF ac_doc_key.

     CLASS-METHODS get
       IMPORTING
         i_company_code  TYPE ac_doc_key-company_code
         i_doc_number    TYPE ac_doc_key-doc_number
         i_fiscal_year   TYPE ac_doc_key-fiscal_year
       RETURNING
         value(r_object) TYPE REF TO lcl_accounting_document.

     METHODS display.

   PRIVATE SECTION.

     DATA key    TYPE ac_doc_key.
     DATA object TYPE swo_objhnd.

ENDCLASS.                    "LCL_ACCOUNTING_DOCUMENT
 

*----------------------------------------------------------------------*
*       CLASS LCL_ACCOUNTING_DOCUMENT IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS lcl_accounting_document IMPLEMENTATION.

   METHOD get.

     DATA:
       objtype TYPE swo_objtyp,
       objkey  TYPE swo_typeid.

     CREATE OBJECT r_object.

     r_object->key-company_code = i_company_code.
     r_object->key-doc_number   = i_doc_number.
     r_object->key-fiscal_year  = i_fiscal_year.

     objtype =  'BKPF'.
     objkey  =  r_object->key.

     CALL FUNCTION 'SWO_CREATE'
       EXPORTING
         objtype = objtype
         objkey  = objkey
       IMPORTING
         object  = r_object->object.

   ENDMETHOD.                    "lcl_accounting_document

   METHOD display.

     DATA :
       container_tab TYPE STANDARD TABLE OF swcont.

     CALL FUNCTION 'SWO_INVOKE'
       EXPORTING
         object    = object
         verb      = 'Display'
       TABLES
         container = container_tab.

   ENDMETHOD.                    "display

ENDCLASS.                    "LCL_ACCOUNTING_DOCUMENT IMPLEMENTATION

PARAMETERS p_bukrs TYPE bkpf-bukrs.
PARAMETERS p_belnr TYPE bkpf-belnr.
PARAMETERS p_gjahr TYPE bkpf-gjahr.

DATA :
   ac_document TYPE REF TO lcl_accounting_document.

*----------------------------------------------------------------------*
START-OF-SELECTION.
*----------------------------------------------------------------------*

   ac_document = lcl_accounting_document=>get(
     i_company_code = p_bukrs
     i_doc_number   = p_belnr
     i_fiscal_year  = p_gjahr ).

   ac_document->display( ).

Fast Links:
Sample Download Programs:

SAP Books
SAP Certification, Functional, Basis Administration and ABAP Programming Reference Books

ABAP Programming Tips
ABAP and Samples Program Codes for Abapers

Best regards,
SAP Basis, ABAP Programming and Other IMG Stuff
http://www.erpgreat.com

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.  The site www.erpgreat.com is in no way affiliated with SAP AG.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk. 
 The content on this site may not be reproduced or redistributed without the express written permission of 
www.erpgreat.com or the content authors.