-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZCL_STRING_OPERATIONS
76 lines (59 loc) · 2.66 KB
/
ZCL_STRING_OPERATIONS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
class ZCL_STRING_OPERATIONS definition
public
final
create public .
public section.
class-methods FIRST_CHARACTER
importing
!IV_STRING type STRING
returning
value(RV_FIRST_CHARACTER) type CHAR1 .
class-methods LAST_CHARACTER
importing
!IV_STRING type STRING
returning
value(RV_LAST_CHARACTER) type CHAR1 .
class-methods REMOVE_LAST_CHARACTER
importing
!IV_STRING type STRING
returning
value(RV_LAST_CHARACTER_REMOVED) type STRING .
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS ZCL_STRING_OPERATIONS IMPLEMENTATION.
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Static Public Method ZCL_STRING_OPERATIONS=>FIRST_CHARACTER
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_STRING TYPE STRING
* | [<-()] RV_FIRST_CHARACTER TYPE CHAR1
* +--------------------------------------------------------------------------------------</SIGNATURE>
METHOD first_character.
CHECK iv_string IS NOT INITIAL.
rv_first_character = iv_string+0(1).
ENDMETHOD.
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Static Public Method ZCL_STRING_OPERATIONS=>LAST_CHARACTER
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_STRING TYPE STRING
* | [<-()] RV_LAST_CHARACTER TYPE CHAR1
* +--------------------------------------------------------------------------------------</SIGNATURE>
METHOD last_character.
CHECK iv_string IS NOT INITIAL.
rv_last_character = substring( val = iv_string
off = ( strlen( iv_string ) - 1 )
len = 1 ).
ENDMETHOD.
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Static Public Method ZCL_STRING_OPERATIONS=>REMOVE_LAST_CHARACTER
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_STRING TYPE STRING
* | [<-()] RV_LAST_CHARACTER_REMOVED TYPE STRING
* +--------------------------------------------------------------------------------------</SIGNATURE>
METHOD remove_last_character.
CHECK iv_string IS NOT INITIAL.
rv_last_character_removed = substring( val = iv_string
off = 0
len = strlen( iv_string ) - 1 ).
ENDMETHOD.
ENDCLASS.