1
*&---------------------------------------------------------------------*
2
*& Include ZUTIL_CONVERT_NUMBER *
3
*& *
4
5
6
*& This file is part of ZUTIL. *
7
8
*& ZUTIL is free software: you can redistribute it and/or modify *
9
*& it under the terms of the GNU General Public License as published *
10
*& by the Free Software Foundation, either version 3 of the License, *
11
*& or any later version. *
12
13
*& ZUTIL is distributed in the hope that it will be useful, *
14
*& but WITHOUT ANY WARRANTY; without even the implied warranty of *
15
*& MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16
*& GNU General Public License for more details. *
17
18
*& You should have received a copy of the GNU General Public License *
19
*& along with ZUTIL. If not, see <http://www.gnu.org/licenses/>. *
20
21
22
23
*& Author: Ruediger von Creytz ruediger.creytz@globalbit.net *
24
*& Copyright: globalBIT, LLC http://www.globalbit.net *
25
26
27
28
29
*-----------------------------------------------------------------------
30
* number_to_x_char
31
32
FORM number_to_x_char
33
USING
34
i_num TYPE i
35
CHANGING
36
c_char TYPE c.
37
38
DATA:
39
l_num TYPE i.
40
41
CONSTANTS:
42
lc_chars(26) TYPE c VALUE 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
43
44
CLEAR c_char.
45
46
IF i_num < 10.
47
c_char = i_num.
48
ELSEIF i_num < 36.
49
l_num = i_num - 10.
50
c_char = lc_chars+l_num(1).
51
ENDIF.
52
ENDFORM. "number_to_x_char
53
54
55
56
* number_to_hex_string
57
58
FORM number_to_hex_string
59
60
i_num TYPE any
61
62
c_hex TYPE string.
63
64
PERFORM number_to_x_string
65
66
i_num
67
68
69
c_hex.
70
71
ENDFORM. "number_to_hex_string
72
73
74
75
* number_to_x_string
76
77
FORM number_to_x_string
78
79
80
i_number_system TYPE i
81
82
83
84
85
l_num TYPE i,
86
l_cal TYPE i VALUE 1,
87
l_cnt TYPE i,
88
l_hex_char TYPE c.
89
90
CLEAR c_hex.
91
l_num = i_num.
92
93
IF l_num = 0.
94
c_hex = '0'.
95
ELSE.
96
DO.
97
l_cnt = 0.
98
IF l_cal <= l_num.
99
l_cal = l_cal * i_number_system.
100
101
IF l_cal > l_num.
102
l_cal = l_cal / i_number_system.
103
104
105
l_num = l_num - l_cal.
106
l_cnt = l_cnt + 1.
107
108
EXIT.
109
110
ENDDO.
111
PERFORM number_to_x_char
112
USING l_cnt
113
CHANGING l_hex_char.
114
CONCATENATE c_hex l_hex_char INTO c_hex.
115
116
IF l_num = 0 AND l_cal = 1.
117
118
119
120
121