‎2008 Feb 22 8:26 AM
Hi Friends,
i need to split a string which contains # in between, into its corresponding internal table.
the structure of the internal table will be given dynamically...
Is tr any function module to split the string and put it into the dynamically provided itab.
or Is tr any way to read the data's from Application server which contains Tab de-limited file into its corresponding itab.(Dynamically provided itab)
<REMOVED BY MODERATOR>
Regards,
SASI...
Edited by: Alvaro Tejada Galindo on Feb 22, 2008 3:58 PM
‎2008 Feb 22 8:30 AM
make use of SPLIT statement ... i.e,
DATA: NAMES2(30) VALUE 'Charly# John# Peter',
THREE(10) VALUE 'New York',
FOUR(10),
FIVE(10),
SIX(10) VALUE 'SAP'.
SPLIT NAMES2 AT '#' INTO THREE FOUR FIVE SIX.
IF THREE = 'Charly' AND
FOUR = ' John' AND
FIVE = ' Peter' AND
SIX = SPACE.
WRITE 'SPLIT is OK'.
ENDIF.
‎2008 Feb 22 8:30 AM
Hello,
use the split at into command. Find the syntax below
SPLIT f AT g INTO TABLE itab.
here g= '#' for you
Regards
Farzan
‎2008 Feb 22 8:30 AM
use the function module
STRING_SPLIT
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Feb 22, 2008 3:59 PM
‎2008 Feb 22 8:40 AM
data:wk_str(11) value 'dfn#bsd#fcc'.
data:begin of it,
f1(3) type c,
f2(3) type c,
f3(3) type c,
end of it.
data:itab like standard table of it with header line.
split wk_str at '#' into it-f1 it-f2 it-f3..
append it to itab.
‎2008 Feb 22 9:23 AM
hi
good
Splitting Character Strings
To split a character string into two or more smaller strings, use the SPLIT statement as follows:
SPLIT <c> AT <del> INTO <c1> ... <cn>.
The system searches the field <c> for the separator <del>. The parts before and after the separator are placed in the target fields <c1> ... <cn>.
To place all fragments in different target fields, you must specify enough target fields. Otherwise, the last target field is filled with the rest of the field <c> and still contains delimiters.
If all target fields are long enough and no fragment has to be truncated, SY-SUBRC is set to 0. Otherwise it is set to 4.
DATA: STRING(60),
P1(20) VALUE '++++++++++++++++++++',
P2(20) VALUE '++++++++++++++++++++',
P3(20) VALUE '++++++++++++++++++++',
P4(20) VALUE '++++++++++++++++++++',
DEL(3) VALUE '***'.
STRING = ' Part 1 *** Part 2 *** Part 3 *** Part 4 *** Part 5'.
WRITE STRING.
SPLIT STRING AT DEL INTO P1 P2 P3 P4.
WRITE / P1.
WRITE / P2.
WRITE / P3.
WRITE / P4.
The output appears as follows:
Part 1 *** Part 2 *** Part 3 *** Part 4 *** Part 5
Part 1
Part 2
Part 3
Part 4 *** Part 5
Note that the contents of the fields P1 ...P4 are totally overwritten and that they are filled out with trailing blanks.
You can also split a string into the individual lines of an internal table as follows:
SPLIT <c> AT <del> INTO TABLE <itab>.
The system adds a new line to the internal table <itab> for each part of the string.
<REMOVED BY MODERATOR>
thanks
mrutyun^
Edited by: Alvaro Tejada Galindo on Feb 22, 2008 3:59 PM