Skip to Content
author's profile photo Former Member
Former Member

Opposite to concatinate

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.

Add a comment
10|10000 characters needed characters exceeded

Related questions

6 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Nov 29, 2005 at 09:45 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 29, 2005 at 09:45 AM

    Hi,

    Use SPLIT statement.

    Regards,

    Amey

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 29, 2005 at 09:46 AM

    loop at itab1.

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

    append itab2.

    clear itab2.

    endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 29, 2005 at 09:46 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 29, 2005 at 09:48 AM

    Hi Linn,

    pls post the structure of your internal tables

    Andreas

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 29, 2005 at 09:48 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.