Google Search - Blog...........

ABAP - Decoding BASE64 In ABAP

A small form routine to decode base64 (TYPE STRING) into plaintext (TYPE STRING).
FORM decode_base64 USING base64 plaintext.

CHECK base64 IS NOT INITIAL.

CONSTANTS:
lc_op_dec TYPE x VALUE 37.
DATA:
l_xstr TYPE xstring,
lr_conv TYPE REF TO cl_abap_conv_in_ce.

CALL 'SSF_ABAP_SERVICE'
ID 'OPCODE' FIELD lc_op_dec
ID 'BINDATA' FIELD l_xstr
ID 'B64DATA' FIELD base64. "#EC CI_CCALL

TRY.

lr_conv = cl_abap_conv_in_ce=>create( input = l_xstr ).
lr_conv->read( IMPORTING data = plaintext ).

CATCH cx_sy_conversion_codepage.
CLEAR plaintext.
MESSAGE i999(samx) WITH text-004 text-005.
ENDTRY.

ENDFORM

No comments:

Post a Comment