2016 Feb 19 6:06 AM
Hi,
Is object oriented access of BAPIs is possible or through only FM we can access them in ABAP. If possible can somebody provide link to a documentation/example for that.
Regards,
What do you mean with "OO access?"
BAPIs are FM and as FM can be called both in "old way" FORM and in methods
2016 Feb 19 6:10 AM
2016 Feb 19 6:23 AM
Thanks Sabir for your response, but my question is that: Is the object Oriented access to BAPIs is possible in ABAP??? The link you provided is for OO BAPI access from other languages C++, Java. I want to know Is BAPI access in ABAP is possible only via FMs or classes are also there.
2016 Feb 19 8:32 AM
What do you mean with "OO access?"
BAPIs are FM and as FM can be called both in "old way" FORM and in methods
2016 Feb 19 4:54 PM
I think you are looking for 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( ).
BR,
Gábor
2016 Feb 22 7:12 AM
Thanks Gabor for understanding yes I had to confirm are there any wrapper classes available for Business Objects, since I also googled a lot on this and I thinks there are not any standard provided by SAP.
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |