-
Notifications
You must be signed in to change notification settings - Fork 0
/
ZCL_GOS_ATTACHMENTS.abap
184 lines (137 loc) · 5.01 KB
/
ZCL_GOS_ATTACHMENTS.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
*----------------------------------------------------------------------*
* CLASS lcl_gos_attachments DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_gos_attachments DEFINITION.
PUBLIC SECTION.
TYPES:
BEGIN OF mty_s_borid.
INCLUDE TYPE borident.
TYPES attachments TYPE sgs_flag.
TYPES notes TYPE sgs_flag.
TYPES urls TYPE sgs_flag.
TYPES t_bitem TYPE bitem_t.
TYPES t_boritem TYPE bitem_t.
TYPES o_att_list TYPE REF TO cl_gos_attachments.
TYPES END OF mty_s_borid .
TYPES:
mty_t_borid TYPE STANDARD TABLE OF mty_s_borid WITH DEFAULT KEY .
DATA:
mt_objects TYPE TABLE OF mty_s_borid,
mo_services TYPE REF TO cl_gos_document_service,
mo_gos_att_list TYPE REF TO cl_gos_attachments.
METHODS:
constructor,
set_object
IMPORTING
is_object TYPE mty_s_borid OPTIONAL
it_objects TYPE mty_t_borid OPTIONAL,
get_attachments RETURNING value(rt_attachments) TYPE mty_t_borid,
get_object_content
IMPORTING
iv_docid TYPE so_entryid
RETURNING value(rv_content) TYPE string,
display_all
IMPORTING
iv_objkey TYPE swo_typeid.
ENDCLASS. "lcl_gos_attachments DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_gos_attachments IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_gos_attachments IMPLEMENTATION.
METHOD constructor.
CREATE OBJECT mo_services.
ENDMETHOD. "constructor
METHOD display_all.
DATA:
lo_mitem TYPE REF TO cl_container_item,
lo_bitem TYPE REF TO cl_browser_item.
FIELD-SYMBOLS: <ls_borid> TYPE mty_s_borid.
READ TABLE mt_objects ASSIGNING <ls_borid>
WITH KEY objkey = iv_objkey.
CHECK sy-subrc = 0.
IF <ls_borid>-o_att_list IS NOT BOUND.
CREATE OBJECT lo_mitem.
CALL METHOD lo_mitem->if_container_item~set_items
EXPORTING
it_bitem = <ls_borid>-t_boritem.
TRY.
lo_bitem ?= lo_mitem.
CATCH cx_sy_move_cast_error.
RETURN.
ENDTRY.
CREATE OBJECT <ls_borid>-o_att_list
EXPORTING
io_object = lo_bitem
ip_mode = 'D'
ip_notes = <ls_borid>-notes
ip_attachments = <ls_borid>-attachments
ip_urls = <ls_borid>-urls.
ENDIF.
<ls_borid>-o_att_list->display( ).
ENDMETHOD. "display_all
METHOD set_object.
IF is_object IS NOT INITIAL.
APPEND is_object TO mt_objects.
ELSE.
mt_objects = it_objects.
ENDIF.
ENDMETHOD. "set_object
METHOD get_attachments.
DATA: lo_boritem TYPE REF TO cl_sobl_bor_item,
ls_borident TYPE borident.
DATA: li_service TYPE REF TO if_link_service,
lo_service TYPE REF TO if_link_service,
lo_msgsrv TYPE REF TO cl_msg_al_linksrv,
lt_services TYPE lsrvc_t.
FIELD-SYMBOLS: <ls_borid> TYPE mty_s_borid.
CREATE OBJECT li_service TYPE cl_msg_al_linksrv.
APPEND li_service TO lt_services.
LOOP AT mt_objects ASSIGNING <ls_borid>.
CLEAR: ls_borident.
TRY.
lo_msgsrv ?= li_service.
CATCH cx_sy_move_cast_error.
RETURN.
ENDTRY.
lo_msgsrv->gp_attachments = <ls_borid>-attachments.
lo_msgsrv->gp_notes = <ls_borid>-notes.
lo_msgsrv->gp_urls = <ls_borid>-urls.
MOVE-CORRESPONDING <ls_borid> TO ls_borident.
CREATE OBJECT lo_boritem
EXPORTING
is_bor = ls_borident.
APPEND lo_boritem TO <ls_borid>-t_boritem.
READ TABLE lt_services INTO lo_service INDEX 1.
CHECK sy-subrc = 0.
CALL METHOD lo_service->get_item_links
EXPORTING
io_bitem = lo_boritem
ip_load_restriction = 0
IMPORTING
et_partner = <ls_borid>-t_bitem.
ENDLOOP.
rt_attachments = mt_objects.
ENDMETHOD. "get_attachments
METHOD get_object_content.
DATA lt_obj_content TYPE TABLE OF solisti1.
FIELD-SYMBOLS: <ls_conent> TYPE solisti1.
CALL FUNCTION 'SO_DOCUMENT_READ_API1'
EXPORTING
document_id = iv_docid
TABLES
object_content = lt_obj_content
EXCEPTIONS
document_id_not_exist = 1
operation_no_authorization = 2
x_error = 3
OTHERS = 4.
READ TABLE lt_obj_content ASSIGNING <ls_conent> INDEX 1.
IF sy-subrc = 0 AND <ls_conent>-line(5) = '&KEY&'.
rv_content = <ls_conent>-line+5.
ENDIF.
ENDMETHOD. "get_object_content
ENDCLASS. "lcl_gos_attachments IMPLEMENTATION