cancel
Showing results for 
Search instead for 
Did you mean: 

upload Internal table data to application server in .xls

sachin_s_panchal
Explorer
0 Kudos
3,677

Hi ,

Can anyone please let me know if there is any FM to upload internal table data in .xls on application server.

I have tried Open dataset... close data set but it works perfectly for .csv, If I try .xls with the same file and when I download it from CG3Y to my PC (Just ot verify the excel sheet) fields are not separated its coming on one cell only.

I have also tried FM "MS_EXCEL_OLE_STANDARD_DAT" (Suggested on some threads) but it is for downloading excel file on my PC, not useful for application server.

Regards,

sachin

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member186338
Active Contributor

Sorry, but why do you think that your application server can read data from MS Excel file?

Please read again answers here: https://archive.sap.com/discussions/thread/1737852

P.S. And: https://github.com/ivanfemia/abap2xlsx

https://blogs.sap.com/2010/07/12/abap2xlsx-generate-your-professional-excel-spreadsheet-from-abap/

sachin_s_panchal
Explorer
0 Kudos

Hi Valdim,

Thanks for your response.

In my case User have the script that directly pick file from application server and download it. I just need to upload the .xls file in batch job. I don't want to opne that .xls file in application server. I tried to upload it from cg3y and download it by CG3Z tcode, It was working fine.

So I am looking for a FM which takes data from internal table and store it in application server in .xls format.

regards,

sachin

matt
Active Contributor

What does your internal table contain?

former_member186338
Active Contributor

If you have some numbers and strings in your internal table (not a binary excel file) then you will need to create excel file using abap. And abap2xlsx is a solution.

0 Kudos

Hi,

It's better if you can provide more detail about your current work e.g. abap code

By the way, as I see, your need is to write internal table to application server .xls file. You may seperate your data by horizontal tab (cl_abap_char_utilities=>horizontal_tab) then fields will be seperated into each column.

Best Regards,

Nam

DoanManhQuynh
Active Contributor
0 Kudos

convert your internal table to excel like this:

TRY.
 cl_salv_table=>factory(
 IMPORTING
 r_salv_table = DATA(lr_table)
 CHANGING
 t_table = lt_tab ). " your data in this table
 CATCH cx_salv_msg .
 EXIT.
ENDTRY.

TRY.
 lt_fcat = cl_salv_controller_metadata=>get_lvc_fieldcatalog(
 r_columns = lr_table->get_columns( )
 r_aggregations = lr_table->get_aggregations( ) ).

 lr_result = cl_salv_ex_util=>factory_result_data_table(
 r_data = REF #( lt_tab )
 t_fieldcatalog = lt_fcat ).

 cl_salv_bs_lex=>export_from_result_data_table(
 EXPORTING
 is_format = if_salv_bs_lex_format=>mc_format_xlsx " based on sap version
 ir_result_data_table = lr_result
 IMPORTING
 er_result_file = DATA(lr_xstring) ).
 CATCH cx_salv_unexpected_param_value .
 EXIT.
ENDTRY.

then convert the xstring to binary table:

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lr_xstring " this is the XSTRING of the file u want to upload
IMPORTING
output_length = lv_output_length
TABLES
binary_tab = lt_solix_tab.

after that use open data set to write that binary table to application server.

User10732
Newcomer
0 Kudos
Can you please share an code example to write the binary table to application server