cancel
Showing results for 
Search instead for 
Did you mean: 

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

abhishekbiwal
Explorer
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

former_member205887
Active Participant
0 Kudos

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)

abhishekbiwal
Explorer
0 Kudos

hello Balakrishna,

tried your logic but gives error syntax incorrect.

lets say , input is not a global variable but a table1.field 10

and output field is table2.field11

decode(index(table1.field 10,'#',1)>0,substr( table1.field 10 ,index(table1.field 10,'#',1)+1,length(table1.field 10)- index(table1.field 10,'#',1)+1),table1.field 10)


thanks and regards,

abhishek

former_member205887
Active Participant
0 Kudos

Could you post the screenshot or error you are getting ?

abhishekbiwal
Explorer
0 Kudos

Hello Balakrishna,

please find attached screenshot of the error

abhishekbiwal
Explorer
0 Kudos

hello Balakrishna,

another screenshot

former_member205887
Active Participant
0 Kudos

in substr function after 2nd parameter index(....)+1  you have an extra paranthesis

abhishekbiwal
Explorer
0 Kudos

Hello Balakrishna,

i removed the decode part and used the substring part and it worked

thanks and regards

Abhishek

Answers (2)

Answers (2)

Former Member
0 Kudos

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

abhishekbiwal
Explorer
0 Kudos

Hello Tanvi,

my input is not a file.

thanks for the reply

regards,

abhishek

aarif_baig
Active Participant
0 Kudos

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.

abhishekbiwal
Explorer
0 Kudos

hello Aarif,

thank you for the reply, i guess this is abap code, correct me if i'm wrong.

i need this logic in BODS

thanks and regards

Abhishek

aarif_baig
Active Participant
0 Kudos

Hi Abhishek,

                    Yes mate my bad.