-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzcl_intfmonitor_data_container.clas.abap
More file actions
128 lines (98 loc) · 3.64 KB
/
Copy pathzcl_intfmonitor_data_container.clas.abap
File metadata and controls
128 lines (98 loc) · 3.64 KB
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
119
120
121
122
123
124
125
126
"! <p class="shorttext synchronized" lang="en">SAP Interface Monitor - Data container</p>
CLASS zcl_intfmonitor_data_container DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
TYPES:
"! <p class="shorttext synchronized" lang="en">Data</p>
BEGIN OF mtyp_s_data,
id TYPE string,
data_ref TYPE REF TO data,
obj_ref TYPE REF TO object,
type TYPE typename,
END OF mtyp_s_data .
TYPES:
"! <p class="shorttext synchronized" lang="en">DataContainer</p>
mtyp_t_data TYPE STANDARD TABLE OF mtyp_s_data WITH KEY id .
"! <p class="shorttext synchronized" lang="en">DataContainer</p>
DATA mt_data TYPE mtyp_t_data READ-ONLY .
"! <p class="shorttext synchronized" lang="en">Adds data to DataContainer</p>
"!
"! @exception error | <p class="shorttext synchronized" lang="en">Error</p>
METHODS add
IMPORTING
id_id TYPE string
id_data TYPE any
EXCEPTIONS
error .
"! <p class="shorttext synchronized" lang="en">Gets data from DataContainer</p>
"!
"! @parameter id_id | <p class="shorttext synchronized" lang="en">Parameter Id</p>
"! @parameter ed_data | <p class="shorttext synchronized" lang="en">Parameter valu</p>
"! @parameter ed_type | <p class="shorttext synchronized" lang="en">Name of Dictionary Type</p>
"! @parameter er_data | <p class="shorttext synchronized" lang="en">Reference to parameter value</p>
"! @exception not_found | <p class="shorttext synchronized" lang="en">Not Found</p>
"! @exception error | <p class="shorttext synchronized" lang="en">Error</p>
METHODS get
IMPORTING
id_id TYPE string
EXPORTING
ed_data TYPE any
ed_type TYPE typename
er_data TYPE REF TO data
EXCEPTIONS
not_found
error .
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zcl_intfmonitor_data_container IMPLEMENTATION.
METHOD add.
DATA: ls_data LIKE LINE OF mt_data.
READ TABLE mt_data WITH KEY id = id_id ASSIGNING FIELD-SYMBOL(<ls_data>).
IF sy-subrc IS NOT INITIAL.
ls_data-id = id_id.
INSERT ls_data INTO TABLE mt_data.
READ TABLE mt_data WITH KEY id = id_id ASSIGNING <ls_data>.
ENDIF.
DATA(lo_typedescr) = cl_abap_typedescr=>describe_by_data( p_data = id_data ).
IF lo_typedescr IS NOT BOUND.
"Unable to identify data
RAISE error.
ENDIF.
IF lo_typedescr->type_kind = cl_abap_typedescr=>typekind_oref.
TRY.
<ls_data>-obj_ref = id_data.
CATCH cx_root. "#EC CATCH_ALL
"Is not an object?! so it couldn't be typekind_oref!!!
RAISE error.
ENDTRY.
ELSE.
TRY.
<ls_data>-type = lo_typedescr->get_relative_name( ).
DATA(lo_datadescr) = CAST cl_abap_datadescr( lo_typedescr ).
CREATE DATA <ls_data>-data_ref TYPE HANDLE lo_datadescr.
ASSIGN <ls_data>-data_ref->* TO FIELD-SYMBOL(<ld_data>).
<ld_data> = id_data.
CATCH cx_root. "#EC CATCH_ALL
RAISE error.
ENDTRY.
ENDIF.
ENDMETHOD.
METHOD get.
READ TABLE mt_data WITH KEY id = id_id ASSIGNING FIELD-SYMBOL(<ls_data>).
IF sy-subrc IS NOT INITIAL.
RAISE error.
ELSE.
IF <ls_data>-obj_ref IS NOT INITIAL.
ed_data ?= <ls_data>-obj_ref.
ELSEIF <ls_data>-data_ref IS NOT INITIAL.
ASSIGN <ls_data>-data_ref->* TO FIELD-SYMBOL(<ld_data>).
ed_data = <ld_data>.
er_data = <ls_data>-data_ref.
ENDIF.
ed_type = <ls_data>-type.
ENDIF.
ENDMETHOD.
ENDCLASS.