File tree Expand file tree Collapse file tree 4 files changed +62
-0
lines changed Expand file tree Collapse file tree 4 files changed +62
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,12 @@ lo_map->set(
39
39
iv_val = '2' ).
40
40
```
41
41
42
+ - there is also ` setx ` - a more readable yet not so strict version of ` set ` . Can be useful for multiple sets in a raw.
43
+
44
+ ``` abap
45
+ lo_map->setx( 'A:1' )->setx( |B : { '2' }| ).
46
+ ```
47
+
42
48
- implements ` keys ` , ` values `
43
49
44
50
``` abap
Original file line number Diff line number Diff line change 11
11
v1.0.4, 2024-06-24
12
12
------------------
13
13
+ to_entries - saves entries to a standard table with 2 char-like components (#11)
14
+ + setx - simplified and more readable version of set (#12)
14
15
15
16
v1.0.3, 2021-07-25
16
17
------------------
Original file line number Diff line number Diff line change @@ -49,6 +49,11 @@ class zcl_abap_string_map definition
49
49
!iv_val type clike
50
50
returning
51
51
value (ro_map ) type ref to zcl_abap_string_map.
52
+ methods setx
53
+ importing
54
+ !iv_str type csequence
55
+ returning
56
+ value (ro_map ) type ref to zcl_abap_string_map.
52
57
methods size
53
58
returning
54
59
value (rv_size ) type i .
@@ -383,6 +388,32 @@ CLASS ZCL_ABAP_STRING_MAP IMPLEMENTATION.
383
388
endmethod .
384
389
385
390
391
+ method setx .
392
+
393
+ data lv_key type string .
394
+ data lv_val type string .
395
+
396
+ ro_map = me .
397
+
398
+ if iv_str is initial .
399
+ return .
400
+ endif .
401
+
402
+ split iv_str at ':' into lv_key lv_val.
403
+ condense lv_key.
404
+ condense lv_val.
405
+
406
+ if lv_key is initial .
407
+ return .
408
+ endif .
409
+
410
+ set(
411
+ iv_key = lv_key
412
+ iv_val = lv_val ).
413
+
414
+ endmethod .
415
+
416
+
386
417
method size .
387
418
388
419
rv_size = lines ( mt_entries ).
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ class ltcl_string_map definition
19
19
methods keys_values for testing .
20
20
methods case_insensitive for testing .
21
21
methods set_clike for testing .
22
+ methods setx for testing .
22
23
23
24
methods strict for testing .
24
25
methods freeze for testing .
@@ -927,4 +928,27 @@ class ltcl_string_map implementation.
927
928
928
929
endmethod .
929
930
931
+ method setx .
932
+
933
+ data lo_cut type ref to zcl_abap_string_map.
934
+
935
+ lo_cut = zcl_abap_string_map=>create( ).
936
+
937
+ lo_cut->setx( 'a:1' ).
938
+ lo_cut->setx( | b : 2| ).
939
+ lo_cut->setx( ':c' ).
940
+ lo_cut->setx( '' ).
941
+
942
+ cl_abap_unit_assert=>assert_equals(
943
+ exp = 2
944
+ act = lo_cut->size( ) ).
945
+ cl_abap_unit_assert=>assert_equals(
946
+ exp = lo_cut->get( 'a' )
947
+ act = '1' ).
948
+ cl_abap_unit_assert=>assert_equals(
949
+ exp = lo_cut->get( 'b' )
950
+ act = '2' ).
951
+
952
+ endmethod .
953
+
930
954
endclass .
You can’t perform that action at this time.
0 commit comments