Step1. Create the below program .
--------------------------------------------------------------------------------------------------------------------------
TYPES : BEGIN OF ty_str,
fld1 TYPE i,
fld2 TYPE i,
fld3 TYPE i,
END OF ty_str.
DATA : str1 TYPE ty_str.
" old way of filling structure "
str1-fld1 = 5.
str1-fld2 = 15.
str1-fld3 = 25.
WRITE :/ 'Old way', str1-fld1, str1-fld2, str1-fld3.
" New way of filling structure with VALUE operator "
DATA : str2 TYPE ty_str.
str2 = VALUE ty_str( fld1 = 10
fld2 = 20
fld3 = 30 ).
WRITE :/ 'New way1', str2-fld1, str2-fld2, str2-fld3.
" New way of filling structure with VALUE operator "
DATA str3 TYPE ty_str.
str3 = VALUE #( fld1 = 100
fld2 = 200
fld3 = 300 ).
WRITE :/ 'New way2', str3-fld1, str3-fld2, str3-fld3.
" New way of filling structure with VALUE operator"
DATA(str4) = VALUE ty_str( fld1 = 1000
fld2 = 2000
fld3 = 3000 ).
WRITE :/ 'New way3 ', str4-fld1, str4-fld2, str4-fld3.
------------------------------------------------------------------------------------------------------------------------
Step2.
-------------------------------------------------------------------------------------------------------------------------
fld1 TYPE i,
fld2 TYPE i,
fld3 TYPE i,
END OF ty_str.
DATA : str1 TYPE ty_str.
" old way of filling structure "
str1-fld1 = 5.
str1-fld2 = 15.
str1-fld3 = 25.
WRITE :/ 'Old way', str1-fld1, str1-fld2, str1-fld3.
" New way of filling structure with VALUE operator "
DATA : str2 TYPE ty_str.
str2 = VALUE ty_str( fld1 = 10
fld2 = 20
fld3 = 30 ).
WRITE :/ 'New way1', str2-fld1, str2-fld2, str2-fld3.
" New way of filling structure with VALUE operator "
DATA str3 TYPE ty_str.
str3 = VALUE #( fld1 = 100
fld2 = 200
fld3 = 300 ).
WRITE :/ 'New way2', str3-fld1, str3-fld2, str3-fld3.
" New way of filling structure with VALUE operator"
DATA(str4) = VALUE ty_str( fld1 = 1000
fld2 = 2000
fld3 = 3000 ).
WRITE :/ 'New way3 ', str4-fld1, str4-fld2, str4-fld3.
------------------------------------------------------------------------------------------------------------------------
Step2.
-------------------------------------------------------------------------------------------------------------------------
No comments:
Post a Comment