Skip to Content
author's profile photo Former Member
Former Member

download to excel

Hi experts,

I am downloading the internal table values to excel sheet using the

FM 'WS_DOWNLOAD'.

The issue is after downloading in the excel sheet I am getting the value field like below

PRICE

151.00

200.00

235

67

89.00

In internal table all the Price values has two decimal places, after downloading

some of the price is showing with decimal places some of them not

Can anybody show me why this is happening and hoe to slove

Thanks in advance

karthik

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Posted on Dec 04, 2007 at 09:37 AM

    Hi,

    Try FM

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    • BIN_FILESIZE =

    filename = p_path

    filetype = 'ASC'

    • APPEND = ' '

    write_field_separator = 'X'

    • HEADER = '00'

    • TRUNC_TRAILING_BLANKS = ' '

    • WRITE_LF = 'X'

    • COL_SELECT = ' '

    • COL_SELECT_MASK = ' '

    • DAT_MODE = ' '

    • CONFIRM_OVERWRITE = ' '

    • NO_AUTH_CHECK = ' '

    • CODEPAGE = ' '

    • IGNORE_CERR = ABAP_TRUE

    • REPLACEMENT = '#'

    • WRITE_BOM = ' '

    • TRUNC_TRAILING_BLANKS_EOL = 'X'

    • WK1_N_FORMAT = ' '

    • WK1_N_SIZE = ' '

    • WK1_T_FORMAT = ' '

    • WK1_T_SIZE = ' '

    • IMPORTING

    • FILELENGTH =

    TABLES

    data_tab = it_final

    • FIELDNAMES =

    • EXCEPTIONS

    • FILE_WRITE_ERROR = 1

    • NO_BATCH = 2

    • GUI_REFUSE_FILETRANSFER = 3

    • INVALID_TYPE = 4

    • NO_AUTHORITY = 5

    • UNKNOWN_ERROR = 6

    • HEADER_NOT_ALLOWED = 7

    • SEPARATOR_NOT_ALLOWED = 8

    • FILESIZE_NOT_ALLOWED = 9

    • HEADER_TOO_LONG = 10

    • DP_ERROR_CREATE = 11

    • DP_ERROR_SEND = 12

    • DP_ERROR_WRITE = 13

    • UNKNOWN_DP_ERROR = 14

    • ACCESS_DENIED = 15

    • DP_OUT_OF_MEMORY = 16

    • DISK_FULL = 17

    • DP_TIMEOUT = 18

    • FILE_NOT_FOUND = 19

    • DATAPROVIDER_EXCEPTION = 20

    • CONTROL_FLUSH_ERROR = 21

    • OTHERS = 22

    .

    IF sy-subrc <> 0.

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

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

    ENDIF.

    Regards,

    Prashant

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 09:41 AM

    Hi Karthik,

    For these problems use FM 'GUI_DOWNLOAD'.Below is simple code for it.You will easily understand.

    Plz do reward if useful.

    Thankx.

    report zhdownload.

    data : begin of itab occurs 100,

    f_matnr type matnr,

    f_ersda type ersda,

    f_ernam type ernam,

    end of itab.

    select matnr ersda ernam into table itab from mara up to 10 rows.

    append itab.

    data : begin of itab1 occurs 0,

    line(50) type c,

    end of itab1.

    itab1-line = 'MATERIAL NUMBER'.

    append itab1.

    itab1-line = 'DATE'.

    append itab1.

    itab1-line = 'NAME'.

    append itab1.

    call function 'GUI_DOWNLOAD'

    exporting

    filename = 'C:\Documents and Settings\ak0020758\abc2.xls'

    filetype = 'ASC'

    write_field_separator = 'X'

    • IMPORTING

    • FILELENGTH =

    tables

    data_tab = itab

    fieldnames = itab1 " for headings

    exceptions

    file_write_error = 1

    no_batch = 2

    gui_refuse_filetransfer = 3

    invalid_type = 4

    no_authority = 5

    unknown_error = 6

    header_not_allowed = 7

    separator_not_allowed = 8

    filesize_not_allowed = 9

    header_too_long = 10

    dp_error_create = 11

    dp_error_send = 12

    dp_error_write = 13

    unknown_dp_error = 14

    access_denied = 15

    dp_out_of_memory = 16

    disk_full = 17

    dp_timeout = 18

    file_not_found = 19

    dataprovider_exception = 20

    control_flush_error = 21

    others = 22

    .

    if sy-subrc <> 0.

    message id sy-msgid type sy-msgty number sy-msgno

    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    endif.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 04, 2007 at 09:42 AM

    hi karthik,

    You can use gui_download for this one.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 09:51 AM

    u can use either of the 2 FMs below

    GUI_DOWNLOAD

    TEXT_CONVERT_XLS_TO_SAP

    Hope dis will clear ur doubt..

    Reward all helpful answers

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 09:51 AM

    Hi Karthik,

    what ever FM you use either WS_DOWNLOAD or GUI_DOWNLOAD

    Usually If you download any data from SAP to excel file with decimal values.. if there are any numeric after decimal then only it’ll display in excel sheet .

    For example if value is 100.01 then display like 100.01

    If value is 100.00 then it display like 100.

    To overcome this problem after (or before ) download use formatting techniques in excel like

    Select cell column in excel sheet> right click> format cells --> select category as ‘ Number’ and decimal places 2.

    After this you can see 100 as 100.00

    I hope this will solve your problem.

    Message was edited by:

    Perez C

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 09:52 AM

    Hi

    You can very well use the following fun modules for downloading data to EXCEL

    GUI_DOWNLOAD

    EXCEL_OLE_STANDARD_DAT

    MS_EXCEL_OLE_STANDARD_DAT

    Check this code:

    PARAMETERS : P_FILE TYPE RLGRAP-FILENAME.

    DATA: V_FILE TYPE P_FILE.

    data: begin OF itab occurs 0,

    matnr like mara-matnr,

    end of itab.

    data : begin of it_fieldnames occurs 0,

    name(100),

    end of it_fieldnames.

    START-OF-SELECTION.

    it_fieldnames-name = 'MATNR'.

    APPEND IT_FIELDNAMES.

    MOVE P_FILE TO V_FILE.

    select matnr from mara into table itab UP TO 10 ROWS.

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    • BIN_FILESIZE =

    FILENAME = V_FILE

    FILETYPE = 'ASC'

    • APPEND = ' '

    • WRITE_FIELD_SEPARATOR = ' '

    • HEADER = '00'

    • TRUNC_TRAILING_BLANKS = ' '

    • WRITE_LF = 'X'

    • COL_SELECT = ' '

    • COL_SELECT_MASK = ' '

    • DAT_MODE = ' '

    • CONFIRM_OVERWRITE = ' '

    • NO_AUTH_CHECK = ' '

    • CODEPAGE = ' '

    • IGNORE_CERR = ABAP_TRUE

    • REPLACEMENT = '#'

    • WRITE_BOM = ' '

    • TRUNC_TRAILING_BLANKS_EOL = 'X'

    • WK1_N_FORMAT = ' '

    • WK1_N_SIZE = ' '

    • WK1_T_FORMAT = ' '

    • WK1_T_SIZE = ' '

    • IMPORTING

    • FILELENGTH =

    TABLES

    DATA_TAB = itab

    FIELDNAMES = IT_FIELDNAMES .

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.