2019.11.10 learn every day [Tips] SAP Day3 - ABAP 7.40 new syntax conversion value and value assignment

1. The syntax is CONV dTYPE | # (...) \

# Represents any type

"Before expression 7.40 
DATA text   TYPE c LENGTH 255.
DATA helper TYPE string.
DATA xstr   TYPE xstring.
helper = text.
xstr = cl_abap_codepage=>convert_to( source = helper ).

 

"After 7.40

DATA text TYPE c LENGTH 255.
text 'zhujx'.
DATA(xstr1= cl_abap_codepage=>convert_to( source = CONV stringtext ).
*OR
DATA(xstr2= cl_abap_codepage=>convert_to( source = CONV #text ).
"转化为16进制

 

2. New Syntax: operating values

"操作值
*   Variables:    VALUE dtype|#( )
*
*   Structures:  VALUE dtype|#( comp1 = a1 comp2 = a2 … )
*
*   Tables:         VALUE dtype|#( ( … ) ( … ) … ) …

TYPES:BEGIN OF ty_mara,
        matnr TYPE mara-matnr,
        matkl TYPE mara-matkl,
      END OF ty_mara.

TYPES:BEGIN OF ty_makt,
        maktx TYPE makt-maktx,
        mara1 TYPE ty_mara,
      END . OF ty_makt. 

" . 1 variables are assigned 
the DATA (lv_matnr) = ' AT001 ' .
 " 2 in assignment to 
the DATA (ls_makt1) ty_makt of VALUE = (maktx = ' the TEST MATERIAL ' 
                           mara1 -matnr = lv_matnr 
                           mara1 -matkl = ' Z001 ' ).
 " 3 assigned to the table 
" (1) inner standard 
the TYPES : ty_t_makt the TYPE the sTANDARD tABLE  . oF ty_makt the WITH EMPTY KEY. 

the DATA (lt_makt) = VALUE ty_t_makt(
( maktx = 'MATERIAL 1' mara1-matnr = 'AT001' mara1-matkl = 'Z001')
( maktx = 'MATERIAL 2' mara1-matnr = 'AT002' mara1-matkl = 'Z001')
( maktx = 'MATERIAL 3' mara1-matnr = 'AT003' mara1-matkl = 'Z001')

The results are:

 

 

-TAB love technology and enjoy life

 

 

 

Guess you like

Origin www.cnblogs.com/jxzhu/p/11830807.html