2006 Aug 31 10:56 PM
Hi,
I have a long text like (0001001352, 0001001683, 0001001457, 0001236530, ............... continues). I dont how long will be the string length either it may contain 1 or more than one numbers.
So my requirement is to split at each comma and store in a range.
If I use split then I don't know how many local fields I need to be declare to hold those split values.
I want to know is their any function module or class, which splits the string at comma and stores in internal table? So that I can store those into my range table.
Regards,
Kumar
2006 Aug 31 11:02 PM
try this...
do.
split wf_text at ',' into wf_first wf_rest.
if wf_rest is initial.
append wf_first to tb_table.
exit.
endif.
append wf_first to tb_table.
wf_text = wf_rest.
enddo.
Message was edited by: Abhishek Jolly
Message was edited by: Abhishek Jolly
2006 Aug 31 11:41 PM
Hi,
check this..
data: itab type table of string with header line.
data: lv_string type string.
SPLIT LV_STRING AT ',' into table itab.
Thanks,
Naren
Thanks,
Naren
2006 Sep 01 3:08 AM
Hi Kumar,
The sample code is follows.
DATA: str TYPE string VALUE 'A,B,C,D,E,F,G,H,I,J,K,L',
itab TYPE string OCCURS 0 WITH HEADER LINE.
SPLIT str AT ',' INTO TABLE itab.
LOOP AT itab.
WRITE:/ itab.
ENDLOOP.
Nothing to worry about the length of string or number of words.
Regards,
Prasanth
2006 Sep 01 3:22 AM
Hi Kumar,
check this code
REPORT ZRICH_0001.
DATA : BEGIN OF IT_RANGE OCCURS 0,
SIGN(1),
OPTION(2),
LOW TYPE STRING,
HIGH TYPE STRING,
END OF IT_RANGE.
DATA : BEGIN OF ITAB OCCURS 0,
VAR(5000),
END OF ITAB.
DATA : V_STR TYPE STRING VALUE '0000123,123456,345677'.
CLEAR ITAB.
REFRESH ITAB.
SPLIT V_STR AT ',' INTO TABLE ITAB.
CLEAR ITAB.
REFRESH IT_RANGE.
LOOP AT ITAB.
IT_RANGE-SIGN = 'I'.
IT_RANGE-OPTION = 'BT'.
IT_RANGE-LOW = ITAB-VAR.
IT_RANGE-HIGH = ''.
APPEND IT_RANGE.
CLEAR IT_RANGE.
ENDLOOP.
LOOP AT IT_RANGE.
WRITE : / IT_RANGE-LOW.
ENDLOOP.