cancel
Showing results for 
Search instead for 
Did you mean: 

ALV grid output issue to excel

Former Member
0 Kudos

Hi Experts

I have an ALV report which I want to Download to Excel( I am using excel 2003).

When I veiw the report it apperars ok. Their are around 90 columns in the Report

But when I export the alv I found that some columns are on the next line. Is there any way to resolve this issue

I want to export in excel without creating new rows of columns .

Thanks

Vikrant

Accepted Solutions (1)

Accepted Solutions (1)

mauro_bianchi
Active Contributor
0 Kudos

Hi Vikrant,

This is really a technical limitation of Abap list export to local file.

ALV Grid > 1023 characters per line will be split into 2 lines.

To prevent a line break occurring when you download the list as a local spreadsheet file, you must reduce the width of the list in the ALV.

You can do this either by hiding columns, or by changing the column widths in the ALV. Please see details in note below:

855314 - Downloading a list from the ALV to Excel

Regards,

Mauro

Former Member
0 Kudos

Deleted

Edited by: Gaurav.B on Sep 20, 2011 9:04 AM

Answers (2)

Answers (2)

jaheer_hussain
Active Contributor
0 Kudos

Hi,

please tell your abaper to move 90 fields to intenal table & have a look below code.

Here my internal table is i_downfinal.

DATA: FULLPATH TYPE STRING,

FILENAME TYPE STRING,

PATH TYPE STRING,

USER_ACTION TYPE I.

  • encoding TYPE ABAP_ENCODING.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG

EXPORTING

WINDOW_TITLE = 'File Download'

DEFAULT_FILE_NAME = 'C:\TEMP\zpmcs.xls'

WITH_ENCODING = 'X'

CHANGING

FILENAME = FILENAME

PATH = PATH

FULLPATH = FULLPATH

USER_ACTION = USER_ACTION

  • FILE_ENCODING = encoding

EXCEPTIONS

CNTL_ERROR = 1

ERROR_NO_GUI = 2

NOT_SUPPORTED_BY_GUI = 3

OTHERS = 4.

IF SY-SUBRC <> 0.

EXIT.

ENDIF.

IF USER_ACTION <> CL_GUI_FRONTEND_SERVICES=>ACTION_OK.

EXIT.

ENDIF.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = FULLPATH

FILETYPE = 'DAT'

TABLES

DATA_TAB = I_DOWNFINAL

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.

JL23
Active Contributor
0 Kudos

Can you explain what transaction you have problems with and how you download (each step) and open Excel.

Have you tried to display the ALV as Excel inplace directly in SAP?

Former Member
0 Kudos

Hi Jürgen

This is a Z report which we have created. This report is created using table and field values from MARA,MARC,MARD,MDMA,MLGN

This Z report when we execute shows the correct no of columns and rows and all the columns appear in the same row.

When we download the data of this report in an excel sheet , using -List--export to spreatsheet or local file the data in the excel sheet shows the columns appearing in 2 rows.( for eg their were 90 columns initially and and now in the excel download 60 columns are in the first row and 30 columns are in the 2nd row)

The Function module"REUSE_ALV_GRID_DISPLAY" is being used in the Z report.

Thanks

VIkrant

JL23
Active Contributor
0 Kudos

I think it is better to post this question in the ABAP forum.