This is an example of how to fill several lines of data with ALV GRID and the Export to Excel cells. We can first define our text components as text symbols, but you can also use normal string variables.
001 This is line 1.
002 line 2.
003 third line.
004 last line.
CONSTANTS: l_con_dblct(1) TYPE c VALUE '"'. “ Anfang- und Endezeichen
data: l_cell_text type text255, “ Textfeld
l_con_sepa TYPE c VALUE cl_abap_char_utilities=>newline . “ Neue Zeile in Excel
Now we combine the components:
Text + new line separator + text + new line separator ………
Then the complete text string is provided with a start and end characters. This signals the Excel commands are mixed with text together in a chain.
Start character + Text with commands + end character
INTO l_cell_text SEPARATED BY l_con_sepa.
CONCATENATE l_con_dblct l_cell_text l_con_dblct INTO l_cell_text.
Field l_cell_text can now be issued with ALV in an Excel spreadsheet.
It is important to remember the field length of 255 points including new line characters and the beginning and end characters. If the last point is not occupied one end characters then all other data is output in only one Excel cell.
At various points, SAP has a technical limit of 255 characters set for text fields when in other programs, eg Excel to be exported.