Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to extract characters from string

Former Member
0 Likes
1,792

Dear experts,

How can we extract characters from a given string

in this case.

The prgram fail to compile in *1 and *2.

How can i debug to get output.

data: pa_num(20) type c.

pa_num = '1245678.44'.

len = strlen( pa_num ).

FIND '.' in pa_num.

if sy-subrc = 0.

      • DECIMAL EXISTS.

i_broken-cnum = pa_num+(len-6)(3). *1

append i_broken.

else

      • NO DECIMAL EXISTS.

i_broken-cnum = pa_num+(len-3)(3). *2

append i_broken.

endif.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,204

i_broken-cnum = pa_num+(len-6)(3). wont work.

you cannot do any arithmetic operations in operands. you gotta do it manually before.

like following:

len = len - 6.

i_broken-cnum = pa_num+(len)(3).

Dear experts,

How can we extract characters from a given string

in this case.

The prgram fail to compile in *1 and *2.

How can i debug to get output.

data: pa_num(20) type c.

pa_num = '1245678.44'.

len = strlen( pa_num ).

FIND '.' in pa_num.

if sy-subrc = 0.

      • DECIMAL EXISTS.

i_broken-cnum = pa_num+(len-6)(3). *1

append i_broken.

else

      • NO DECIMAL EXISTS.

i_broken-cnum = pa_num+(len-3)(3). *2

append i_broken.

endif.

4 REPLIES 4
Read only

Former Member
0 Likes
1,204

try like this

completely mistaken

Read only

Former Member
0 Likes
1,205

i_broken-cnum = pa_num+(len-6)(3). wont work.

you cannot do any arithmetic operations in operands. you gotta do it manually before.

like following:

len = len - 6.

i_broken-cnum = pa_num+(len)(3).

Read only

0 Likes
1,204

This too not work as well.

Read only

0 Likes
1,204

Hi,

write

i_brokencnum = pa_num+len(3).

len cant be in ().

Regards,

Surinder