report z_encode_decode_program. "解密后中文易出现乱码..
parameters: program(100).
parameters: p_encode radiobutton group g1 modif id g1,
p_decode radiobutton group g1 modif id g1.
if p_encode = 'X'.
perform frm_encode_program.
elseif p_decode = 'X'.
perform frm_decode_program.
endif.
*----------------------- Encode ----------------------------------------
form frm_encode_program.
data:begin of itab occurs 0,
line(72).
data:end of itab.
data g_in type string.
data g_out type xstring.
data g_c type string.
data g_line type i.
data g_x type i.
read report program into itab.
loop at itab.
g_line = strlen( itab-line ).
clear g_x.
do g_line times.
g_c = itab-line+g_x(1).
if not g_c is initial.
call function 'HR_KR_STRING_TO_XSTRING'
exporting
codepage_to = '8500'
unicode_string = g_c
out_len = 0
importing
xstring_stream = g_out
exceptions
invalid_codepage = 1
invalid_string = 2
others = 3.
g_out = g_out - 1.
call function 'HR_KR_XSTRING_TO_STRING'
exporting
from_codepage = '8500'
in_xstring = g_out
out_len = 0
importing
out_string = g_in.
itab-line+g_x(1) = g_in.
endif.
g_x = g_x + 1.
enddo.
modify itab.
write itab-line.
endloop.
insert report program from itab.
endform. "frm_encode_program
*----------------------- Decode ----------------------------------------
form frm_decode_program.
data:begin of itab occurs 0,
line(72).
data:end of itab.
data g_in type string.
data g_out type xstring.
data g_c type string.
data g_line type i.
data g_x type i.
read report program into itab.
loop at itab.
g_line = strlen( itab-line ).
clear g_x.
do g_line times.
g_c = itab-line+g_x(1).
if not g_c is initial.
call function 'HR_KR_STRING_TO_XSTRING'
exporting
codepage_to = '8500'
unicode_string = g_c
out_len = 0
importing
xstring_stream = g_out
exceptions
invalid_codepage = 1
invalid_string = 2
others = 3.
g_out = g_out + 1.
call function 'HR_KR_XSTRING_TO_STRING'
exporting
from_codepage = '8500'
in_xstring = g_out
out_len = 0
importing
out_string = g_in.
itab-line+g_x(1) = g_in.
endif.
g_x = g_x + 1.
enddo.
modify itab.
write itab-line.
endloop.
insert report program from itab.
endform. "frm_encode_program
评论