cancel
Showing results for 
Search instead for 
Did you mean: 

Opposite to concatinate

Former Member
0 Kudos

Can anybody help me? I want to do the opposite to "concatinate". I have numbers in an internal table and want to resave the numbers in a new internal table but without the two first positions.

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi Lin,

If you want to eliminate first two positions.

then you can use offset.

String+2(len) like this. it will consider from the

3rd position.

Thanks&Regards,

Siri.

andreas_mann3
Active Contributor
0 Kudos

Hi Linn,

pls post the structure of your internal tables

Andreas

Former Member
0 Kudos

Hi Linn,

opposite of concatenation is split.

But, in your case, you use offset and get the same number without first two positions.

Like for eg: if your number is 8 digits long.

Then, itab-number = itab-number+2(6).

Regards,

Raj

former_member181962
Active Contributor
0 Kudos

loop at itab1.

itab2-number = itab1-number+2(length>).

append itab2.

clear itab2.

endloop.

Former Member
0 Kudos

Hi,

Use SPLIT statement.

Regards,

Amey

Former Member
0 Kudos

use split statement..here is the sap documentation for it

Variant 1

SPLIT f AT g INTO h1 ... hn.

Effect

Splits f wherever the separator g occurs and places the resulting sections into the fields h1 ... hn (n >= 2). Note that if g has type C, the field is used in its defined and not its occupied length.

The field is split using the following procedure: f is split internally into a set of target fields k1 to kn with the same type as f. These are then transferred into the actual target fields h1 to hn using MOVE semantics.

The return code is set as follows:

SY-SUBRC = 0:

All of the fields hi (1 <= i <= n) were large enough.

SY-SUBRC = 4:

One of the fields hi was not large enough and significant characters were lost.

Examples

DATA: NAMES(30) TYPE C VALUE 'Charly, John , Peter',

NAMES2 TYPE STRING,

ONE(10) TYPE C,

TWO(10) TYPE C,

THREE TYPE STRING,

FOUR(4) TYPE C VALUE 'FOUR',

DELIMITER(2) VALUE ','.

SPLIT NAMES AT DELIMITER INTO ONE TWO.

  • ONE contains 'Charly' and TWO contains 'John , Pet'.

  • SY-SUBRC is 4, because TWO was not large enough to

  • accommodate the whole of the remaining string

SPLIT NAMES AT ',' INTO ONE TWO THREE.

  • ONE contains 'Charly', TWO contains ' John',

  • THREE contains ' Peter'.

SPLIT NAMES AT ', ' INTO ONE THREE TWO.

  • ONE contains 'Charly', THREE contains 'John',

  • TWO contains 'Peter'.

CONCATENATE NAMES '' INTO NAMES2 SEPARATED BY SPACE.

SPLIT NAMES2 AT DELIMITER INTO ONE TWO THREE FOUR.

  • ONE contains 'Charly', TWO contains 'John',

  • THREE contains 'Peter ', FOUR is empty.

SPLIT NAMES2 AT DELIMITER INTO ONE FOUR THREE.

  • ONE contains 'Charly', FOUR contains 'John',

  • THREE contains 'Peter', SY-SUBRC is 4, since

  • FOUR was not large enough (spaces are significant

  • characters!)

Notes

If the number of target fields is not greater than the number of separator strings in the source string, very little information can be lost. In this case, the last target field contains the "remainder", including the separator string (see first example).

If the source field does not contain the separator string, or if you specify an empty C string as the separator, the entire source field is placed in the first target field.

Any target fields that are not required are deleted.

If f begins with the separator string g, the first target field (h1) contains an initial value.

Variant 2

SPLIT f AT g INTO TABLE itab.

Effect

Similar to variant 1

The sections of f are placed in the internal table itab. The sytsem creates a table row for each section of f.

Note: If f ends with the separator string g, the system does not create an empty table row at the end. This is in contrast to what happens when g occurs at the beginning of f.

Example

TYPES: BEGIN OF ITAB_TYPE,

WORD(20),

END OF ITAB_TYPE.

DATA: ITAB TYPE STANDARD TABLE OF ITAB_TYPE WITH

NON-UNIQUE DEFAULT KEY INITIAL SIZE 5.

SPLIT 'STOP Two STOP Three STOP ' AT 'STOP' INTO TABLE ITAB.

ITAB now has three rows. The first is empty, the second contains ' Two', and the third ' Three'.

Note

Performance:

The runtime required for the SPLIT statement in the first example of variant 1 is approximately 15 msn (standard microseconds). If you write the sections of f into an internal table, the runtime is around 30 msn.

Message was edited by: Anid