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

Want to get data in multiple rows and not in one row of excel..

Hi,

I am trying to write data in a file using separated by ',' keyword, so that the data when written in Excel file using GUI_DOwnload, will separate the fields. But the problem is all the data is separated by comma in just one row of excel file.

LOOP AT it_itab.

IF sy-tabix = 1.

v_string = it_itab-name.

ELSE.

CONCATENATE v_string it_itab-name INTO v_string separated by ','.

ENDIF.

ENDLOOP.

APPEND v_string TO it_string.

ENDIF.

IF v_string IS NOT INITIAL.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = 'C:\temp.xls'

TABLES

data_tab = it_string

EXCEPTIONS

file_write_error = 1

no_batch = 2.

But I want to get each data on each separate row.

For example now I am getting ,

row1: Data1, data2, data3... in one row of Excel

But I need in the form:

row1: Data1

row2: Data2

row3: Data3

:

:

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2007 at 10:20 PM

    Hi,

    Instead of using comma as a separator, declare a varaiable as shown below and use it. It will download data in multiple columns in an excel.

    CONSTANTS : c_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.

    Reward points if the answer is helpful.

    Regards,

    Mukul

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2007 at 10:07 PM

    Hi Rajesh,

    Declare an internal table then append the data from v_string to internal table & after that pass the internal table to GUI_download using tab as field searator. It will work.

    Ashven

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2007 at 10:14 PM

    Hi,

    Instead of

    LOOP AT it_itab.

    IF sy-tabix = 1.

    v_string = it_itab-name.

    ELSE.

    CONCATENATE v_string it_itab-name INTO v_string separated by ','.

    ENDIF.

    ENDLOOP.

    APPEND v_string TO it_string.

    ENDIF.

    use

    LOOP AT it_itab.

    IF sy-tabix = 1.

    v_string = it_itab-name.

    ELSE.

    CONCATENATE v_string it_itab-name INTO v_string separated by ','.

    ENDIF.

    APPEND v_string TO it_string.

    ENDLOOP.

    Regards,

    Vara

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2007 at 10:25 PM

    Hi,

    In GUI_DOWNLOAD pass the parameter WRITE_FIELD_SEPARATOR 'X'...Then in the excel you see it in different columns..

    • DOWNLOAD THE DATA.

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    filename = 'C:\TEST.XLS'

    <b>WRITE_FIELD_SEPARATOR = 'X'</b>

    tables

    data_tab = ITAB

    THanks,

    Naren

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2007 at 10:28 PM

    Hi,

    Please check my reply..

    Thanks,

    Naren

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 29, 2007 at 10:29 PM

    With the supplied code, all you need is to make the file extension .csv instead of .xls, if you want the file to be comma delimited.

    
    data: it_string type table of string.
    data: v_string type string.
    
    LOOP AT it_itab.
    IF sy-tabix = 1.
    v_string = it_itab-name.
    ELSE.
    CONCATENATE v_string it_itab-name INTO v_string separated by ','.
    ENDIF.
    ENDLOOP.
    APPEND v_string TO it_string.
    ENDIF.
    
    IF it_string IS NOT INITIAL.     "<- Change here
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    filename = 'C:temp.csv'       "<- Change here
    TABLES
    data_tab = it_string
    EXCEPTIONS
    file_write_error = 1
    no_batch = 2.
    
    
    

    Regards,

    RIch Heilman

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2007 at 10:35 PM

    use field separator as 'X' in GUI_DOWNLOAD.

    sony

    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.