Thursday, January 24, 2019

base64 encoding decoding in ABAP

SAP's standard class cl_http_utility provides methods to encode and decode base64, i.e. encode_base64 and decode_base64.


l_result = new cl_http_utility)->encode_base64( l_input ).
l_result = new cl_http_utility)->decode_base64l_input ).

Example Report

report zjso_base64.

parameters pa_enc type text120.
parameters pa_dec type text120.

start-of-selection.
  if pa_enc is not initial.
    perform encode_base64 using pa_enc.
  endif.
  if pa_dec is not initial.
    perform decode_base64 using pa_dec.
  endif.


form encode_base64 using i_char type char120.
  write/ |{ i_char } { 'base64-encoded is' } { new cl_http_utility)->encode_base64conv #i_char }|.
endform.

form decode_base64 using i_char type char120.
  write/ |{ i_char } { 'base64-decoded is' } { new cl_http_utility)->decode_base64conv #i_char }|.
endform.

Working with the session Id // ID für den Modus

Sometimes it can be helpful to know the id of the current session     CALL FUNCTION 'TH_GET_CONTEXT_ID'       IMPORTING         cont...