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: 

How to use offset in getting the last 7 digit of a sting

Former Member
0 Kudos

Hi,

Will you please tell me, how I can use Offset like command for the following code :-

Data :- v_file type string .

Let v_file = xyz/abc/ABCD/pq.rs.tuv1234

I want to take last 7 digit i.e. "tuv1234"

Please tell me..

Saurabh

1 ACCEPTED SOLUTION

Former Member
0 Kudos

data : text(40) type c value 'gashscj/kdkkl223',

length type i,

value(7).

length = strlen( text ).

length = length - 7.

value = text+length(7).

regards

shiba dutta

Message was edited by:

SHIBA DUTTA

9 REPLIES 9

Former Member
0 Kudos

data : text(40) type c value 'gashscj/kdkkl223',

length type i,

value(7).

length = strlen( text ).

length = length - 7.

value = text+length(7).

regards

shiba dutta

Message was edited by:

SHIBA DUTTA

Former Member
0 Kudos

Hi,

Count the total length of the string and use the offset.

here total is 26

Let v_file = xyz/abc/ABCD/pq.rs.tuv1234

so use String = v_file+19(7).

Regards,

Anji

Former Member
0 Kudos

Hello,

U can do like this:


DATA : V_FILE TYPE STRING .
DATA: LEN TYPE I.

V_FILE = 'xyz/abc/ABCD/pq.rs.tuv1234'.

LEN = STRLEN( V_FILE ).
LEN = LEN - 7.
WRITE: V_FILE+LEN(7).

If usefulreward.

Vasanth

amit_khare
Active Contributor
0 Kudos

v= strlen(v_file).

x = v - 7.

v_file1 = v_file+x(7).

Regards,

Amit

raymond_giuseppi
Active Contributor
0 Kudos

Try something like

  DATA: v_file TYPE string,
        extract TYPE string,
        len TYPE i.
  v_file = 'xyz/abc/ABCD/pq.rs.tuv1234'.
  COMPUTE len = strlen( v_file ) - 7.
  extract = v_file+len(7).

Regards

Former Member
0 Kudos

Hi,

Data : v_file type string .

v_file = 'xyz/abc/ABCD/pq.rs.tuv1234'.

v_file = v_file+19(7).

write:/ v_file.

Regards,

Sruthi

Former Member
0 Kudos

HI,

v_len = strlen( field-name ).

v_len = v_len - 6.

offset = BSIS-BUDAT+v_len(7).

Kishore

Former Member
0 Kudos

you can also use this FM to get the extension of a file

<b>SDOK_FILE_NAME_EXTENSION_GET</b>

Former Member
0 Kudos

In addition to the answers above. Check that the filled length of the source field is 7 or greater. Trying to extract from a negative offset is meaningless.

MattG.