-
Notifications
You must be signed in to change notification settings - Fork 0
/
EXAMPLE.AB4
executable file
·118 lines (94 loc) · 3.04 KB
/
EXAMPLE.AB4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
*&---------------------------------------------------------------------*
*& Report YARISTO
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT yaristo.
DATA wa TYPE zcl_zca_type_utils=>ty_struc_definition.
DATA it TYPE zcl_zca_type_utils=>tt_struc_definition.
DATA ref_it TYPE REF TO zcl_zca_dynamic_table.
DATA ref_wa TYPE REF TO zcl_zca_dynamic_struc.
DATA ref_it_data TYPE REF TO data.
DATA ref_wa_data TYPE REF TO data.
DATA it_withkey TYPE zcl_zca_dynamic_table=>tt_condition.
DATA wa_withkey TYPE zcl_zca_dynamic_table=>ty_condition.
DATA it_where TYPE zcl_zca_dynamic_table=>tt_condition.
DATA wa_where TYPE zcl_zca_dynamic_table=>ty_condition.
DATA lv_tabix TYPE sy-tabix.
DATA lv_subrc TYPE sy-subrc.
FIELD-SYMBOLS <it> TYPE STANDARD TABLE.
FIELD-SYMBOLS <wa> TYPE ANY.
" define structure
wa-fname = 'f1'.
wa-ftype = 'i'.
APPEND wa TO it.
wa-fname = 'f2'.
wa-ftype = 'char50'.
APPEND wa TO it.
wa-fname = 'f3'.
wa-ftype = 'i'.
APPEND wa TO it.
BREAK-POINT.
" create dynamic INTERNAL TABLE object
CREATE OBJECT ref_it
EXPORTING
im_it_struc_def = it.
" create dynamic WORK AREA object
CREATE OBJECT ref_wa
EXPORTING
im_it_struc_def = it.
ref_wa->set_value( im_name = 'f1' im_value = 1 ).
ref_wa->set_value( im_name = 'f2' im_value = 'Hello' ).
ref_wa->set_value( im_name = 'f3' im_value = 99 ).
ref_it->append( ref_wa ).
ref_wa->set_value( im_name = 'f1' im_value = 2 ).
ref_wa->set_value( im_name = 'f2' im_value = 'World' ).
ref_wa->set_value( im_name = 'f3' im_value = 88 ).
ref_it->append( ref_wa ).
ref_wa->set_value( im_name = 'f1' im_value = 3 ).
ref_wa->set_value( im_name = 'f2' im_value = 'Welcome' ).
ref_wa->set_value( im_name = 'f3' im_value = 69 ).
ref_it->append( ref_wa ).
ref_wa->set_value( im_name = 'f1' im_value = 4 ).
ref_wa->set_value( im_name = 'f2' im_value = 'Welcome' ).
ref_wa->set_value( im_name = 'f3' im_value = 69 ).
ref_it->append( ref_wa ).
ref_wa->set_value( im_name = 'f1' im_value = 2 ).
ref_wa->set_value( im_name = 'f2' im_value = 'World' ).
ref_wa->set_value( im_name = 'f3' im_value = 88 ).
ref_it->append( ref_wa ).
ref_it->append( ref_wa ).
ref_it->append( ref_wa ).
ref_it->append( ref_wa ).
ref_it->append( ref_wa ).
ref_it->append( ref_wa ).
ref_it->append( ref_wa ).
BREAK-POINT.
" sort
ref_it->sort( 'F2 ASCENDING F1 DESCENDING' ).
" define your WITH KEY
wa_withkey-field = 'F2'.
wa_withkey-value = 'Welcome'.
APPEND wa_withkey TO it_withkey[].
wa_withkey-field = 'F1'.
wa_withkey-value = 3.
APPEND wa_withkey TO it_withkey[].
BREAK-POINT.
ref_wa->clear( ).
" read table
ref_it->read_table(
EXPORTING
im_it_withkey = it_withkey
im_binarysearch = 'X'
IMPORTING
ex_into_object = ref_wa
).
BREAK-POINT.
" get original WORK AREA
ref_wa_data = ref_wa->get_ref_data( ).
ASSIGN ref_wa_data->* TO <wa>.
ref_it->modify( im_object = ref_wa
im_index = 1 ).
BREAK-POINT.