cancel
Showing results for 
Search instead for 
Did you mean: 

extract substring

Former Member
0 Kudos

hi,

i have 2 strings :

AB:9085

123AB:9085

as 9085 not in the same start or fixed position, may i know how to extract it? the length to extract is always 4 and after AB:

thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

U can use SEARCH statement as follows:

DATA : str1 TYPE string VALUE 'AB:9085',

str2 TYPE string VALUE '123AB:9085',

index TYPE i.

SEARCH str1 FOR 'AB:'.

IF sy-subrc = 0.

index = sy-fdpos + 3.

WRITE : str1+index(4).

ENDIF.

Regards,

Himanshu

Answers (3)

Answers (3)

Former Member
0 Kudos

use search syntax

or contain string co

Former Member
0 Kudos
Former Member
0 Kudos

variable = var+3(4)

where var = AB:9085.

Regards,

Atish