Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

internal table to excel

Former Member
0 Likes
806

Hi,

See the below code and can any one pls tell me what is that i writing wrong here. What i want to do is If the check box is checked, i want to download the data to excel sheet.

also tell me if there are any other parameters to be filled in the function module.


DATA: v_file type string.

DATA : BEGIN OF it_excelhead OCCURS 0,
         colname(40),
        END OF it_excelhead.

PARAMETER:  p_check AS CHECKBOX DEFAULT ' ',
            p_file LIKE rlgrap-filename DEFAULT 'c:'.



  IF p_check = 'X'.
    PERFORM prepare_excel_header.
    MOVE p_file TO v_file.

    CONCATENATE p_file '.xls' INTO v_file.

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    filename                        = v_file
   FILETYPE                        = 'ASC'
  tables
    data_tab                        = i_final1
    FIELDNAMES                      = it_excelhead.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endif.


7 REPLIES 7
Read only

Former Member
0 Likes
784

Hi,

Please change <b>the 'ASC' to 'BIN'.</b>Hope This Info Helps YOU.

<i>Reward Points If It Helps YOU.</i>

Regards,

Raghav

IF p_check = 'X'.

PERFORM prepare_excel_header.

MOVE p_file TO v_file.

CONCATENATE p_file '.xls' INTO v_file.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = v_file

FILETYPE = 'BIN'

tables

data_tab = i_final1

FIELDNAMES = it_excelhead.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

endif.

Read only

0 Likes
784

Why don't you use fm XXL_SIMPLE_API?

Fo XL files this is the best

Read only

Former Member
0 Likes
784

Hi Hema,

you have build a flat file,

try to put a txt extension and open it with a txt editor.

for creating an excel file there is a fm.

As soon as i put it there,

bye

enzo

Read only

Former Member
0 Likes
784

Hi ,

Please use below FM to download data

CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'

EXPORTING

FILE_NAME = LV_FILE1

DATA_SHEET_NAME = 'SUMMARY'

TABLES

DATA_TAB = IT_EXCEL_SUMMARY

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.

ENDIF.

ENDIF.

Reward points If information is helpful

Regards

Amole

Read only

0 Likes
784

HI.

try this FM.

MS_EXCEL_OLE_STANDARD_DAT .

In this FM, the header can also be given separately.

Thanks,

Maheshwari.V

Read only

Former Member
0 Likes
784

Hi i dont think using gui_download is a good option for handling Excel file.

Try this one out: <b>SAP_CONVERT_TO_XLS_FORMAT</b>

Read only

Former Member
0 Likes
784

Hi Hema,

Pass the exporting parameter WRITE_FIELD_SEPARATOR as 'X' for GUI_DOWNLOAD and it should work...

Regards,

Srikanth