도움이 되었으면 좋겠습니다.
소스 긁어서 통채로 올립니다.
*&---------------------------------------------------------------------*
*& Form compress_2byte_string
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_L_TLINE_ST_IT_TDLINE text
*----------------------------------------------------------------------*
FORM compress_2byte_string CHANGING value(c_string).
" DATA : l_count TYPE i,"
" l_number TYPE i,"
l_no_space TYPE i.
CHECK NOT c_string IS INITIAL.
DO.
sy-index = sy-index - 1.
IF c_string+sy-index(1) EQ space.
l_no_space = l_no_space + 1.
ELSE.
EXIT.
ENDIF.
ENDDO.
CHECK l_no_space NE 0.
DO l_no_space TIMES.
REPLACE space WITH '*' INTO c_string.
ENDDO.
DO.
sy-index = sy-index - 1.
IF c_string+sy-index(1) EQ '*'.
l_count = l_count + 1.
ELSE.
EXIT.
ENDIF.
ENDDO.
IF l_count GT 2.
l_number = l_count DIV 2.
DO l_number TIMES.
REPLACE '*' WITH space INTO c_string.
ENDDO.
CONDENSE c_string.
DO.
REPLACE '*' WITH space INTO c_string.
IF sy-subrc NE 0.
EXIT.
ENDIF.
ENDDO.
ELSE.
DO.
REPLACE '*' WITH space INTO c_string.
IF sy-subrc NE 0.
EXIT.
ENDIF.
ENDDO.
ENDIF.
"ENDFORM. "" compress_2byte_string
<< 발췌는 역시나 http://www.storyroom.net >>
한글을 2자리로 먹어야하나 1자리로 먹어서 문제네요 ㅡ.ㅡ;;