Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Function Module Require

Former Member
0 Likes
676

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

5 REPLIES 5
Read only

Former Member
0 Likes
650

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.

Read only

0 Likes
650

Hello,

use the split at into command. Find the syntax below

SPLIT f AT g INTO TABLE itab.

here g= '#' for you

Regards

Farzan

Read only

Former Member
0 Likes
650

use the function module

STRING_SPLIT

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Feb 22, 2008 3:59 PM

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
650

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.


Read only

Former Member
0 Likes
650

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