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

Find Substring + 2 characters in a string

Former Member
0 Likes
2,302

I have the following string: 1.0000000000000000E+01

I need to find subtring E+01 and delete it from the string.

problem is thet 01 can be anything and changes.

I need an expression that will find a subtring starting E+ and two characters that come after ie 01

<removed_by_moderator>

Edited by: Julius Bussche on Sep 15, 2009 10:31 AM

1 ACCEPTED SOLUTION
Read only

former_member188827
Active Contributor
0 Likes
1,483

split string at 'E' into ch1 ch2.

ch1 is the string that doesnt contain your desired substring.

8 REPLIES 8
Read only

former_member188827
Active Contributor
0 Likes
1,484

split string at 'E' into ch1 ch2.

ch1 is the string that doesnt contain your desired substring.

Read only

Former Member
0 Likes
1,483

Hi,

Here is the code acc to the requirement...


data:
w_str(30) type c value '1.0000000000000000E+01',
w_off type i.
search w_str for 'E+'.
write: sy-fdpos.
w_off = sy-fdpos.
w_str+w_off(4) = space.
write: w_str.

Regards,

Mdi.Deeba

Read only

Former Member
0 Likes
1,483

Hi,

Try the below code;

Data : str(100) type C value '1.0000000000000000E+01'.
Data : len type i.
len = strlen( str ) - 4.
str = str+0(len).

This will solve the problem.

>

> Will award points pls help.

Do not offer points its against [Forum Rules|http://wiki.sdn.sap.com/wiki/x/FgQ].

Regards

Karthik D

Read only

Former Member
0 Likes
1,483

Hi,

Try this,

data: w_var1(10) type C value '100E+01',

var1(10) type c,

var2(10) type c.

if w_var1 CS 'E+'.

Split w_var1 at 'E+' into var1 var2.

Endif.

Write: var1, var2.

Read only

Former Member
0 Likes
1,483

Hi,

Try following code

DATA : TEMP TYPE STRING,

CHAR_1(20) TYPE C,

CHAR_2(10) TYPE C.

TEMP = '1.0000000000000000E+01'.

SPLIT TEMP AT 'E+' INTO CHAR_1 CHAR_2.

IF CHAR_2 = '01'.

char_1 contains value you need, you can move this value to the desired internal table.

ENDIF.

Hope this helps.

Edited By Tejaswini Khante

Read only

Former Member
0 Likes
1,483

Hi,

Hope this code will give you an idea of how to do this.



DATA: str TYPE string VALUE '1.00000000000E+02',
      result_tab TYPE match_result.

FIND 'E+' IN str RESULTS result_tab.

WRITE:/ str+result_tab-offset.

Regards,

Naga Sai Swapna

Read only

rainer_hbenthal
Active Contributor
0 Likes
1,483

Strange requirement....

1.0000000E+01 is 10

1.0000000E+02 is 100

After deleting the exponent both values are 1.....

If it is to convert a stringrepresantion of a floating number to a number there are better solutions...

Read only

Former Member
0 Likes
1,483

Hi Maksims Jegorovcevs,

Use below code... it will solve your problem... Use offset condence etc while solving this kind of requirement..

PARAMETERS : P_STR(30) TYPE C DEFAULT '1.000000000E+010000000'.

DATA: L_OFFSET TYPE I.

WRITE: / 'INPUT  : ' , P_STR.

SEARCH P_STR FOR 'E+'.

L_OFFSET = SY-FDPOS.

P_STR+L_OFFSET(4) = ''.

CONDENSE P_STR NO-GAPS.

WRITE: / 'OUTPUT : ', P_STR.

Hope it will solve your problem..

Thanks & Regards

ilesh 24x7

ilesh Nandaniya