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

proble in spliting

Hello All ,

I have problem with spiting i want to split the below message into table and i have tried

with the following command without success

Hello Dan,##My mobile doesn't work#Please assist ##Best regards #joy

SPLIT ls_create_message-text AT '#' INTO TABLE lt_text.

I want that the first line in lt_text will be hello dan

that to emty lines since i have two ##

etc

what i miss here since i getting all the sentence in lt_text ?

Best regards,

Joy


Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • Best Answer
    Posted on Jun 07, 2012 at 01:07 PM

    Hi Joy,

    as Shambu tried to explain.

    Whenever you see a # hash character in ABAP, very probably this is no # put just a character which can not be displayed or printed, mostly a control, character like tab, linefeed and others.

    In debugger, you can switch to hey mode and see the hex representation of the character.

    Class CL_ABAP_CHAR_UTILITIES has the attributes

    BACKSPACE

    BYTE_ORDER_MARK_BIG Unicode - Big Endian

    BYTE_ORDER_MARK_LITTLE Unicode - Little Endian

    BYTE_ORDER_MARK_UTF8

    CHARSIZE

    CR_LF

    ENDIAN

    FORM_FEED

    HORIZONTAL_TAB

    MAXCHAR

    MINCHAR

    NEWLINE

    VERTICAL_TAB

    So first try to split at CL_ABAP_CHAR_UTILITIES=>NEWLINE or CL_ABAP_CHAR_UTILITIES=>CR_LF to get the lines of the message, then if needed split at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB to get tab-delimited elements.

    What I see from your line "Hello Dan,##My mobile doesn't work#Please assist ##Best regards #joy", I assume

    SPLIT ls_create_message-text AT CL_ABAP_CHAR_UTILITIES=>NEWLINE INTO TABLE lt_text.

    will do it.

    Regards

    Clemens

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 07, 2012 at 12:22 PM

    By # if you mean TAB, the split using CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.

    Data: htab TYPE c VALUE cl_abap_char_utilities=>HORIZONTAL_TAB.

    SPLIT ls_create_message-text AT htab INTO TABLE lt_text.

    Thanks,

    Shambu

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 07, 2012 at 02:23 PM

    Hi Joy,

    *-- Declarations

    DATA : convt TYPE REF TO cl_abap_conv_in_ce,

    DATA : t_data TYPE STANDARD TABLE OF string,
    lv_string TYPE string.

    *--Split srting into internal table

    lv_string = 'Hello Dan##My mobile doesnt work#Please assist ##Best regards#Joy'.


    SPLIT lv_string AT cl_abap_char_utilities=>HORIZONTAL_TAB INTO TABLE t_data.

    This may help you . 😊

    Thanks & Regards,

    Suresh M

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 07, 2012 at 12:14 PM

    Hi Joy,

    Please check the below code its going to work:

    DATA:LV_STRING TYPE STRING,
    LT_STRING TYPE TABLE OF STRING.

    LV_STRING = 'Hello Dan,##My mobile doesnt work.#Please assist. ##Best regards, #Joy'.

    SPLIT LV_STRING AT '#' INTO TABLE LT_STRING.

    LOOP AT LT_STRING INTO LV_STRING.
    IF LV_STRING IS INITIAL.
    SKIP.
    ENDIF.
    WRITE:/ LV_STRING.
    ENDLOOP.

    With regards,

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 07, 2012 at 12:21 PM

    Hello,

    Why don't you try to add a space between ## ?

    ie : Hello Dan,# #My mobile doesn't work#Please assist # #Best regards #joy

    Regards.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 07, 2012 at 12:32 PM

    Hi Joy,

    Try This..

    DATA : STR(50) TYPE C VALUE 'R#P#S'.

    data : chr(1) type c value '#'.

    split STR at chr into table name.

    Pass '#' symble to a veriable and then pass that veriable into SPLIT statement.

    You will get the desired output.

    Regards,

    Ravi Singh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 07, 2012 at 02:38 PM

    Hi Joy

    I've tried Suresh's code above to no avail, but by doing the following:

    SPLIT lv_string AT '#' INTO TABLE t_data.

    Then the results are as follows:

    (

    Hello Dan

    My mobile doesnt work

    Please assist

    Best regards

    Joy

    )

    I'm guessing this is your required result...
    Maybe just check the Type of your lt_text declaration, is it a "type standard table of string"?

    Regards

    Vic

    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.