@@ -16,10 +16,13 @@ ENDCLASS.
1616CLASS cl_abap_exceptional_values IMPLEMENTATION .
1717
1818 METHOD get_max_value .
19- DATA lv_type TYPE c LENGTH 1 .
20- DATA lv_length TYPE i .
21- DATA lv_decimals TYPE i .
22- FIELD-SYMBOLS <out> TYPE any .
19+ DATA lv_type TYPE c LENGTH 1 .
20+ DATA lv_length TYPE i .
21+ DATA lv_decimals TYPE i .
22+ DATA lv_digits_before_decimal TYPE i .
23+ DATA lv_integer_part TYPE string .
24+ DATA lv_decimal_part TYPE string .
25+ FIELD-SYMBOLS <out> TYPE any .
2326
2427 DESCRIBE FIELD in TYPE lv_type.
2528
@@ -32,15 +35,20 @@ CLASS cl_abap_exceptional_values IMPLEMENTATION.
3235 CREATE DATA out TYPE p LENGTH lv_length DECIMALS lv_decimals.
3336 ASSIGN out->* TO <out> .
3437
35- IF lv_length = 3 AND lv_decimals = 1 .
36- <out> = '9999.9' .
37- ELSEIF lv_length = 4 AND lv_decimals = 1 .
38- <out> = '999999.9' .
39- ELSEIF lv_length = 7 AND lv_decimals = 3 .
40- <out> = '9999999999.999' .
41- ELSE .
42- ASSERT 1 = 'todo' .
38+ lv_digits_before_decimal = lv_length * 2 - 1 - lv_decimals.
39+
40+ DO lv_digits_before_decimal TIMES .
41+ lv_integer_part = lv_integer_part && '9' .
42+ ENDDO .
43+
44+ IF lv_decimals > 0 .
45+ lv_decimal_part = '.' .
46+ DO lv_decimals TIMES .
47+ lv_decimal_part = lv_decimal_part && '9' .
48+ ENDDO .
4349 ENDIF .
50+
51+ <out> = lv_integer_part && lv_decimal_part.
4452 WHEN OTHERS .
4553 WRITE '@KERNEL console.dir(INPUT);' .
4654 ASSERT 1 = 'todo' .
0 commit comments