
DATA:ls_bo TYPE sibflporb,
ls_prop TYPE LINE OF sdokproptys,
lt_prop TYPE sdokproptys,
lt_properties_attr TYPE crmt_attr_name_value_t,
ls_file_info TYPE sdokfilaci,
lt_file_info TYPE sdokfilacis,
lt_file_content TYPE sdokcntbins,
lv_length TYPE i,
lv_file_xstring TYPE xstring,
ls_loio TYPE skwf_io,
ls_phio TYPE skwf_io,
ls_error TYPE skwf_error.
ls_prop-name = 'DESCRIPTION'.
ls_prop-value = 'created by Tool'. " replace it with your own description for attachment
APPEND ls_prop TO lt_prop.
ls_prop-name = 'KW_RELATIVE_URL'.
ls_prop-value = iv_file_name. " in the sample code I just reuse file name as relative url
APPEND ls_prop TO lt_prop.
ls_prop-name = 'LANGUAGE'.
ls_prop-value = sy-langu.
APPEND ls_prop TO lt_prop.
lv_file_xstring = iv_data.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lv_file_xstring
IMPORTING
output_length = lv_length
TABLES
binary_tab = lt_file_content.
ls_file_info-binary_flg = 'X'.
ls_file_info-file_name = iv_file_name.
ls_file_info-file_size = lv_length.
ls_file_info-mimetype = 'image/jpeg'. "use the correct mime type for your attachment
APPEND ls_file_info TO lt_file_info.
ls_bo-INSTID = iv_guid.
ls_bo-typeid = iv_bor_type.
ls_bo-catid = 'BO'.
CALL METHOD cl_crm_documents=>create_with_table
EXPORTING
business_object = ls_bo
properties = lt_prop
properties_attr = lt_properties_attr
file_access_info = lt_file_info
file_content_binary = lt_file_content
raw_mode = 'X'
IMPORTING
loio = ls_loio
phio = ls_phio
error = ls_error. " evaluate if there is anything wrong during creation
COMMIT WORK.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |