Generische Objektdienste (GOS): Unterschied zwischen den Versionen

Aus SAP Wiki ツ
Zeile 14: Zeile 14:
   CALL FUNCTION 'SO_SOLITAB_TO_SOLIXTAB'
   CALL FUNCTION 'SO_SOLITAB_TO_SOLIXTAB'
     EXPORTING
     EXPORTING
       ip_solitab  = it_object_content
       ip_solitab  = it_object_content "TYPE SOFOLENTI1
     IMPORTING
     IMPORTING
       ep_solixtab = lt_solixtab.
       ep_solixtab = lt_solixtab.
Zeile 52: Zeile 52:
</syntaxhighlight>
</syntaxhighlight>


==== Inhalt Datei bekommen ====
<syntaxhighlight lang="abap" line start="1">
  CALL FUNCTION 'SO_DOCUMENT_READ_API1'
    EXPORTING
      document_id                = iv_docno " TYPE SO_ENTRYID
    IMPORTING
      document_data              = ls_docoument_data
    TABLES
      object_header              = lt_object_header
      object_content            = lt_object_content
    EXCEPTIONS
      document_id_not_exist      = 1
      operation_no_authorization = 2
      x_error                    = 3
      OTHERS                    = 4.
"convert bin zu xstring
</syntaxhighlight>
==== Anhänge bekommen ====
==== Anhänge bekommen ====
<syntaxhighlight lang="abap" line start="1">
<syntaxhighlight lang="abap" line start="1">

Version vom 15. November 2024, 20:37 Uhr

Coding

FuBas, Klassen

Konvertierungen

BIN zu XSTRING
DATA lt_solixtab TYPE solix_tab.
DATA lv_docsize  TYPE i.
DATA lv_xstring TYPE xstring.

  CALL FUNCTION 'SO_SOLITAB_TO_SOLIXTAB'
    EXPORTING
      ip_solitab  = it_object_content "TYPE SOFOLENTI1
    IMPORTING
      ep_solixtab = lt_solixtab.

  lv_docsize = lines( lt_solixtab ) * 255.

  CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
    EXPORTING
      input_length = lv_docsize
    IMPORTING
      buffer       = lv_xstring
    TABLES
      binary_tab   = lt_solixtab
    EXCEPTIONS
      failed       = 1
      OTHERS       = 2.
XSTRING zu BIN
DATA lt_content_x    TYPE solix_tab.
  DATA lv_solix_length TYPE i.

  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
      buffer        = iv_xstring
    IMPORTING
      output_length = lv_solix_length
    TABLES
      binary_tab    = lt_content_x.

  CALL FUNCTION 'SO_SOLIXTAB_TO_SOLITAB'
    EXPORTING
      ip_solixtab = lt_content_x
    IMPORTING
      ep_solitab  = lt_content.

Inhalt Datei bekommen

  CALL FUNCTION 'SO_DOCUMENT_READ_API1'
    EXPORTING
      document_id                = iv_docno " TYPE SO_ENTRYID
    IMPORTING
      document_data              = ls_docoument_data
    TABLES
      object_header              = lt_object_header
      object_content             = lt_object_content
    EXCEPTIONS
      document_id_not_exist      = 1
      operation_no_authorization = 2
      x_error                    = 3
      OTHERS                     = 4.

"convert bin zu xstring

Anhänge bekommen

DATA(ls_lpor) = VALUE sibflporb( instid = *Business Objekt Key* "z.B. Belegnummer Kundenauftrag
                                 typeid = *Business Objekt TYPE* "z.B. Kundenauftrag BUS2032
                                 catid  = 'BO' ).

DATA(lt_rel_options) = VALUE obl_t_relt( ( sign   = 'I'
                                           option = 'EQ'
                                           low    = 'ATTA' ) ).

cl_binary_relation=>read_links_of_binrels(
 EXPORTING
  is_object           = ls_lpor
  it_relation_options = lt_rel_options
  ip_role             = 'GOSAPPLOBJ'
 IMPORTING
  et_links            = DATA(lt_links) ).
 CATCH cx_obl_parameter_error
  cx_obl_internal_error
  cx_obl_model_error.

Anhänge kopieren

"Prüfen, ob die Quelle Anhänge hat, s. o.
DATA(ls_source) = VALUE sibflporb( instid = *Business Objekt Key* "z.B. Belegnummer Kundenauftrag
                                   typeid = *Business Objekt TYPE* "z.B. Kundenauftrag BUS2032
                                   catid  = 'BO' ).

DATA(ls_target) = VALUE sibflporb( instid = *Business Objekt Key* "z.B. Belegnummer Kontrakt
                                   typeid = *Business Objekt TYPE* "z.B. Kontrakt BUS2034
                                   catid  = 'BO' ).

cl_gos_service_tools=>copy_linked_objects( is_source            = ls_source
                                           is_target            = ls_target
                                           it_service_selection = VALUE tgos_sels( ( sign   = 'I'
                                                                                     option = 'EQ'
                                                                                     low    = 'PCATTA_CREA' ) 
                                                                                  ) 
                                          ).

APIs