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

Carriage return in an excell cell

Hi,

we have to transfer data from a sap internal table to an excel file. We have to do a return carriage into a cell, but we can´t do it (all that we get is to jump to another line).

Anyone knows how to do it?

Thanks in advance!

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

8 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 22, 2008 at 02:36 PM

    Apparently the hex code is 0A. But the cell info needs to be quoted ("") if you want excel to respect the carriage return

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 22, 2008 at 09:10 AM

    Hi Marc,

    Use Function Module GUI_DOWNLOAD as follows.

    Hope this solves your problem.

    Report Z101754_TEST.

    tables zvbak_101754.

    DATA: BEGIN OF itab OCCURS 0. "Segments for IDOC

    INCLUDE STRUCTURE zvbak_101754.

    DATA: END OF itab.

    select * from zvbak_101754 into CORRESPONDING FIELDS OF TABLE itab.

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    filename = 'd:\test.xls'

    FILETYPE = 'ASC'

    WRITE_FIELD_SEPARATOR = 'X'

    tables

    data_tab = itab

    .

    IF sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    Regards,

    Amit.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 22, 2008 at 09:20 AM

    Hi Carles,

    Kindly try using the ABAP type X (hexadecimal)

    with value 10.

    I am assuming you are using OLE2OBJECT, so your code might be like this

    DATA: l_data type char128,
          l_crlf TYPE X.
    
    
    " this hex 10 is Carriage Return-Line Feed
    l_crlf = 10.
    
    CONCATENATE 'First Line'
                l_crlf
    	    'Second Line'
             INTO l_data.
    
    CALL METHOD OF excel 'CELLS' = cell EXPORTING #1 = COLUMN #2 = ROW.
    
    SET PROPERTY OF cell 'VALUE' =   l_data.

    Have a nice try

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 22, 2008 at 09:03 AM

    Hi,

    we tried to use and x type field, and inform it with the ascii code 13...

    It makes jump into another line of the excel and writes the information, ok, but all that we want, is to jump into the next line, but into the same cell...

    Any ideas?

    Thanks!

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 22, 2008 at 02:27 PM

    Hi,

    We are using the c.f.GUI_DOWNLOAD for this...

    Uwe, if we use as you said (cl_abap_char_utilities=>newline), we get a jump into the other line A1 -> A2...

    We tried the

    "cl_abap_char_utilities=>cr_lf" too, but as the same result.

    Thanks for your help!

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 22, 2008 at 02:56 PM

    Hi,

    recently, we have updated to a 6.0 version...

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 22, 2008 at 03:03 PM

    Ok, hehe, finally, it works!!!

    The "" was the solution

    CONCATENATE

    '"'

    'aa'

    cl_abap_char_utilities=>newline

    'bb'

    '"'

    INTO var.

    Thank you very much for your help!!!

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 06:30 PM

    Hi Jean Claude,

    I wrote this code in an standard abap program,

    CONCATENATE

    '"'

    'aa'

    cl_abap_char_utilities=>newline

    'bb'

    '"'

    INTO var.

    and it worked ok. The text

    aa

    bb

    was moved into my excel in two lines...

    Ah, better open another Question into the forum, because this one was answered... or better consider to put in the "Form Printing" discussion forum (ABAP GENERAL).

    Hope this help!

    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.