-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzcl_bapi_protocol.clas.abap
140 lines (107 loc) · 3.52 KB
/
zcl_bapi_protocol.clas.abap
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
CLASS zcl_bapi_protocol DEFINITION PUBLIC FINAL CREATE PRIVATE.
PUBLIC SECTION.
INTERFACES zif_bapi_protocol.
ALIASES messages_types FOR zif_bapi_protocol~messages_types.
ALIASES contains_errors FOR zif_bapi_protocol_reader~contains_errors.
ALIASES contains_aborts FOR zif_bapi_protocol_reader~contains_aborts.
CLASS-METHODS create_for_read_write
IMPORTING
identifier TYPE string OPTIONAL
protocol TYPE any
RETURNING
VALUE(result) TYPE REF TO zif_bapi_protocol
RAISING
zcx_bapi_protocol.
CLASS-METHODS create_for_read
IMPORTING
identifier TYPE string OPTIONAL
protocol TYPE any
RETURNING
VALUE(result) TYPE REF TO zif_bapi_protocol_reader
RAISING
zcx_bapi_protocol.
METHODS constructor
IMPORTING
identifier TYPE string OPTIONAL
protocol TYPE any
RAISING
zcx_bapi_protocol.
PROTECTED SECTION.
PRIVATE SECTION.
DATA identifier TYPE string.
DATA timestamp TYPE timestampl.
DATA protocol TYPE bapirettab.
METHODS set_protocol_via_rtti
IMPORTING
protocol TYPE any
RAISING
zcx_bapi_protocol.
ENDCLASS.
CLASS zcl_bapi_protocol IMPLEMENTATION.
METHOD constructor.
me->identifier = identifier.
set_protocol_via_rtti( protocol ).
GET TIME STAMP FIELD timestamp.
ENDMETHOD.
METHOD create_for_read_write.
result = NEW zcl_bapi_protocol( identifier = identifier
protocol = protocol ).
ENDMETHOD.
METHOD zif_bapi_protocol_reader~contains_errors.
result = xsdbool( line_exists( protocol[ type = messages_types-error ] ) ).
ENDMETHOD.
METHOD zif_bapi_protocol_reader~contains_warnings.
result = xsdbool( line_exists( protocol[ type = messages_types-warning ] ) ).
ENDMETHOD.
METHOD zif_bapi_protocol_reader~get_entries.
result = protocol.
ENDMETHOD.
METHOD zif_bapi_protocol_reader~contains_aborts.
result = xsdbool( line_exists( protocol[ type = messages_types-abort ] ) ).
ENDMETHOD.
METHOD zif_bapi_protocol_reader~count_entries.
result = lines( protocol ).
ENDMETHOD.
METHOD zif_bapi_protocol_reader~get_entries_by_message_type.
LOOP AT protocol INTO DATA(line) WHERE type = message_type.
APPEND line TO result.
ENDLOOP.
ENDMETHOD.
METHOD zif_bapi_protocol_reader~contains_problems.
IF contains_errors( ).
result = abap_true.
ELSEIF contains_aborts( ).
result = abap_true.
ENDIF.
ENDMETHOD.
METHOD zif_bapi_protocol_reader~get_identifier.
result = identifier.
ENDMETHOD.
METHOD zif_bapi_protocol_reader~get_timestamp.
result = timestamp.
ENDMETHOD.
METHOD zif_bapi_protocol_writer~append_entries.
APPEND LINES OF entries TO me->protocol.
ENDMETHOD.
METHOD zif_bapi_protocol_writer~clear_entries.
CLEAR protocol.
ENDMETHOD.
METHOD create_for_read.
result = NEW zcl_bapi_protocol( identifier = identifier
protocol = protocol ).
ENDMETHOD.
METHOD zif_bapi_protocol_writer~append_entry.
APPEND line TO protocol.
ENDMETHOD.
METHOD set_protocol_via_rtti.
DATA(type_description) = cl_abap_typedescr=>describe_by_data( protocol ).
CASE type_description->get_relative_name( ).
WHEN 'BAPIRETTAB'.
me->protocol = protocol.
WHEN 'BAPIRET2'.
me->protocol = VALUE bapirettab( ( protocol ) ).
WHEN OTHERS.
RAISE EXCEPTION NEW zcx_bapi_protocol( ).
ENDCASE.
ENDMETHOD.
ENDCLASS.