Gyan Factory

Gyan Factory
SAP Technical Project Support

Wednesday, January 6, 2016

Some Useful String Functions?

Substring with Offset and length

DATA  result TYPE string.

result = substring( val = 'ABCDEFGH' off = 2 len = 3 ).
Write :/ result

OUTPUT:   CDE


----------------------------------------------------------------------------------------------------------------------------------

Substring From

DATA  result TYPE string.

result = substring_from( val = 'ABCDEFGH' sub = 'CD' ).
Write :/ result

OUTPUT:   CDEFGH

----------------------------------------------------------------------------------------------------------------------------------

Substring After


DATA  result TYPE string.

result = substring_after( val = 'ABCDEFGH' sub = 'CD' ). 
Write :/ result

OUTPUT:   EFGH


----------------------------------------------------------------------------------------------------------------------------------

Substring Before

DATA  result TYPE string.

result = substring_brfore( val = 'ABCDEFGH' sub = 'CD' ). 
Write :/ result

OUTPUT:   AB


----------------------------------------------------------------------------------------------------------------------------------

Substring To

DATA  result TYPE string.

result = substring_to( val = 'ABCDEFGH' sub = 'CD' ). 
Write :/ result

OUTPUT:   ABCD


--------------------------------------------------------------------------------------

No comments:

Post a Comment