FUNCTION Z02FI_NUMBER_SPLIT
.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(I_NUM) TYPE STRING
*" EXPORTING
*" REFERENCE(E_NUM) TYPE STRING
*"----------------------------------------------------------------------
DATA
:L_STR1
TYPE STRING
.
DATA
:L_STR2
TYPE STRING
.
DATA
: L_LEN
TYPE
I
,
L_COUNT
TYPE
I
,
L_CHAR
TYPE STRING
,
L_POS
TYPE
I
,
L_REST
TYPE
I
,
L_TIME
TYPE
I
,
L_FLAG
.
CONSTANTS
: C_TAB
VALUE
','
,
C_POT
VALUE
'.'
.
CLEAR
:
L_LEN
,
L_COUNT
,
L_CHAR
,
L_POS
,
L_REST
,
L_TIME
,
L_STR1
,
L_STR2
,
L_FLAG
.
CHECK I_NUM
IS
NOT
INITIAL
.
IF I_NUM
CS C_POT
.
SPLIT I_NUM
AT C_POT
INTO L_STR1 L_STR2
.
L_FLAG
=
'X'
.
ELSE
.
L_STR1
= I_NUM
.
ENDIF
.
L_LEN
=
STRLEN
( L_STR1
)
.
L_COUNT
= L_LEN
.
L_REST
= L_LEN
MOD
3
.
IF L_REST
=
0
.
L_TIME
= L_LEN
DIV
3
.
ELSE
.
L_TIME
= L_LEN
DIV
3 +
1
.
ENDIF
.
DO L_TIME
TIMES
.
L_COUNT
= L_COUNT
-
3
.
IF L_COUNT >
0
.
CONCATENATE C_TAB L_STR1+L_COUNT
(
3
) L_CHAR
INTO L_CHAR
.
ELSEIF L_COUNT <=
0
.
L_COUNT
= L_COUNT +
3
.
CONCATENATE L_STR1+0
(L_COUNT
) L_CHAR
INTO L_CHAR
.
EXIT
.
ENDIF
.
ENDDO
.
E_NUM
= L_CHAR
.
CONDENSE E_NUM
NO
-GAPS
.
IF L_FLAG
IS
NOT
INITIAL
.
CONCATENATE E_NUM C_POT L_STR2
INTO E_NUM
.
ENDIF
.
ENDFUNCTION
.