IT干货网

【ABAP系列】ABAP CL_ABAP_CONV_IN_CE

shasha 2022年03月17日 SAP 134 0

以下为正文

Conversion

either CREATE + CONVERT

Error rendering macro 'code': Invalid value specified for parameter 'lang'

  DATA conv TYPE REF TO cl_abap_conv_in_ce. 
  DATA buffer(4) TYPE x. 
  DATA text(100) TYPE c. 
  buffer = '41424332'. "bytes represent ABC2 in UTF-8 
  conv = cl_abap_conv_in_ce=>create( 
        encoding = 'UTF-8' ). 
  conv->convert( 
        EXPORTING input = buffer 
        IMPORTING data = text ). 
  ASSERT text = `ABC2`. 

or CREATE + READ + SKIP_C (buffer of bytes with a pointer)

Error rendering macro 'code': Invalid value specified for parameter 'lang'

  DATA buffer(5) TYPE x. 
  DATA conv TYPE REF TO cl_abap_conv_in_ce. 
  DATA text(100) TYPE c. 
  buffer = '4142433235'. "bytes represent ABC25 in UTF-8 
  conv = cl_abap_conv_in_ce=>create( 
         encoding = 'UTF-8' 
         input = buffer ). 
  CALL METHOD conv->read( 
    EXPORTING n    = 2 
    IMPORTING data = text ). 
  ASSERT text = `AB`. 
  CALL METHOD conv->skip_c( 
    EXPORTING n    = 1 ). 
  CALL METHOD conv->read( 
    EXPORTING n    = 2 
    IMPORTING data = text ). 
  ASSERT text = `25`. 

UCCP: converts a unicode code point (hexa representation) into a character

Unique parameter must be a string of exactly 4 characters, in hexadecimal representation (0 to 9, and A to F).

Error rendering macro 'code': Invalid value specified for parameter 'lang'

DATA c2 TYPE c LENGTH 2. 
c2 = cl_abap_conv_in_ce=>uccp( '0041' ). 
ASSERT c2 = 'A'. 

Error rendering macro 'code': Invalid value specified for parameter 'lang'

DATA c4 TYPE c LENGTH 4. 
DATA c2 TYPE c LENGTH 2. 
c4 = '0041'. 
c2 = cl_abap_conv_in_ce=>uccp( c4 ). 
ASSERT c2 = 'A'. 

Error rendering macro 'code': Invalid value specified for parameter 'lang'

DATA x2 TYPE x LENGTH 2. 
x2 = '0041'. 
c2 = cl_abap_conv_in_ce=>uccp( x2 ). 
ASSERT c2 = 'A'. 

UCCPI: converts a unicode code point into a character

Unique parameter must be an integer.

Error rendering macro 'code': Invalid value specified for parameter 'lang'

DATA c2 TYPE c LENGTH 2. 
c2 = cl_abap_conv_in_ce=>uccpi( 65 ). 
ASSERT c2 = 'A'.

评论关闭
IT干货网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!

【ABAP系列】SAP ABAP下载带密码的Excel文件