This website is not affiliated with, sponsored by, or approved by SAP AG.

Transformation: Need to suppress letters in expression

Business Warehouse

Moderators: Snowy, thx4allthefish

Transformation: Need to suppress letters in expression

Postby Triskel » Mon Nov 08, 2010 4:16 am

Hi All,

In a transformation I need to create a routine to suppress all the letters (and anything else than ".") contained in an expression. For example:
ABC-DEF 1.2 -> 1.2
GHI 5 -> 5
ABC DEF 4.3 -> 4.3

I have unsuccessfully tried the use of regex functions and I suspect it is because of my poor abap knowledge and the poor ability of understanding regex functions!!!

I had wrongly posted this question in the abap section previously: viewtopic.php?f=13&t=342529&p=1038675#p1038675

Thanks for your help,
Phil
Triskel
 
Posts: 14
Joined: Mon Jun 28, 2010 7:52 am
Location: France

Re: Transformation: Need to suppress letters in expression

Postby closingbrace » Wed Nov 10, 2010 5:11 am

This is not possible using normal ABAP functions. But by reversing the string its possible.
Code: Select all
DATA str TYPE STRING.
DATA str2 TYPE STRING.

str = SOURCE_FEILDS-XXXXXX.

PERFORM rsubstring
    USING
        str
        0
        3
    CHANGING
        str2.

FORM rsubstring
    USING
        str TYPE STRING
        offset
        len
    CHANGING
        out TYPE STRING.
    DATA:
        strln TYPE i,
        l_offset TYPE i,
        l_len TYPE i.

    strln = STRLEN( str ).
    l_offset = strln - offset - len.
    l_len = len.
    out = str+l_offset(l_len).

* Optional - Perform ALPHA conversion if necessary!
closingbrace
 
Posts: 5
Joined: Wed Nov 10, 2010 4:57 am


Return to Business Warehouse

Who is online

Users browsing this forum: No registered users and 5 guests





loading...


This website is not affiliated with, sponsored by, or approved by SAP AG.