cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with GOS with image as attachment from fiori

0 Kudos

dd.txtHello Experts,

I am sending image data in png;base64 string from my fiori app to OData which has create_stream method. I am trying to attach the image to BO BUS2088.

The file is available in IW32 but when i download it shows corrupted. Below is the ABAP code i am using.

SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S31 { font-style: italic; color: #808080; } .L0S32 { color: #3399FF; } .L0S33 { color: #4DA619; } .L0S52 { color: #0000FF; } .L0S55 { color: #800080; } .L0S70 { color: #808080; }

include : <cntn01> .
* Load class.
class cl_binary_relation definition load.
class cl_obl_object definition load.
data:
p_botype like obl_s_pbor-typeid value 'BUS2088',
p_bo_id like obl_s_pbor-instid value '000004002862',
p_docty like borident-objtype value 'MESSAGE' ,
p_reltyp like breltyp-reltype value 'ATTA' ,
p_msgtyp like sofm-doctp value 'EXT' .

types: begin of ty_message_key,
foltp type so_fol_tp,
folyr type so_fol_yr,
folno type so_fol_no,
doctp type so_doc_tp,
docyr type so_doc_yr,
docno type so_doc_no,
fortp type so_for_tp,
foryr type so_for_yr,
forno type so_for_no,
end of ty_message_key.
types : begin of ty_binary,
binary_field(255) type c,
end of ty_binary.
data : lt_binary type table of ty_binary with header line,
wa_binary type ty_binary.
data : lv_message_key type ty_message_key.
data : lo_message type swc_object.
data : lt_doc_content type standard table of soli-line with header line.
data: listobject like abaplist occurs 1 with header line.
data: lv_doc_size type i.
data: filesize type so_doc_len.
data: l_file_lines type i.
data help_objcont like soli occurs 0 with header line.
data file_type like rlgrap-filetype.
data act_filetype like rlgrap-filetype.
data act_filename like rlgrap-filename.
data h_filename like rlgrap-filename.
data doc_length like soxwd-doc_length.
data def_filename(12).
data object_hd_display like sood2.
p_docty = 'MESSAGE'.
p_msgtyp = 'EXT'.
swc_create_object lo_message 'MESSAGE' lv_message_key.
swc_container lt_message_container.
swc_set_element lt_message_container 'DOCUMENTTITLE' 'attach'.
swc_set_element lt_message_container 'DOCUMENTLANGU' 'E'.
swc_set_element lt_message_container 'NO_DIALOG' 'X'.
swc_set_element lt_message_container 'DOCUMENTNAME' p_docty.
swc_set_element lt_message_container 'DOCUMENTTYPE' p_msgtyp.
swc_set_element lt_message_container 'FILEEXTENSION' 'PNG'.

data : new1 type string.
data : filestring1 like filestring.
new1 = filestring.
call function 'SSFC_BASE64_DECODE'
exporting
b64data = new1
importing
bindata = filestring1
exceptions
others = 8.

call function 'SCMS_XSTRING_TO_BINARY'
exporting
buffer = filestring1
importing
output_length = lv_doc_size
tables
binary_tab = lt_binary
.
swc_set_table lt_message_container 'DocumentContent' lt_binary.
swc_set_element lt_message_container 'DOCUMENTSIZE' lv_doc_size.
swc_refresh_object lo_message.
swc_call_method lo_message 'CREATE' lt_message_container.
swc_get_object_key lo_message lv_message_key.

data: lo_is_object_a type borident.
lo_is_object_a-objkey = p_bo_id.
lo_is_object_a-objtype = p_botype.
* Create attachment BO object_b
data: lo_is_object_b type borident.
lo_is_object_b-objkey = lv_message_key.
lo_is_object_b-objtype = p_docty.

call function 'BINARY_RELATION_CREATE'
exporting
obj_rolea = lo_is_object_a
obj_roleb = lo_is_object_b
relationtype = p_reltyp
exceptions
others = 1.
commit work and wait.

Attached is the data received in gateway (dd.txt). Please help.

Accepted Solutions (0)

Answers (0)