DATA: l_json TYPE string,
l_xstr TYPE xstring,
l_encode TYPE string.
l_json = '{"I_INT_NAME":"Z_TEST_FUNCTION","I_KEY":"123456","I_JSON":{"AUFNR":"0000123456"}}'.
* String to Xstring
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = l_json
IMPORTING
buffer = l_xstr
EXCEPTIONS
failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
WRITE:/ l_xstr.
*Encode base64
CALL FUNCTION 'SCMS_BASE64_ENCODE_STR'
EXPORTING
input = l_xstr
IMPORTING
output = l_encode.
WRITE:/ l_encode.
结果
用notepad++测试
结果一致。
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/17869.html