2022 Nov 02 12:52 PM
Hi, i have a excel upload code but i dont know how can i show alv grid excel file. Im new a sap sorry about that. Here is my code.
Regards.
FORM excel_upload.
DATA: lv_rc TYPE i,
it_files TYPE filetable,
lv_action TYPE i.
TRY.
cl_gui_frontend_services=>file_open_dialog( EXPORTING
file_filter = |xlsx (*.xlsx)\|*.xlsx\|{ cl_gui_frontend_services=>filetype_all }|
CHANGING
file_table = it_files
rc = lv_rc
user_action = lv_action ).
IF lv_action = cl_gui_frontend_services=>action_ok.
IF lines( it_files ) > 0.
DATA: lv_filesize TYPE w3param-cont_len,
lv_fieldtype TYPE w3param-cont_type,
it_bin_data TYPE w3mimetabtype.
cl_gui_frontend_services=>gui_upload( EXPORTING
filename = |{ it_files[ 1 ]-filename } |
filetype = 'BIN'
IMPORTING
filelength = lv_filesize
CHANGING
data_tab = it_bin_data ).
Data(lv_bin_data) = cl_bcs_convert=>solix_to_xstring( it_solix = it_bin_data ).
Data(o_excel) = New cl_fdt_xl_spreadsheet( document_name = CONV #( it_files[ 1 ]-filename )
xdocument = lv_bin_data ).
Data: it_worksheet_names type if_fdt_doc_spreadsheet=>t_worksheet_names.
o_excel->if_fdt_doc_spreadsheet~get_worksheet_names( IMPORTING worksheet_names = it_worksheet_names ).
if lines( it_worksheet_names ) > 0.
Data(o_worksheet_itab) = o_excel->if_fdt_doc_spreadsheet~get_itab_from_worksheet( it_worksheet_names[ 1 ] ).
ASSIGN o_worksheet_itab->* to FIELD-SYMBOL(<worksheet>).
cl_demo_output=>write_data( <worksheet> ).
Data(lv_html) = cl_demo_output=>get( ).
cl_abap_browser=>show_html( EXPORTING
title = 'Excel Worksheet'
html_string = lv_html
container = cl_gui_container=>default_screen ).
WRITE: space.
ENDIF.
ENDIF.
ENDIF.
CATCH cx_root INTO DATA(e_text).
MESSAGE e_text->get_text( ) TYPE 'S' DISPLAY LIKE 'E'.
ENDTRY.
ENDFORM.
Regards
2022 Nov 02 12:52 PM
Thank you for visiting SAP Community to get answers to your questions. Since you're asking a question here for the first time, I recommend that you familiarize yourself with: https://community.sap.com/resources/questions-and-answers, as it provides tips for preparing questions that draw responses from our members.
For example, you can:
- outline what steps you took to find answers (and why they weren't helpful)
- share screenshots of what you've seen/done
- make sure you've applied the appropriate tags
- use a more descriptive subject line
The more details you provide, the more likely it is that members will be able to respond. Feel free to also take our Q&A tutorial at: https://developers.sap.com/tutorials/community-qa.html
Should you wish, you can revise your question by selecting Actions, then Edit.
By adding a picture to your profile you encourage readers to respond: https://developers.sap.com/tutorials/community-profile.html
Questions on how to draw responses from members? Check out this discussion on how to improve questions. https://groups.community.sap.com/t5/welcome-corner-discussions/advice-from-sap-champions-questions-a...
2022 Nov 02 2:30 PM
2022 Nov 03 4:06 PM
Read this tutorial Create a Global ABAP Class (which use CL_SALV_TABLE in an OO development)