Skip to Content

find a specific character in an input string and getting the string after if

Hello,

my requirement is as such, lets say we have an input string ABHISHEK #1234, or BOMBAY 123 #235,

i need to find if the character string has # in it,, if yes pick all the numbers after # .

in the above example, i need output as 1234 and 235

and if any non numeric values after # set a flag

please help me in this.

regards

Abhishek

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 09, 2014 at 09:10 AM

    Hi Abhishek,

    $GV_VALUE  -- Is your String value

    Index function can be used to identify #  in string

    decode(index($GV_VALUE,'#',1)>0,substr( $GV_VALUE ,index($GV_VALUE,'#',1)+1,length($GV_VALUE)- index($GV_VALUE,'#',1)+1),$GV_VALUE)

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 09, 2014 at 09:26 AM

    Hi Abhishek,

    This can be done in BODS using below settings in file format (only if your source is flat file):

    Below is the source file data :

    abcd#1234,Bombay#23456

    By using this file format setting, you should be able to get all the numbers in one column which you can use futher and you can verify this columns data by using "is_valid_int", not null function in BODS.

    I think it should give you solution.

    Thanks,

    Tanvi

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 09, 2014 at 08:35 AM

    Hi Abhishek,

                          one way of doing it is

    DATA a type string,

               b type string ,

              c type string,

              .

    a = 'abhis#1234'.

    split a at '#'  into b c.

    if sy-subrc = 0.

    write : c.

    endif.

    Add comment
    10|10000 characters needed characters exceeded