Application Development 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: 

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

Former Member
0 Kudos

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

:

:

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

10 REPLIES 10

Former Member
0 Kudos

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

0 Kudos

As you can see I am already doing what you suggested:

APPEND v_string TO it_string.

But it does not work.I et the data in different columns but I want in different rows...

0 Kudos

Hi Rajesh,

ok use field separator as Tab in gui_download.

Ashven

0 Kudos

I need to use

CONSTANTS : c_tab TYPE c VALUE cl_abap_char_utilities=>NEWLINE.

Thanks for all the help, gurus...

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi,

Please check my reply..

Thanks,

Naren

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

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

Former Member
0 Kudos

use field separator as 'X' in GUI_DOWNLOAD.

sony