2012 Jun 07 12:42 PM
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
2012 Jun 07 2:07 PM
Hi Joy,
as Shambu tried to explain.
Whenever you see a # 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
2012 Jun 07 1: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,
2012 Jun 07 3:34 PM
Hi
Use REPLACE or TRANSALATE - Command to translate the ## into # in the text.
Then process that text line
Regards,
Venkat
2012 Jun 07 1: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.
2012 Jun 07 1: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
2012 Jun 07 1: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
2012 Jun 07 2:07 PM
Hi Joy,
as Shambu tried to explain.
Whenever you see a # 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
2012 Jun 07 3: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
2012 Jun 07 3: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