Encode String
DATA: lv_xstring TYPE xstring.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = input_string
IMPORTING
buffer = lv_xstring
EXCEPTIONS
failed = 1
OTHERS = 2.
CALL FUNCTION 'SCMS_BASE64_ENCODE_STR'
EXPORTING
input = lv_xstring
IMPORTING
output = output_encoded_string.
Decode String
DATA: lv_xstring TYPE xstring,
lv_len TYPE i,
lt_bin TYPE solix_tab.
CALL FUNCTION 'SCMS_BASE64_DECODE_STR'
EXPORTING
input = input_encoded_string
IMPORTING
output = lv_xstring
EXCEPTIONS
failed = 1
OTHERS = 2.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lv_xstring
IMPORTING
output_length = lv_len
TABLES
binary_tab = lt_bin.
CALL FUNCTION 'SCMS_BINARY_TO_STRING'
EXPORTING
input_length = lv_len
IMPORTING
text_buffer = output_decoded_string
TABLES
binary_tab = lt_bin
EXCEPTIONS
failed = 1
OTHERS = 2.
1 thought on “SAP ABAP – String Encode & Decode BASE64”