[ABAP] Klassen für Zugriff auf Business-Objekte

SAPoffice Dokumente

  • verlinkt auf Business Objekte via Object Relationship Service Tables
  • Klasse: CL_BINARY_RELATION (ersetzt FuBas SO_DOCUMENT*)
  • Tabellen: SRGBTBREL

Beispiel

* Quelle / Inspiration: https://www.inwerken.de/gos-anhange-auslesen-anlegen/

**********************************************************************
* Typen
**********************************************************************
TYPES: BEGIN OF ty_s_key,
         foltp     TYPE so_fol_tp,
         folyr     TYPE so_fol_yr,
         folno     TYPE so_fol_no,
         objtp     TYPE so_obj_tp,
         objyr     TYPE so_obj_yr,
         objno     TYPE so_obj_no,
         forwarder TYPE so_usr_nam,
       END OF ty_s_key.
**********************************************************************
* Selektionsbild
**********************************************************************
PARAMETERS: p_instid TYPE sibfboriid DEFAULT '000000001234567890'.
PARAMETERS: p_typeid TYPE sibftypeid DEFAULT 'BUS1001006'.
PARAMETERS: p_catid TYPE sibfcatid DEFAULT 'BO'.

START-OF-SELECTION.

* Schlüssel des Business-Objekts
  DATA(lv_object) = VALUE sibflporb( instid  = p_instid
                                     typeid  = p_typeid
                                     catid   = p_catid ).

* Verknüpfungsoptionen
* Verknüpfungstypen
  DATA(it_relopt) = VALUE obl_t_relt( ( sign   = 'I'
                                        option = 'EQ'
                                        low    = 'ATTA' " Anhänge
                                      )
                                      ( sign   = 'I'
                                        option = 'EQ'
                                        low    = 'NOTE' " Notizen
                                      )
                                      ( sign   = 'I'
                                        option = 'EQ'
                                        low    = 'URL'  " URLs
                                      )
                                    ).

  TRY.
* Verknüpfungen zum Objekt
      DATA(it_links) = VALUE obl_t_link( ).
      DATA(it_roles) = value obl_t_role( ).

* Verknüpfungen zum Objekt lesen
      cl_binary_relation=>read_links_of_binrels( EXPORTING
                                                   is_object           = lv_object
                                                   it_relation_options = it_relopt
                                                   ip_role             = 'GOSAPPLOBJ'
                                                 IMPORTING
                                                   et_links            = it_links
                                                   et_roles            = it_roles ).

      cl_demo_output=>write_data( it_links ).
      cl_demo_output=>write_data( it_roles ).

* Verknüpfungen vom Typ 'MESSAGE' durchgehen
      LOOP AT it_links ASSIGNING FIELD-SYMBOL(<l>) WHERE typeid_b = 'MESSAGE'.

        cl_demo_output=>line( ).

* Schlüssel einer Verknüpfung
        DATA(lv_key) = CONV ty_s_key( <l>-instid_b ).
        cl_demo_output=>write_data( lv_key ).

* Dokumenten-Grunddaten
        DATA(lv_doc_data) = VALUE sofolenti1( ).
* Dokumenteninhalt Text und Binär
        DATA(it_contx) = VALUE solix_tab( ).
        DATA(it_cont) = VALUE soli_tab( ).

* Daten des Dokuments lesen
        CALL FUNCTION 'SO_DOCUMENT_READ_API1'
          EXPORTING
            document_id                = CONV sofolenti1-doc_id( <l>-instid_b ) " Dokumenten-ID für SAPOffice == Instanz-ID
          IMPORTING
            document_data              = lv_doc_data
          TABLES
            object_content             = it_cont
            contents_hex               = it_contx
          EXCEPTIONS
            document_id_not_exist      = 1
            operation_no_authorization = 2
            x_error                    = 3
            OTHERS                     = 4.
        IF sy-subrc = 0.
          cl_demo_output=>write_data( lv_doc_data ).
          cl_demo_output=>write_data( it_cont ).
        ENDIF.

      ENDLOOP.

      cl_demo_output=>display( ).

    CATCH cx_root INTO DATA(e_txt).
      WRITE: / e_txt->get_text( ).
  ENDTRY.

Archivdokumente

  • Logische Dokumente, verlinkt auf Business Objekte via Connection Tables des Content Management Systems
  • Klasse: CL_ALINK_CONNECTION
  • Funktionen: find, find_by_doc_key, compose, insert, delete_by_key
  • Tabellen: TOAAR, TOAOM, TOJTB, TOA01, TOA02, TOA03

Beispiel

TRY.
    DATA(o_alink) = NEW cl_alink_connection( ).
* Suche von Verknüpfungen
    o_alink->find( EXPORTING 
                     sap_object = 'ZXYZ'                   " SAP ArchiveLink: Objekttyp des Business Objekts
                     object_id  = CONV saeobjid( '12345' ) " SAP ArchiveLink: Objekt-Id (Objektidentifikator)
                     mandt      = sy-mandt                 " Mandantenkennung des aktuellen Benutzers
                     archiv_id  = 'XY'                     " Content Repository Identifikation
                   IMPORTING
                     connections = DATA(it_conn) ).
    
    cl_demo_output=>display( it_conn ).
  CATCH cx_root.
ENDTRY.

[ABAP] String in Textabelle (SOLITAB) konvertieren

* Teststring bauen
DATA(lv_string) = REDUCE string( INIT s = ||
                                 FOR i = 1 WHILE i < 1001
                                 NEXT s = |{ s }{ i }| ).

* Ausgabetabelle
DATA(it_soli_txt) = VALUE soli_tab( ).

* string -> solitab (Text-Tabelle mit Zeilen a 255 Zeichen)
CALL FUNCTION 'SO_STRING_TO_TAB'
  EXPORTING
    content_str = lv_string
  TABLES
    content_tab = it_soli_txt.

* Ausgabe
cl_demo_output=>display( it_soli_txt ).