on 05-18-2009 12:43 PM
Hi,
I need to upload and attach a file (Word, PDF, TXT ...) to Service Notificacion (TX - IW53) through Web Dynpro.
I have used the integration component "File Upload" to obtain the "fileName" atribute. Also, I have used the functions SO_OBJECT_UPLOAD, SO_INSERT_OBJECT and BINARY_RELATION_CREATE_COMMIT.
But have a problem, because the function SO_OBJECT_UPLOAD use the class "cl _ gui _ frontend _ services" and that clash with Web Dynpro.
My question is: how could I resolve that problem?
I look forward to your response.
Thanks
Hi,
It took our developer a really long time to figure out how we would to do it and finally found this method. It's working successfully in our dev test systems. See if it'll be useful to you.
data ls_lporb type sibflporb.
ls_lporb-instid = lv_zmre_nr.
ls_lporb-typeid = 'BUS2088'.
data lv_objtyp type so_obj_tp.
lv_objtyp = 'EXT'.
data lt_return_attach type bapirettab.
call method cl_fitv_gos=>save
exporting
iv_name = lv_file_name
iv_content =
iv_content_hex = lv_content
is_lporb = ls_lporb
iv_objtp = lv_objtyp
receiving
rt_messages = lt_return_attach
.
Good luck,
Huntr
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
IV_NAME Importing Type STRING
IV_CONTENT Importing Type STRING
IV_CONTENT_HEX Importing Type XSTRING
IS_LPORB Importing Type SIBFLPORB
IV_OBJTP Importing Type SO_OBJ_TP
RT_MESSAGES Returning Type BAPIRETTAB
method save.
data ls_message type bapiret2.
data:
filename type string,
filefullname type string,
mime_type type string,
size type i,
offset type i,
offset_old type i,
temp_len type i,
objname type string,
l_obj_type type so_obj_tp,
hex_null type x length 1 value '20',
l_document_title type so_text255,
file_ext type string,
lt_objcont type standard table of solisti1 initial size 6,
objcont like line of lt_objcont,
lt_ls_doc_change type standard table of sodocchgi1,
ls_doc_change like line of lt_ls_doc_change,
lt_data type soli_tab,
ls_data type soli,
lt_xdata type solix_tab,
ls_xdata type solix,
l_folder_id type sofdk,
ls_object_id type soodk,
l_object_id_fol type so_obj_id,
l_object_id type so_obj_id,
l_doc_info TYPE sofolenti1,
l_object_hd_change type sood1,
l_tab_size type int4,
l_retype type breltyp-reltype,
lt_urltab type standard table of sood-objdes.
get foler
l_folder_id = 'FOL29000000000004'.
call function 'SO_FOLDER_ROOT_ID_GET'
exporting
owner = sy-uname
region = 'B'
importing
folder_id = l_folder_id
tables
path_table =
.
if iv_objtp = gc_type_file.
size = xstrlen( iv_content_hex ).
get file name and extension
call method split_path
exporting
iv_path = iv_name
importing
E_PATH =
ev_filename = filename
E_PSERVER =
.
call method split_file_extension
exporting
iv_filename_with_ext = filename
importing
ev_filename = objname
ev_extension = file_ext.
ls_doc_change-obj_name = objname.
ls_doc_change-obj_descr = objname.
ls_doc_change-obj_langu = sy-langu.
ls_doc_change-sensitivty = 'F'.
ls_doc_change-doc_size = size.
offset = 0.
while offset <= size.
offset_old = offset.
offset = offset + 255.
if offset > size.
temp_len = xstrlen( iv_content_hex+offset_old ).
clear ls_xdata-line with hex_null in byte mode.
ls_xdata-line = iv_content_hex+offset_old(temp_len).
else.
ls_xdata-line = iv_content_hex+offset_old(255).
endif.
append ls_xdata to lt_xdata.
endwhile.
set object type relation type and other header info
l_retype = 'ATTA'.
l_obj_type = 'EXT'.
l_object_hd_change-objnam = ls_doc_change-obj_name.
l_object_hd_change-objdes = ls_doc_change-obj_descr.
l_object_hd_change-objsns = ls_doc_change-sensitivty.
l_object_hd_change-objla = ls_doc_change-obj_langu.
l_object_hd_change-objlen = ls_doc_change-doc_size.
l_object_hd_change-file_ext = file_ext.
*
prepare header
data lt_obj_header type standard table of solisti1.
data ls_header type solisti1.
concatenate '&SO_FILENAME=' filename into ls_header.
append ls_header to lt_obj_header.
clear ls_header.
ls_header = '&SO_FORMAT=BIN'.
append ls_header to lt_obj_header.
change hex data to text data
call function 'SO_SOLIXTAB_TO_SOLITAB'
exporting
ip_solixtab = lt_xdata
importing
ep_solitab = lt_data.
else.
for note
size = strlen( iv_content ).
objname = iv_name.
ls_doc_change-obj_descr = objname.
ls_doc_change-sensitivty = 'O'.
ls_doc_change-obj_langu = sy-langu.
put content into table
offset = 0.
if iv_objtp = gc_type_note.
it's a note
l_retype = 'NOTE'.
l_obj_type = 'RAW'.
l_object_hd_change-file_ext = 'TXT'.
read note content into table
while offset <= size.
offset_old = offset.
offset = offset + 255.
if offset > size.
temp_len = strlen( iv_content+offset_old ).
clear ls_data-line.
ls_data-line = iv_content+offset_old(temp_len).
else.
ls_data-line = iv_content+offset_old(255).
endif.
append ls_data to lt_data.
endwhile.
get title from content , if it's initial
if objname is initial.
read table lt_data index 1 into l_document_title.
while l_document_title+49 <> ' '.
shift l_document_title right.
endwhile.
shift l_document_title left deleting leading ' '.
ls_doc_change-obj_descr = l_document_title.
endif.
else.
it's url (not note)
l_retype = 'URL'.
l_obj_type = 'URL'.
if objname is initial.
split iv_content at '/' into table lt_urltab.
describe table lt_urltab lines l_tab_size.
read table lt_urltab index l_tab_size into ls_doc_change-obj_descr.
endif.
while offset <= size.
offset_old = offset.
offset = offset + 250.
if offset > size.
temp_len = strlen( iv_content+offset_old ).
clear ls_data-line.
ls_data-line = iv_content+offset_old(temp_len).
else.
ls_data-line = iv_content+offset_old(250).
endif.
concatenate '&KEY&' ls_data-line into ls_data-line.
append ls_data to lt_data.
endwhile.
endif.
ls_doc_change-doc_size = size.
l_object_hd_change-objnam = ls_doc_change-obj_name.
l_object_hd_change-objdes = ls_doc_change-obj_descr.
l_object_hd_change-objsns = ls_doc_change-sensitivty.
l_object_hd_change-objla = ls_doc_change-obj_langu.
l_object_hd_change-objlen = ls_doc_change-doc_size.
endif.
save object
call function 'SO_OBJECT_INSERT'
exporting
folder_id = l_folder_id
OBJECT_FL_CHANGE = OBJECT_FL_CHANGE
object_hd_change = l_object_hd_change
object_type = l_obj_type
ORIGINATOR_ID = OWNER_ID
OWNER = USER-USRNAM
importing
OBJECT_FL_DISPLAY = OBJECT_FL_DISPLAY
OBJECT_HD_DISPLAY = OBJECT_HD_DISPLAY
object_id = ls_object_id "l_doc_info-object_id
tables
objcont = lt_data
objhead = lt_obj_header
OBJPARA = OBJECT_PARA
OBJPARB = OBJECT_PARB
exceptions
component_not_available = 01
folder_not_exist = 06
folder_no_authorization = 05
object_type_not_exist = 17
operation_no_authorization = 21
parameter_error = 23
others = 1000.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 into ls_message-message.
ls_message-type = sy-msgty.
ls_message-id = sy-msgid.
ls_message-number = sy-msgno.
ls_message-message_v1 = sy-msgv1.
ls_message-message_v2 = sy-msgv2.
ls_message-message_v3 = sy-msgv3.
ls_message-message_v4 = sy-msgv4.
append ls_message to rt_messages.
return.
endif.
create relation
data l_obj_rolea type borident.
data l_obj_roleb type borident.
MOVE-CORRESPONDING wd_this->ms_lporb to l_obj_rolea.
l_obj_rolea-objkey = is_lporb-instid.
l_obj_rolea-objtype = is_lporb-typeid.
l_obj_rolea-logsys = is_lporb-catid.
l_object_id_fol = l_folder_id.
l_object_id = ls_object_id.
concatenate l_object_id_fol l_object_id into l_obj_roleb-objkey respecting blanks.
l_obj_roleb-objtype = 'MESSAGE'.
clear l_obj_roleb-logsys.
call function 'BINARY_RELATION_CREATE'
exporting
obj_rolea = l_obj_rolea
obj_roleb = l_obj_roleb
relationtype = l_retype
exceptions
others = 1.
if sy-subrc = 0.
commit work and wait.
wd_this->MV_UPDATE_FLAG = 'X'.
else.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 into ls_message-message.
ls_message-type = sy-msgty.
ls_message-id = sy-msgid.
ls_message-number = sy-msgno.
ls_message-message_v1 = sy-msgv1.
ls_message-message_v2 = sy-msgv2.
ls_message-message_v3 = sy-msgv3.
ls_message-message_v4 = sy-msgv4.
append ls_message to rt_messages.
return.
endif.
endmethod.
Edited by: Reyleene Hunt on May 26, 2009 10:05 AM
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.