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

concatenating strings

Hi all,

I am getting text from read_text . I am concatenating all lines of text into another variable declared as LINE type string . ALL LINES are concatenating in one line. is there any other way to concatenating the lines into multiple lines of same cell. Is it possible or not?

pls check the given code.

loop at tlinetab into wa_tlinetab2.

if sy-tabix = 1.

move wa_tlinetab2-tdline to line2.

else.

concatenate line2 wa_tlinetab2-tdline into line2 separated by space.

endif.

endloop.

st_stxh-text2 = line2.

Add comment
10|10000 characters needed characters exceeded

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Sep 28, 2007 at 12:37 PM

    hi

    good

    go through this code and use accordingly,

    data:

    l_text1(10) type c value 'first',

    l_text2(10) type c value 'next',

    l_out(20) type c.

    concatenate l_text1 l_text2 into l_out.

    write:/ l_out. " ---> Output: firstnext

    concatenate l_text1 l_text2 into l_out separated by space.

    write:/ l_out. "---> Output: first next

    move: l_text1 to l_out.

    l_out+15 = l_text2.

    write:/ l_out. "----> Output: first next

    thanks

    mrutyun^

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 28, 2007 at 12:46 PM

    Ekta,

    I didnt understand the phrase 'multiple lines of same cell'. can you elborate ur requirement. According to my understanding, you want to use a single variable to store multiple lines seperated, as in a table, which is impossible. Because a variable stores the data in a continuous sequence. ( Variable i mean here is a STRING)

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 28, 2007 at 12:54 PM

    Hi

    see the sample code and do accordingly

    REPORT ZTEST.

    tables:stxh.

    parameters p_vbeln type vbeln.

    data:begin of it_stxh occurs 0,

    tdobject type tdobject,

    tdname type tdobname,

    tdid type tdid,

    tdspras type spras,

    end of it_stxh.

    types:begin of ty_lines.

    include structure tline.

    types:end of ty_lines.

    data:it_lines type standard table of ty_lines with header line.

    start-of-selection.

    select tdobject

    tdname

    tdid

    tdspras

    from stxh

    into table it_stxh where tdobject = 'VBBK' and

    tdname = p_vbeln and

    tdid = 'Z102' AND

    tdspras = sy-langu.

    if not sy-subrc ne 0.

    leave to list-processing.

    endif.

    data: str type string.

    read table it_stxh index 1.

    CALL FUNCTION 'READ_TEXT'

    EXPORTING

    • CLIENT = SY-MANDT

    ID = it_stxh-tdid

    LANGUAGE = it_stxh-tdspras

    NAME = it_stxh-tdname

    OBJECT = it_stxh-tdobject

    • ARCHIVE_HANDLE = 0

    • LOCAL_CAT = ' '

    • IMPORTING

    • HEADER =

    TABLES

    LINES = it_lines

    • EXCEPTIONS

    • ID = 1

    • LANGUAGE = 2

    • NAME = 3

    • NOT_FOUND = 4

    • OBJECT = 5

    • REFERENCE_CHECK = 6

    • WRONG_ACCESS_TO_ARCHIVE = 7

    • OTHERS = 8

    .

    IF SY-SUBRC eq 0.

    loop at it_lines.

    concatenate str it_lines-tdline into str separated by '"'.

    endloop.

    ENDIF.

    Regards

    Anji

    Add comment
    10|10000 characters needed characters exceeded