Application Development 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 data between two characters

Former Member
0 Kudos

Hello Experts,

I have the data as follows:

"943/2764//00101/1000/11111/////121/3405\"

The above data is stored in a structure ITAB.

I want to get the characters between the last "/" (forward slash) and the "\" (back slash), that is the value 3405.

Could you let me know how to go about it? Points to be awarded for sure. Thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Try as follows:

data: begin of itab,

text(20) type c,

end of itab.

str = '943/2764//00101/1000/11111/////121/3405\'.

SPLIT str AT '/' INTO TABLE itab.

describe itab lines l_f_lines.

read itab index l_f_lines.

len = strlen(itab-text).

len = len - 1.

val = itab-text+0(len).

Write : / val.

5 REPLIES 5

Former Member
0 Kudos

Hi,

You can do it by do end endo

use search and split at / and again split / till you wont new one

finally read the string only the required portin

Regards

shiva

former_member156446
Active Contributor
0 Kudos

hi Prasad

Assumptions: 3405 will be always 4 characters...

lv_total = strln (itab-field).

lv_buff = lv_total - 5.

lv_final = itab-field+lv_buff(4).

Former Member
0 Kudos

Hi,

Try as follows:

data: begin of itab,

text(20) type c,

end of itab.

str = '943/2764//00101/1000/11111/////121/3405\'.

SPLIT str AT '/' INTO TABLE itab.

describe itab lines l_f_lines.

read itab index l_f_lines.

len = strlen(itab-text).

len = len - 1.

val = itab-text+0(len).

Write : / val.

Former Member
0 Kudos

Thanks Hiri..the problem is solved.

Former Member
0 Kudos

Hi Debaprasad,

try this.

DATA : test(200) TYPE c,

len TYPE i,

result(20) TYPE c,

flag_done type c.

test = '943/2764//00101/1000/11111/////121/3405\'.

condense test.

DESCRIBE FIELD test LENGTH len IN CHARACTER MODE.

len = len - 1.

DO.

IF test+len(1) = '\'.

DO.

len = len - 1.

If test+len(1) = '/'.

flag_done = 'X'.

exit.

endif.

IF result IS INITIAL.

result = test+len(1).

ELSE.

CONCATENATE test+len(1)

result

INTO result.

condense result.

ENDIF.

ENDDO.

ENDIF.

if flag_done = 'X'.

exit.

endif.

len = len - 1.

ENDDO.

write result.

Regards,

Mohaiyuddin