adesso orange🍊Stellenangebote:
Software Engineer Trainee · Senior
| (Senior) Cloud Software Engineer BTP
(Senior) Consultant Technologie · Consultant ABAP
Werkstudent Softwareentwicklung · Fiori / UI5 · Consulting · Application Management
Generische Objektdienste (GOS): Unterschied zwischen den Versionen
Aus SAP Wiki ツ
Zeile 40: | Zeile 40: | ||
<syntaxhighlight lang="abap" line start="1"> | <syntaxhighlight lang="abap" line start="1"> | ||
*Parameter | *Parameter | ||
IV_XSTRING TYPE XSTRING | *IV_XSTRING TYPE XSTRING | ||
value( RT_CONTENT ) TYPE SOLI_TAB | *value( RT_CONTENT ) TYPE SOLI_TAB | ||
Version vom 15. November 2024, 20:46 Uhr
Coding
FuBas, Klassen
Konvertierungen
BIN zu XSTRING
*Parameter
*IS_DOCOUMENT_DATA TYPE SOFOLENTI1
*IT_OBJECT_CONTENT TYPE SWFTLISTI1
*value( RV_XSTRING ) TYPE 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
*Parameter
*IV_XSTRING TYPE XSTRING
*value( RT_CONTENT ) TYPE SOLI_TAB
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
*Parameter
*IV_DOCNO TYPE SO_ENTRYID
*ES_DOCOUMENT_DATA TYPE SOFOLENTI1
*ET_OBJECT_HEADER TYPE SWFTLISTI1
*ET_OBJECT_CONTENT TYPE SWFTLISTI1
*EV_XSTRING TYPE XSTRING
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 hinzufügen
*Parameter
*IS_DOCOUMENT_DATA TYPE SOFOLENTI1
*IT_OBJECT_HEADER TYPE SWFTLISTI1
*IV_XSTRING TYPE XSTRING
*value( RS_OBJECT_HEAD ) TYPE SOOD2
DATA ls_root_folder TYPE soodk.
DATA ls_object_id TYPE soodk.
DATA lt_content TYPE soli_tab.
DATA ls_doc_data TYPE sood1.
DATA ls_object_head TYPE sood2.
CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'
EXPORTING
region = 'B'
IMPORTING
folder_id = ls_root_folder
EXCEPTIONS
communication_failure = 1
owner_not_exist = 2
system_failure = 3
x_error = 4
OTHERS = 5.
IF sy-subrc <> 0.
RETURN.
ENDIF.
lt_content = convert_xstring_to_bin( iv_xstring ).
ls_doc_data = VALUE #( objla = is_docoument_data-obj_langu
objsrt = is_docoument_data-obj_sort
objnam = is_docoument_data-obj_name
objdes = is_docoument_data-obj_descr
objpri = is_docoument_data-obj_prio
objsns = is_docoument_data-sensitivty
acout = is_docoument_data-to_do_out
vmtyp = is_docoument_data-proc_type
skips = is_docoument_data-skip_scren
objcp = is_docoument_data-no_change
ownnam = is_docoument_data-owner_nam ).
CALL FUNCTION 'SO_OBJECT_INSERT'
EXPORTING
folder_id = ls_root_folder
object_hd_change = ls_doc_data
object_type = 'EXT'
IMPORTING
object_hd_display = ls_object_head
object_id = ls_object_id
TABLES
objcont = lt_content
objhead = it_object_header
EXCEPTIONS
active_user_not_exist = 1
communication_failure = 2
component_not_available = 3
dl_name_exist = 4
folder_not_exist = 5
folder_no_authorization = 6
object_type_not_exist = 7
operation_no_authorization = 8
owner_not_exist = 9
parameter_error = 10
substitute_not_active = 11
substitute_not_defined = 12
system_failure = 13
x_error = 14
OTHERS = 15.
IF sy-subrc <> 0.
RETURN.
ENDIF.
IF create_binary_relation( is_root_folder = ls_root_folder
is_object_id = ls_object_id ).
"Alle Schritte erfogreich durchgeführt
"--> Informationen zur Datei zurückgeben
rs_object_head = ls_object_head.
ENDIF.
Anhänge bekommen
*Parameter
*value( RT_LINKS ) TYPE OBL_T_LINK
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' )
)
).
Anhänge löschen
"is_link TYPE OBL_S_LINK
DATA ls_lpor_a TYPE sibflporb.
DATA ls_lpor_b TYPE sibflporb.
DATA ls_folder_id TYPE soodk.
DATA ls_object_id TYPE soodk.
IF is_link IS INITIAL.
RETURN.
ENDIF.
ls_lpor_a = VALUE #( catid = is_link-catid_a
typeid = is_link-typeid_a
instid = is_link-instid_a ).
ls_lpor_b = VALUE #( catid = is_link-catid_b
typeid = is_link-typeid_b
instid = is_link-instid_b ).
TRY.
cl_binary_relation=>delete_link( is_object_a = ls_lpor_a
is_object_b = ls_lpor_b
ip_reltype = is_link-reltype ).
CATCH cx_obl_parameter_error
cx_obl_internal_error
cx_obl_model_error.
RETURN.
ENDTRY.
ls_folder_id = VALUE #( objtp = is_link-instid_b+0(3)
objyr = is_link-instid_b+3(2)
objno = is_link-instid_b+5(12) ).
ls_object_id = VALUE #( objtp = is_link-instid_b+17(3)
objyr = is_link-instid_b+20(2)
objno = is_link-instid_b+22(12) ).
CALL FUNCTION 'SO_OBJECT_DELETE'
EXPORTING
folder_id = ls_folder_id
object_id = ls_object_id
EXCEPTIONS
communication_failure = 1
folder_not_empty = 2
folder_not_exist = 3
folder_no_authorization = 4
forwarder_not_exist = 5
object_not_exist = 6
object_no_authorization = 7
operation_no_authorization = 8
owner_not_exist = 9
substitute_not_active = 10
substitute_not_defined = 11
system_failure = 12
x_error = 13
OTHERS = 14.
IF sy-subrc = 0.
"Löschen erfolgreich. Commit ist noch erforderlich.
rv_deleted = abap_true.
ENDIF.