소수점뒤의 0을 제거하는 로직입니다.
검증된 로직은 아닙니다. 참조만 해주세요~
REPORT TEST01.
DATA : lv_char13(13),
lv_char17(17).
DATA : lv_menge TYPE ekpo-menge.
lv_menge = '123456789.500000'.
lv_char17 = lv_menge.
WRITE : / lv_menge.
PERFORM exclude_zero USING lv_char17
CHANGING lv_char13.
WRITE : / lv_char13.
*&---------------------------------------------------------------------*
*& Form EXCLUDE_ZERO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_lv_menge text
* <--P_lv_char13 text
*----------------------------------------------------------------------*
FORM EXCLUDE_ZERO USING P_UNIPR
CHANGING P_CHAR13.
CLEAR: P_CHAR13.
CONSTANTS: C_EXEP_NUM_PER TYPE STRING VALUE '[^0-9.,]',
C_EXEP_NUM TYPE STRING VALUE '[^1-9]',
C_COMMA TYPE C VALUE ',',
C_PERIOD TYPE C VALUE '.'.
DATA: LV_STRING TYPE STRING.
DATA: LV_CNT TYPE I VALUE 0.
DATA: LV_BEF TYPE STRING,
LV_AFT TYPE STRING,
LV_TEMP TYPE CHAR255.
MOVE P_UNIPR TO LV_STRING. "DATA 이동
SHIFT LV_STRING LEFT DELETING LEADING SPACE.
SPLIT LV_STRING AT C_PERIOD INTO LV_BEF LV_AFT.
FIND REGEX C_EXEP_NUM_PER IN LV_STRING.
IF SY-SUBRC = 0.
EXIT.
ELSE.
SY-SUBRC = 0.
CLEAR LV_STRING.
ENDIF.
MOVE LV_AFT TO LV_CNT. "1.000 이런 케이스 -> 분류 위해
IF LV_CNT <> 0.
WHILE SY-SUBRC EQ 0.
MOVE LV_AFT TO LV_TEMP.
LV_CNT = STRLEN( LV_TEMP ) - 1.
MOVE LV_TEMP+LV_CNT(1) TO LV_AFT.
FIND REGEX C_EXEP_NUM IN LV_AFT.
IF SY-SUBRC = 0.
MOVE LV_TEMP+0(LV_CNT) TO LV_AFT.
ELSE.
MOVE LV_TEMP TO LV_AFT.
ENDIF.
ENDWHILE.
CONCATENATE LV_BEF C_PERIOD LV_AFT INTO LV_STRING.
ELSE.
MOVE LV_BEF TO LV_STRING.
ENDIF.
MOVE LV_STRING TO P_CHAR13.
ENDFORM. " EXCLUDE_ZERO