Skip to content

abapify/codepage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Codepage polyfill

It never happened and it happened again. Clean core requires a new class for code page and the old class is not allowed.

Why?

CL_ABAP_CODEPAGE was a class SAP introduced long time ago and it was efficiently handling string <-> binary conversion for UTF-8 documents such as XML or JSON or whatever else.

We can see that is still present in a new ABAP documentation snippets. image

However it turned out to be one more example when "Clean Core" concept simply prevented us from using this class: The use of Class CL_ABAP_CODEPAGE is not permitted

image

So what should we use instead? Well there is another nice class which we can use: CL_ABAP_CONV_CODEPAGE

Introducing one class in a new environment which is not present in the old environment prevents us from reusing the code. Polyfill approach allows us to use one class which will work in any system.

ZCL_ABAP_CODEPAGE

Rountrip example from the unit test

data(test) = |This is a sample string|.
" String to xstring ( to codepage )
data(lv_binary) = zcl_abap_codepage=>to( test ).
" Xstring to string ( from codepage )
assert( zcl_abap_codepage=>from( lv_binary ) )->eq( test ).

Test Dependencies

About

Codepage polyfill

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages