2008 Mar 06 3:12 AM
Hi,
I have an ALV grid that contains multiple columns. One of the column is storing a long text that may have more than 255 chars. When i download the file, the long text will be truncated to 255 chars.
Can anyone advise if there is a way to download all the columns including the long text column that having width > 255 chars without being truncated?
Thanks,
Edited by: daphne daphne on Mar 6, 2008 4:14 AM
2008 Mar 06 3:29 AM
Are you downloading to Excel?
Within some Excel versions, while you can enter more than 255 characters in a cell, the contents get truncated at 255 when you copy the cells using cut/paste.
So it may be that the issue is not with the SAP ALV end.
You could try formatting the text in the ALV column so that it is chopped into smaller segments in multiple columns or multiple rows as another option.
Andrew
2008 Mar 06 3:32 AM
Hai.
check this .
Re: upload longtext from excel file
REPORT zupload_excel_to_itab.
TYPE-POOLS: truxs.
PARAMETERS: p_file TYPE rlgrap-filename.
TYPES: BEGIN OF t_datatab,
col1(30) TYPE c,
col2(30) TYPE c,
col3(30) TYPE c,
END OF t_datatab.
DATA: it_datatab type standard table of t_datatab,
wa_datatab type t_datatab.
DATA: it_raw TYPE truxs_t_text_data.
At selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
***********************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_FIELD_SEPERATOR =
i_line_header = 'X'
i_tab_raw_data = it_raw " WORK TABLE
i_filename = p_file
TABLES
i_tab_converted_data = it_datatab[] "ACTUAL DATA
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
***********************************************************************
END-OF-SELECTION.
END-OF-SELECTION.
LOOP AT it_datatab INTO wa_datatab.
WRITE:/ wa_datatab-col1,
wa_datatab-col2,
wa_datatab-col3.
ENDLOOP.
http://www.sapdevelopment.co.uk/file/file_upexcel.htm
regards.
sowjanya.b
2008 Mar 06 6:12 AM
Hi Andrew,
Thanks for your suggestion. Yes, I am downloading it to excel.
Quite a number of my long text columns are having chars more than 1000. If i chop off the string to 4 columns of 255 chars, it would hit 1020 chars for the long text alone. While I still have quite a number of other columns in the ALV.
Do you know if is any constraint on the total number of chars per line to download to excel? If the constraint is 1023 chars per line, then i would not be able to download the content for the rest of my columns. See OSS note 457735, it mentioned that the max column width is 1023. I am not sure if it's referring to 1 column width or the line width.
If there is no constrains on the line width, your suggestion sounds workable for me.
Thanks for your help.
Regards,
Daphne
2008 Mar 06 6:16 AM
Hi sowjanya.b,
Thanks for your message.
The sample above is to upload excel to sap. I am looking for a solution to download the ALV that having column width more than 255 chars.
Regards,
2008 Mar 06 12:38 PM
I think the 1023 character limit is a limit on the width of line that can be displayed in ALV. It is possible in the REUSE_ALV version to wrap a line and have up to 3 lines display per entry in the internal data table - this is done by setting a "row" or "line" value on the fields in the field catalog. Not sure if this can be done with the grid - I believe the field catalog is fairly similar. Of course, this might result in the download to excel being formatted a bit strangely.
It may be possible to download the report as plain text or tab delimited using the ALV savee to file option also - then load it into excel and use the excel reformat options to read the text file. This is a bit messy and probably involves more manual steps.
It may also be possible to reduce the length of the text for the download step by placing place-holders in the main ALV report eg TEXT0001, TEXT0002, etc, and then having a second report that downloads the text place holders and the corresponding long text using multiple lines per text entry. This would then need a macro in excel or a lookup function to merge it back in to the main spreadsheet.
None of these are very pretty options to build or use - depends on the requirement and skill level of your end users.
You could also take a look at the code in the XXL function modules - I think this is what is used behind the scenes by at least one type of ALV download (although it may now be a class based solution). This may show if the 255 limit can be changed / exceeded.
hope this is of some help.
Andrew
2008 Mar 07 2:20 AM
Hi Andrew,
I tried the download as plain text using file option, it will still truncated the column that having chars > 255, same as downloading to excel.
On the suggestion to download the text to another report and merge it using excel, i do not think that the user would accept this solution, as it's a bit too troublesome for them. They wanted a quick way to download and view the data.
I would like to try out your suggestion on wrapping a line to 3 lines per entry in ALV grid. Can you elaborate further how to accomplish this? I tried to look for the field catalogue attribute but couldn't find any thing resembles row or lines.
I am using function module ''REUSE_ALV_GRID_DISPLAY' to display the ALV grid.
Thanks for your help.
Regards,
Daphne
2008 Mar 07 3:43 AM
Hi,
In the ALV Field Catalog there is a ROW_POS field (first field in the field catalog structure). The value in this field defaults as 0 but can be changed to different values. The field is not documented for function REUSE_ALV_GRID_DISPLAY, but in the documentation for REUSE_ALV_LIST_DISPLAY is listed and allowed values given as 0,1,2,3.
Changing the value for a couple of fields in DEBUG to test gives the following error:
-
Multiple lines are only supported for printing and in print view
Message no. 0K063
Diagnosis
You have selected a display variant in which the columns span several rows.
System Response
This display format is only supported for printing or in print preview mode. In the current display, the fields of the subsequent rows are appended.
-
So it looks like the function you are using does not support the multiple lines option.
You might like to check notes 1065001 and 1080608 about setting the format used for download - don't know if changing this will have any effect on the 255 character limit.
Andrew
2008 Mar 07 6:18 AM
Hi Andrew,
I have tried to changed my function module to 'REUSE_ALV_LIST_DISPLAY' to try out the row_pos. I am to see the column text more than 255 chars now. It's showed as the next line in the record.
However, I would need to display the data in ALV grid. Perhaps, one way is to advise user to switch to list mode before download to excel.
Thanks for your help again.
Regards,
2009 Jul 24 5:00 AM
Hi Dhapne,
There is a work arround for this. I have an ALV Report with 4 colunms of 4000 Characters each one and the user wants to see the whole text in a excel spreadsheet. What I did: Create the ALV Grid as usual with the 4 colunms of type 4000 Char. After execute the ALV Report, I chose the option Export -> XML. I have to give a name to the xml file and save it locally in my hard disk. The last step of the process is just open the file by double-clicking ( is going to open with Excel by default ) and done!, I got 4 colunns with up to 4000 Char each one.
The limitiation here came just from the data element that you use, so I reckon that using type string instead of Char 4000 give us not limitation of text lenght, and as well from Excel ( I don't know is there is any limitation in Excel for the number of characters in one cell ), but I have downloaded text of up to 2000 Chararcters without any problem, just a bit slow than the usual option.
Best Regards,
Luis Lara