Code: Alles auswählen.
FUNCTION Z_ANLAGE_HINZUFUEGEN5.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(I_OBJECTTYPE) LIKE BORIDENT-OBJTYPE
*" VALUE(I_OBJECTKEY) LIKE BORIDENT-OBJKEY
*" VALUE(I_URL) LIKE SOLI-LINE
*" VALUE(I_URLDES) LIKE SOOD1-OBJDES
*" VALUE(I_NOCOMMIT) TYPE XFELD OPTIONAL
*" TABLES
*" OT_RETURN STRUCTURE BAPIRET2
*"----------------------------------------------------------------------
data: l_owner like soud-usrnam,
l_folderid like soodk,
l_obj_id like soodk,
l_objdata like sood1,
lt_objcont type table of soli with header line,
lt_objhead type table of soli with header line,
l_object like borident,
l_reldoc like borident,
l_syst like syst.
*-----------------------------------------------------------------------
*1. Get folder id.
l_owner = sy-uname.
call function 'SO_FOLDER_ROOT_ID_GET'
exporting
owner = l_owner
region = 'B'
importing
folder_id = l_folderid
exceptions
communication_failure = 1
owner_not_exist = 2
system_failure = 3
x_error = 4
others = 5.
if sy-subrc <> 0.
l_syst = syst.
perform collect_message2 using ot_return l_syst '1.FolderRoot'.
append ot_return.
exit.
endif.
*2. Insert object
l_objdata-objla = 'EN'.
l_objdata-objdes = i_urldes.
l_objdata-objsns = 'O'.
concatenate '&KEY&' i_url into lt_objcont.
append lt_objcont.
Data ld_document_data type SODOCCHGI1.
ld_document_data-OBJ_DESCR = 'Test'.
"ld_document_data-DOC_SIZE = 100.
"ld_document_data-OBJ_Name = null.
Data: ld_document_info type SOFOLENTI1.
call function 'SO_DOCUMENT_INSERT_API1'
EXPORTING
folder_id = l_folderid
document_data = ld_document_data
document_type = 'URL'
IMPORTING
document_info = ld_document_info
" TABLES
"contents_hex = it_contents_hex
EXCEPTIONS
FOLDER_NOT_EXIST = 1
DOCUMENT_TYPE_NOT_EXIST = 2
OPERATION_NO_AUTHORIZATION = 3
PARAMETER_ERROR = 4
X_ERROR = 5
ENQUEUE_ERROR = 6
.
if sy-subrc <> 0.
l_syst = syst.
perform collect_message2 using ot_return l_syst '2.ObjectInsert'.
append ot_return.
exit.
endif.
*3. Create binary relation
l_object-objkey = i_objectkey.
l_object-objtype = i_objecttype.
concatenate l_folderid ld_document_info into l_reldoc-objkey.
l_reldoc-objtype = 'MESSAGE'.
call function 'BINARY_RELATION_CREATE'
exporting
obj_rolea = l_object
obj_roleb = l_reldoc
relationtype = 'ATTA'
exceptions
no_model = 1
internal_error = 2
unknown = 3
others = 4.
if sy-subrc <> 0.
l_syst = syst.
perform collect_message2 using ot_return l_syst
'3.BinaryRelationCreate'.
append ot_return.
exit.
endif.
*4. Commit LUW
* All successful, sent success message.
clear: l_syst-msgid, l_syst-msgno.
l_syst-msgty = 'S'.
l_syst-msgv1 = 'Link created successfully'.
perform collect_message2 using ot_return l_syst '4. URLLinkCreated'.
append ot_return.
if i_nocommit is initial.
call function 'BAPI_TRANSACTION_COMMIT'.
endif.
ENDFUNCTION.
FORM collect_message2 using o_return like bapiret2
i_syst like syst
i_callpoint like bapiret2-parameter.
clear o_return.
o_return-type = i_syst-msgty.
if i_syst-msgty is initial.
o_return-type = 'E'.
i_syst-msgty = 'E'.
endif.
o_return-id = i_syst-msgid.
o_return-number = i_syst-msgno.
o_return-message_v1 = i_syst-msgv1.
o_return-message_v2 = i_syst-msgv2.
o_return-message_v3 = i_syst-msgv3.
o_return-message_v4 = i_syst-msgv4.
o_return-parameter = i_callpoint.
message id i_syst-msgid type i_syst-msgty number i_syst-msgno into
o_return-message.
endform.
CALL FUNCTION 'SO_DOCUMENT_INSERT_API1'
EXPORTING
folder_id = gs_folder
document_data = gs_doc_data
document_type = s_doc_data-obj_type
IMPORTING
document_info = gs_doc_info
TABLES
object_content = t_content_txt
contents_hex = t_content_hex.