‎2014 Mar 12 9:01 AM
I've used the FM SO_ATTACHMENT_READ_API1 to retrieve a EXCEL data attachment.It returns the binary format. I want to process that data in internal table. I am able to download that binary data to Excel file using "cl_gui_frontend_services=>gui_download".I don't know how to process. Please help me.
‎2014 Mar 12 9:17 AM
‎2014 Mar 12 9:35 AM
my internal table look like this....
types: begin of ty_output,
matnr type marc-matnr,
werks type marc-werks,
QZGTP type marc-QZGTP,
description(10) type c,
end of ty_output.
data: it_output type standard table of ty_output.
my Excel attachment look like this..
-------------------------------------------------------------
MATNR | plant | Certificate | Description |
--------------------------------------------------------------
12345 | 1000 | ABC | testing 1 |
-------------------------------------------------------------
67890| 1000 | CDE | testing 2 |
----------------------------------------------------------
I am using this FM to read the attachment. and i am getting the data into "it_contents" in binary format.
call function 'SO_ATTACHMENT_READ_API1'
exporting
attachment_id = it_attachment-attach_id
tables
contents_hex = it_contents
exceptions
attachment_not_exist = 1
operation_no_authorization = 2
parameter_error = 3
x_error = 4
enqueue_error = 5
others = 6.
now i want to store the data to the internal table "it_output".
i am able to download the data to local excel file using following FM.
but unable to store the data into internal table it_output.
input_length = it_attachment-att_size.
call method cl_gui_frontend_services=>gui_download
exporting
bin_filesize = input_length
filename = 'D:\TMP\TEST.XLSX'
filetype = 'BIN'
changing
data_tab = it_contents
exceptions
file_write_error = 1
no_batch = 2.
any quick response appreciated.
‎2014 Mar 12 9:54 AM
Hi
Can you check the contents in the tables parameters of FM 'SO_ATTACHMENT_READ_API1'
ATTACHMENT_HEADER
ATTACHMENT_CONTENT <<< ofthis one
CONTENTS_HEX
Regards
Sree
‎2014 Mar 12 9:55 AM
Well what you want to achieve is importing an excel file from the attachments, parsing it and working with it in your code. That is really not something that can be done easily. You want to convert your binary data to a abap-like interpretation.
Have a look at the abap2xls project and search more for the words "read excel in abap".
‎2014 Mar 12 10:15 AM
hi Sreevisakh,
I have checked these Table parameters, but i couldn't get any thing.
the table ATTACHMENT_HEADER contains only below information.
&SO_FORMAT=BIN
&SO_FILENAME=material_details.xlsx
and
ATTACHMENT_CONTENT contains something unreadable format.
CONTENTS_HEX contains binary format.
‎2014 Mar 12 10:21 AM
yeah exactly Jozef, but I don't know about abap2xls project because i am new to ABAP.please provide me some information on this so that I can get the solution..
‎2014 Mar 12 10:26 AM
please, search SCN, you will find many examples how to import excel to abap. Once you need it to operate only in foreground, you can use OLE interface. Only if background is needed, abap2xls could be useful.
‎2014 Mar 12 11:02 AM
Have you checked the sy-subrc value?
if sy-subrc is initial then.
ATTACHEMENT_HEADER should have header
ATTACHMENT_CONTENT should have content
endif.
‎2014 Mar 12 11:54 AM
hii,
ATTACHEMENT_HEADER and ATTACHMENT_CONTENT has the content. the problem here is that content in ATTACHMENT_CONTENT and CONTENTS_HEX tables are in binary format. and i want to read that content in CONTENTS_HEX table to my internal table IT_OUTPUT.
‎2014 Mar 12 9:43 AM
Hi ram,
‎2014 Mar 12 9:54 AM
hi Manoj,
Thank you for quick response,but here my requirement is to read the table "it_contents" and store the data into internal table "it_output" without downloading to local file.
‎2020 Apr 15 2:44 PM