[SAP] Business-Objekte (BOR) / BAPI

Transaktionen

SWO1 (Business Object Builder)

  • Business Objekte anlegen und anzeigen

SWO2 (BOR Browser)
SWO3 (Business Object Builder)
SWO4 (Business Object Repository)
SWO6 (Customizing Objekttypen)
BAPI (BAPI Explorer)

  • Business Objekte anlegen und anzeigen

Objekttypen (Beispiele)

BUS1001 (Material)
BUS1001006 (Standard Material)
BUS2010 (Lieferantenanfrage)
BUS2011 (Lieferantenangebot)
BUS2012 (Bestellung)
BUS2015 (Anlieferung)
BUS2017 (Warenbewegung)
BUS2030 (Kundenanfrage)
BUS2032 (Kundenauftrag)
BUS2081 (Eingangsrechnung)
BUS2091 (Leistungserfassungsblatt)
BUS2105 (Bestellanforderung)
BUS3005 (Kondition)

Klassen

CL_BINARY_RELATION (API für Binäre Verknüpfung)

Tabellen

TOJTB (Business Object Repository Grunddaten)
TOJTT (Texte Grunddaten)
TOJTD (Customizing Objekttypen)
SWOTDI (Definition Schnittstellen)
SWOTDV (Objekttyp Verben Definition)
SWOTLQ (Laufzeittabelle Parameter, Ausnahmen)
SWOTLV (Laufzeittabelle Verben)
SWOTTV (Texte zu Verben)

Funktionsbausteine

SWO_CREATE (Business Objekt initiieren)
SWO_INVOKE (Buisness Objekt Metode aufrufen / Attribute setzen)
SWO_FREE (Business Objekt freigeben)
SWE_EVENT_CREATE (Erzeugen eines Ereignisses (public))
SWE_EVENT_GET_RECEIVERS (Ermittelt die Empfänger eines Ereignisses (INTERN))

Reports

MMPUR_BOR_CHANGE_ARL (Business Object Migration von EKKO nach BUS20xx)

Links

[ABAP] Funktionen von Business Objekten aufrufen

Beispiel 1 (Bestellung anzeigen)

* http://saptechnical.com/Tutorials/Workflow/BusinessObjects/Page1.htm
* weitere Funktionen siehe SAP-Include:
* INCLUDE <cntn01>.

* Paket: SWO

* Tabellen:

* TOJTB (Business Object Repository Grunddaten)
* TOJTT (Texte Grunddaten)
* TOJTD (Customizing Objekttypen)
* SWOTDI (Definition Schnittstellen)
* SWOTDV (Objekttyp Verben Definition)
* SWOTLQ (Laufzeittabelle Parameter, Ausnahmen)
* SWOTLV (Laufzeittabelle Verben)

* BUS2012 == Bestellung
PARAMETERS: p_objtyp TYPE swo_objtyp DEFAULT 'BUS2012'.
* Bestellnummer
PARAMETERS: p_objkey TYPE swo_typeid DEFAULT '0001122333'.

START-OF-SELECTION.

  TYPES: ty_it_container TYPE STANDARD TABLE OF swcont WITH DEFAULT KEY.

  DATA: lv_obj TYPE swo_objhnd.
  DATA: lv_ret TYPE swotreturn.

  * Business Objekt initiieren
  CALL FUNCTION 'SWO_CREATE'
    EXPORTING
      objtype           = p_objtyp
      objkey            = p_objkey
    IMPORTING
      object            = lv_obj
      return            = lv_ret
    EXCEPTIONS
      no_remote_objects = 1
      OTHERS            = 2.

  IF sy-subrc = 0.
  * Container für Rückgabewerte
    DATA: it_container TYPE ty_it_container.

  * Buisness Objekt Metode aufrufen / Attribute setzen
    CALL FUNCTION 'SWO_INVOKE'
      EXPORTING
        access     = 'C'        " C - Call Method, G - Get Attribute
        object     = lv_obj
        verb       = 'DISPLAY'  " Anzeigen
      IMPORTING
        return     = lv_ret
      TABLES
        container  = it_container.

    IF lv_ret-code <> 0.
      WRITE: / lv_ret-code, lv_ret-errortype, lv_ret-workarea, lv_ret-message, lv_ret-text, lv_ret-variable1, lv_ret-variable2, lv_ret-variable3, lv_ret-variable4.
    ENDIF.
  ELSE.
    IF lv_ret-code <> 0.
      WRITE: / lv_ret-code, lv_ret-errortype, lv_ret-workarea, lv_ret-message, lv_ret-text, lv_ret-variable1, lv_ret-variable2, lv_ret-variable3, lv_ret-variable4.
    ENDIF.
  ENDIF.

  CALL FUNCTION 'SWO_FREE'
    EXPORTING
      object = lv_obj
    IMPORTING
      return = lv_ret.

  IF lv_ret-code <> 0.
    WRITE: / lv_ret-code, lv_ret-errortype, lv_ret-workarea, lv_ret-message, lv_ret-text, lv_ret-variable1, lv_ret-variable2, lv_ret-variable3, lv_ret-variable4.
  ENDIF.

Beispiel 2 (Details zur Bestellung auflisten)

* http://saptechnical.com/Tutorials/Workflow/BusinessObjects/Page1.htm
* weitere Funktionen siehe SAP-Include:
* INCLUDE <cntn01>.

* BUS2012 == Bestellung
PARAMETERS: p_objtyp TYPE swo_objtyp DEFAULT 'BUS2012'.
* Bestellnummer
PARAMETERS: p_objkey TYPE swo_typeid DEFAULT '0001122333'.

START-OF-SELECTION.

  TYPES: ty_it_container TYPE STANDARD TABLE OF swcont WITH DEFAULT KEY.

  DATA: lv_obj TYPE swo_objhnd.
  DATA: lv_ret TYPE swotreturn.

  * Business Objekt initiieren
  CALL FUNCTION 'SWO_CREATE'
    EXPORTING
      objtype           = p_objtyp
      objkey            = p_objkey
    IMPORTING
      object            = lv_obj
      return            = lv_ret
    EXCEPTIONS
      no_remote_objects = 1
      OTHERS            = 2.

  IF sy-subrc = 0.
  * Container für Rückgabewerte
    DATA: it_container TYPE ty_it_container.

  * Buisness Objekt Metode aufrufen / Attribute setzen
    CALL FUNCTION 'SWO_INVOKE'
      EXPORTING
        access    = 'C'           " C - Call Method, G - Get Attribute
        object    = lv_obj
        verb      = 'GETDETAIL1'  " Details
      IMPORTING
        return    = lv_ret
      TABLES
        container = it_container.

    IF lv_ret-code = 0.
      LOOP AT it_container ASSIGNING FIELD-SYMBOL(<a>).
        WRITE: / |{ <a>-element }: { <a>-value }|.
      ENDLOOP.
    ELSE.
      WRITE: / lv_ret-code, lv_ret-errortype, lv_ret-workarea, lv_ret-message, lv_ret-text, lv_ret-variable1, lv_ret-variable2, lv_ret-variable3, lv_ret-variable4.
    ENDIF.
  ELSE.
    IF lv_ret-code <> 0.
      WRITE: / lv_ret-code, lv_ret-errortype, lv_ret-workarea, lv_ret-message, lv_ret-text, lv_ret-variable1, lv_ret-variable2, lv_ret-variable3, lv_ret-variable4.
    ENDIF.
  ENDIF.

  CALL FUNCTION 'SWO_FREE'
    EXPORTING
      object = lv_obj
    IMPORTING
      return = lv_ret.

  IF lv_ret-code <> 0.
    WRITE: / lv_ret-code, lv_ret-errortype, lv_ret-workarea, lv_ret-message, lv_ret-text, lv_ret-variable1, lv_ret-variable2, lv_ret-variable3, lv_ret-variable4.
  ENDIF.

Beispiel 3 (Attribut zum Material anzeigen)

* http://saptechnical.com/Tutorials/Workflow/BusinessObjects/Page1.htm
* weitere Funktionen siehe SAP-Include:
* INCLUDE <cntn01>.

* BUS1001006 == Standard Material
PARAMETERS: p_objtyp TYPE swo_objtyp DEFAULT 'BUS1001006'.
* 18-stellige Materialnummer
PARAMETERS: p_objkey TYPE swo_typeid DEFAULT '000000001112223333'.

START-OF-SELECTION.

  TYPES: ty_it_container TYPE STANDARD TABLE OF swcont WITH DEFAULT KEY.

  DATA: lv_obj TYPE swo_objhnd.
  DATA: lv_ret TYPE swotreturn.

  * Buisiness Objekt initiieren
  CALL FUNCTION 'SWO_CREATE'
    EXPORTING
      objtype           = p_objtyp
      objkey            = p_objkey
    IMPORTING
      object            = lv_obj
      return            = lv_ret
    EXCEPTIONS
      no_remote_objects = 1
      OTHERS            = 2.

  IF sy-subrc = 0.
  * Container für Rückgabewerte
    DATA: it_container TYPE ty_it_container.

  * Buisness Objekt Metode aufrufen / Attribute setzen
    CALL FUNCTION 'SWO_INVOKE'
      EXPORTING
        access    = 'G'             " C - Call Method, G - Get Attribute
        object    = lv_obj
        verb      = 'MATERIALTYPE'  " Attribut
      IMPORTING
        return    = lv_ret
      TABLES
        container = it_container.

    IF lv_ret-code = 0.
      LOOP AT it_container ASSIGNING FIELD-SYMBOL(<a>).
        WRITE: / |{ <a>-element }: { <a>-value }|.
      ENDLOOP.
    ELSE.
      WRITE: / lv_ret-code, lv_ret-errortype, lv_ret-workarea, lv_ret-message, lv_ret-text, lv_ret-variable1, lv_ret-variable2, lv_ret-variable3, lv_ret-variable4.
    ENDIF.
  ELSE.
    IF lv_ret-code <> 0.
      WRITE: / lv_ret-code, lv_ret-errortype, lv_ret-workarea, lv_ret-message, lv_ret-text, lv_ret-variable1, lv_ret-variable2, lv_ret-variable3, lv_ret-variable4.
    ENDIF.
  ENDIF.

  CALL FUNCTION 'SWO_FREE'
    EXPORTING
      object = lv_obj
    IMPORTING
      return = lv_ret.

  IF lv_ret-code <> 0.
    WRITE: / lv_ret-code, lv_ret-errortype, lv_ret-workarea, lv_ret-message, lv_ret-text, lv_ret-variable1, lv_ret-variable2, lv_ret-variable3, lv_ret-variable4.
  ENDIF.

Beispiel 4 (Material Detail)

* http://saptechnical.com/Tutorials/Workflow/BusinessObjects/Page1.htm
* weitere Funktionen siehe SAP-Include:
* INCLUDE <cntn01>.

* BUS1001006 == Standard Material
PARAMETERS: p_objtyp TYPE swo_objtyp DEFAULT 'BUS1001006'.
* 18-stellige Materialnummer
PARAMETERS: p_objkey TYPE swo_typeid DEFAULT '000000001112223333'.

START-OF-SELECTION.

  TYPES: ty_it_container TYPE STANDARD TABLE OF swcont WITH DEFAULT KEY.

  DATA: lv_obj TYPE swo_objhnd.
  DATA: lv_ret TYPE swotreturn.

  * Buisiness Objekt initiieren
  CALL FUNCTION 'SWO_CREATE'
    EXPORTING
      objtype           = p_objtyp
      objkey            = p_objkey
    IMPORTING
      object            = lv_obj
      return            = lv_ret
    EXCEPTIONS
      no_remote_objects = 1
      OTHERS            = 2.

  IF sy-subrc = 0.
  * Container für Rückgabewerte
    DATA: it_container TYPE ty_it_container.

  * SWO1 -> Objekttyp -> Methoden
  * oder
  * Tabelle SWOTDV -> Spalte VERB, VERBTYPE = M
  *GetDetail                             Detaildaten zu einem Material ermitteln
  *ExistenceCheck                        Existenz des Objekts prüfen
  *GetList                               Liste mit Kurztext
  *Display                               Material anzeigen
  *GetMRPList                            Dispositionsliste eines Materials
  *GetStockRequirementsList              Aktuelle Bedarfs-/Bestandsliste eines Materials

  * Buisness Objekt Metode aufrufen / Attribute setzen
    CALL FUNCTION 'SWO_INVOKE'
      EXPORTING
        access    = 'C'          " C - Call Method, G - Get Attribute
        object    = lv_obj
        verb      = 'GETDETAIL'  " Details
      IMPORTING
        return    = lv_ret
      TABLES
        container = it_container.

    IF lv_ret-code = 0.
      LOOP AT it_container ASSIGNING FIELD-SYMBOL(<a>).
        WRITE: / |{ <a>-element }: { <a>-value }|.
      ENDLOOP.
    ELSE.
      WRITE: / lv_ret-code, lv_ret-errortype, lv_ret-workarea, lv_ret-message, lv_ret-text, lv_ret-variable1, lv_ret-variable2, lv_ret-variable3, lv_ret-variable4.
    ENDIF.
  ELSE.
    IF lv_ret-code <> 0.
      WRITE: / lv_ret-code, lv_ret-errortype, lv_ret-workarea, lv_ret-message, lv_ret-text, lv_ret-variable1, lv_ret-variable2, lv_ret-variable3, lv_ret-variable4.
    ENDIF.
  ENDIF.

  CALL FUNCTION 'SWO_FREE'
    EXPORTING
      object = lv_obj
    IMPORTING
      return = lv_ret.

  IF lv_ret-code <> 0.
    WRITE: / lv_ret-code, lv_ret-errortype, lv_ret-workarea, lv_ret-message, lv_ret-text, lv_ret-variable1, lv_ret-variable2, lv_ret-variable3, lv_ret-variable4.
  ENDIF.