‎2007 Jul 17 7:07 AM
hi friends - any idea how to download a XL-sheet to a report output.
i have one xl-sheet. i have to display it in the report output.
Plz help me.
Thanks
Praveen
‎2007 Jul 17 7:10 AM
Hello,
Try this and reward if found helpfull.
Regards,
Rakesh.
DATA: it_t001 TYPE t001 OCCURS 0,
it_fields TYPE dfies OCCURS 0 WITH HEADER LINE,
BEGIN OF it_fnames OCCURS 0,
reptext LIKE dfies-reptext,
END OF it_fnames.
* The structure definition required for this internal table.
* The following definition is not working:
* it_fnames like dfies-reptext occurs 0 with header line.
* because Function Module will use the following:
* ASSIGN COMPONENT 1 OF STRUCTURE FIELDNAMES TO <F>.
SELECT * FROM t001 INTO TABLE it_t001.
CALL FUNCTION 'GET_FIELDTAB'
EXPORTING
* LANGU = SY-LANGU
* ONLY = ' '
tabname = 'T001'
* WITHTEXT = 'X'
* IMPORTING
* HEADER =
* RC =
TABLES
fieldtab = it_fields
EXCEPTIONS
internal_error = 1
no_texts_found = 2
table_has_no_fields = 3
table_not_activ = 4
OTHERS = 5
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
LOOP AT it_fields.
it_fnames-reptext = it_fields-reptext.
APPEND it_fnames.
ENDLOOP.
*CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'
*EXPORTING
*FILE_NAME = 'D:Oletrial'
** CREATE_PIVOT = 0
*DATA_SHEET_NAME = 'Companies'
** PIVOT_SHEET_NAME = ' '
** PASSWORD = 'NISHA'
** PASSWORD_OPTION = 0
*TABLES
** PIVOT_FIELD_TAB =
*DATA_TAB = it_t001
*FIELDNAMES = it_fnames
*EXCEPTIONS
*FILE_NOT_EXIST = 1
*FILENAME_EXPECTED = 2
*COMMUNICATION_ERROR = 3
*OLE_OBJECT_METHOD_ERROR = 4
*OLE_OBJECT_PROPERTY_ERROR = 5
*INVALID_FILENAME = 6
*INVALID_PIVOT_FIELDS = 7
*DOWNLOAD_PROBLEM = 8
*OTHERS = 9
*.
*IF SY-SUBRC <> 0.
*MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.
*
BREAK-POINT.
CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
EXPORTING
file_name = 'D:New Foldernisha'
* CREATE_PIVOT = 0
data_sheet_name = 'Companies 2'
* PIVOT_SHEET_NAME = 'd:nisha'
password = 'NISHA'
password_option = 1
TABLES
* PIVOT_FIELD_TAB =
data_tab = it_t001
*FIELDNAMES = it_fnames
EXCEPTIONS
file_not_exist = 1
filename_expected = 2
communication_error = 3
ole_object_method_error = 4
ole_object_property_error = 5
invalid_filename = 6
invalid_pivot_fields = 7
download_problem = 8
OTHERS = 9
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
‎2007 Jul 17 7:10 AM
Hello,
Try this and reward if found helpfull.
Regards,
Rakesh.
DATA: it_t001 TYPE t001 OCCURS 0,
it_fields TYPE dfies OCCURS 0 WITH HEADER LINE,
BEGIN OF it_fnames OCCURS 0,
reptext LIKE dfies-reptext,
END OF it_fnames.
* The structure definition required for this internal table.
* The following definition is not working:
* it_fnames like dfies-reptext occurs 0 with header line.
* because Function Module will use the following:
* ASSIGN COMPONENT 1 OF STRUCTURE FIELDNAMES TO <F>.
SELECT * FROM t001 INTO TABLE it_t001.
CALL FUNCTION 'GET_FIELDTAB'
EXPORTING
* LANGU = SY-LANGU
* ONLY = ' '
tabname = 'T001'
* WITHTEXT = 'X'
* IMPORTING
* HEADER =
* RC =
TABLES
fieldtab = it_fields
EXCEPTIONS
internal_error = 1
no_texts_found = 2
table_has_no_fields = 3
table_not_activ = 4
OTHERS = 5
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
LOOP AT it_fields.
it_fnames-reptext = it_fields-reptext.
APPEND it_fnames.
ENDLOOP.
*CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'
*EXPORTING
*FILE_NAME = 'D:Oletrial'
** CREATE_PIVOT = 0
*DATA_SHEET_NAME = 'Companies'
** PIVOT_SHEET_NAME = ' '
** PASSWORD = 'NISHA'
** PASSWORD_OPTION = 0
*TABLES
** PIVOT_FIELD_TAB =
*DATA_TAB = it_t001
*FIELDNAMES = it_fnames
*EXCEPTIONS
*FILE_NOT_EXIST = 1
*FILENAME_EXPECTED = 2
*COMMUNICATION_ERROR = 3
*OLE_OBJECT_METHOD_ERROR = 4
*OLE_OBJECT_PROPERTY_ERROR = 5
*INVALID_FILENAME = 6
*INVALID_PIVOT_FIELDS = 7
*DOWNLOAD_PROBLEM = 8
*OTHERS = 9
*.
*IF SY-SUBRC <> 0.
*MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.
*
BREAK-POINT.
CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
EXPORTING
file_name = 'D:New Foldernisha'
* CREATE_PIVOT = 0
data_sheet_name = 'Companies 2'
* PIVOT_SHEET_NAME = 'd:nisha'
password = 'NISHA'
password_option = 1
TABLES
* PIVOT_FIELD_TAB =
data_tab = it_t001
*FIELDNAMES = it_fnames
EXCEPTIONS
file_not_exist = 1
filename_expected = 2
communication_error = 3
ole_object_method_error = 4
ole_object_property_error = 5
invalid_filename = 6
invalid_pivot_fields = 7
download_problem = 8
OTHERS = 9
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
‎2007 Jul 17 7:11 AM
Hi,
You can use the Function Module TEXT_CONVERT_XLS_TO_SAP
and read the contents of the Excel sheet into the internal table
Then display the internal table using write statements.
Regards,
Samson Rodrigues.
‎2007 Jul 17 7:11 AM
REPORT zupload_excel_to_itab.
TYPE-POOLS: truxs.
PARAMETERS: p_file TYPE rlgrap-filename.
TYPES: BEGIN OF t_datatab,
col1(30) TYPE c,
col2(30) TYPE c,
col3(30) TYPE c,
END OF t_datatab.
DATA: it_datatab type standard table of t_datatab,
wa_datatab type t_datatab.
DATA: it_raw TYPE truxs_t_text_data.
At selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
***********************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_FIELD_SEPERATOR =
i_line_header = 'X'
i_tab_raw_data = it_raw " WORK TABLE
i_filename = p_file
TABLES
i_tab_converted_data = it_datatab[] "ACTUAL DATA
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
***********************************************************************
END-OF-SELECTION.
END-OF-SELECTION.
LOOP AT it_datatab INTO wa_datatab.
WRITE:/ wa_datatab-col1,
wa_datatab-col2,
wa_datatab-col3.
ENDLOOP.
‎2007 Jul 17 7:12 AM
Hi ,
Using the FM "ALSM_EXCEL_TO_INTERNAL_TABLE" you can upload the Excel into your program, and then you can use it for Report display.
Hope this solves your purpose.
Award points if it helps.
-Gaurang
‎2007 Jul 17 8:53 AM
hi friends,
thanks for your time and help.
I have used the FM ALSM_EXCEL_TO_INTERNAL_TABLE and have done the required changes.