Skip to Content
0

JPEG or word document to GOS from FIORI

Dec 12, 2017 at 08:10 PM

33

avatar image
Former Member

Hi All,

I have an issue attaching JPEG and word document to the GOS of a sales order from fiori. I am able to attach the PDF files and able to display them too.

I am able to download and display the JPEG images that are attached from GUI in VA02 but if i upload from fiori application i am able to attach it but if i download and display it say can display image in windows photo viewer.

*-----Folder Root
CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'
EXPORTING
* OWNER = ' '
region = 'B'
IMPORTING
folder_id = ls_fol_id
EXCEPTIONS
communication_failure = 1
owner_not_exist = 2
system_failure = 3
x_error = 4
OTHERS = 5.

CHECK sy-subrc = 0.

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = im_xstring
IMPORTING
output_length = lv_size
TABLES
binary_tab = lt_doc_content.

CALL FUNCTION 'SO_SOLIXTAB_TO_SOLITAB'
EXPORTING
ip_solixtab = lt_doc_content
IMPORTING
ep_solitab = lt_cont.

SPLIT im_fname AT '.' INTO lv_name lv_extension.
* TRANSLATE lv_extension TO UPPER CASE .

ls_obj_data-objsns = 'O'.
ls_obj_data-objla = sy-langu.
ls_obj_data-objdes = lv_name .
ls_obj_data-objlen = lv_size.
ls_obj_data-file_ext = lv_extension.

ls_obj_data-objlen = lv_size.
* ls_obj_data-objlen = xstrlen( im_xstring ).

CONCATENATE '&SO_FILENAME=' lv_name '.' lv_extension INTO ls_objhead-line.
APPEND ls_objhead TO lt_objhead.

ls_objhead-line = '&SO_FORMAT=BIN'.
APPEND ls_objhead TO lt_objhead.


CALL FUNCTION 'SO_OBJECT_INSERT'
EXPORTING
folder_id = ls_fol_id
object_type = 'EXT'
object_hd_change = ls_obj_data
IMPORTING
object_id = ls_obj_id
TABLES
objhead = lt_objhead
objcont = lt_cont
EXCEPTIONS
active_user_not_exist = 35
folder_not_exist = 6
object_type_not_exist = 17
owner_not_exist = 22
parameter_error = 23
OTHERS = 1000.

IF sy-subrc EQ 0 .

* attach document as GOS attacment to realted bussiness object
ls_object-objkey = im_vbeln.
ls_object-objtype = 'BUS2096'.

ls_folmem_k-foltp = ls_fol_id-objtp.
ls_folmem_k-folyr = ls_fol_id-objyr.
ls_folmem_k-folno = ls_fol_id-objno.
ls_folmem_k-doctp = ls_obj_id-objtp.
ls_folmem_k-docyr = ls_obj_id-objyr.
ls_folmem_k-docno = ls_obj_id-objno.

lv_ep_note = ls_folmem_k.
ls_note-objtype = 'MESSAGE'.
ls_note-objkey = lv_ep_note.

CALL FUNCTION 'BINARY_RELATION_CREATE_COMMIT'
EXPORTING
obj_rolea = ls_object
obj_roleb = ls_note
relationtype = 'ATTA'
EXCEPTIONS
OTHERS = 1.
IF sy-subrc = 0.

ls_message-type = 'S'.
ls_message-message = text-001.
APPEND ls_message TO t_message.
CLEAR ls_message.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = c_x.

COMMIT WORK.

ENDIF.
ENDIF.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers