rfid. remove_exec

  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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
METHOD remove_exec .
DATA: lo_nd_rfid_table TYPE REF TO if_wd_context_node,
my_table TYPE REF TO data,
my_row TYPE REF TO data.
FIELD-SYMBOLS: <table> TYPE table,
<row> TYPE data,
<flight> TYPE sflight,
<ft_data> TYPE ANY TABLE.
DATA: node_info TYPE REF TO if_wd_context_node_info,
struct_type TYPE REF TO cl_abap_structdescr,
table_type TYPE REF TO cl_abap_tabledescr,
comp_tab TYPE cl_abap_structdescr=>component_table,
comp LIKE LINE OF comp_tab.
DATA lt_elem TYPE wdr_context_element_set.
DATA ls_elem LIKE LINE OF lt_elem.
DATA: lt_pobj_extid TYPE /ain/pub_pobj_extid_tab,
ls_pobj_extid LIKE LINE OF lt_pobj_extid,
lt_pobj_extid_link TYPE /ain/pub_pobj_extid_link_tab,
ls_pobj_extid_link TYPE /ain/pub_pobj_extid_link_str.
DATA:
lt_btd_obj_act_key TYPE /ain/pub_btd_obj_act_key_tab,
ls_btd_obj_act_key LIKE LINE OF lt_btd_obj_act_key.
DATA: lt_pobj_othattr TYPE /ain/pub_pobj_othattr_tab,
ls_pobj_othattr LIKE LINE OF lt_pobj_othattr.
DATA: lt_pobj_tab TYPE /ain/pub_pobj_intid_tab,
ls_pobj_tab TYPE /ain/pub_pobj_intid_str,
lt_pobj_id TYPE /ain/pub_pobj_id_tab,
ls_pobj_id TYPE /ain/pub_pobj_id_str.
DATA: lt_return TYPE bapirettab.
* navigate from <CONTEXT> to <RFID_TABLE> via lead selection
lo_nd_rfid_table = wd_context->get_child_node( name = wd_this->wdctx_rfid_table ).
node_info = lo_nd_rfid_table->get_node_info( ).
struct_type = node_info->get_static_attributes_type( ).
CREATE DATA my_row TYPE HANDLE struct_type.
table_type = cl_abap_tabledescr=>create( p_line_type = struct_type ).
CREATE DATA my_table TYPE HANDLE table_type.
ASSIGN my_table->* TO <table>.
* @TODO handle non existant child
* IF lo_nd_rfid_table IS INITIAL.
* ENDIF.
lo_nd_rfid_table->get_static_attributes_table( IMPORTING table = <table> ).
* LT_ELEM = get_elements_to_remove( ). "LO_ND_RFID_TABLE->GET_SELECTED_ELEMENTS( INCLUDING_LEAD_SELECTION = abap_true ).
lt_elem = lo_nd_rfid_table->get_elements( ).
IF lt_elem IS NOT INITIAL.
TRY.
LOOP AT lt_elem INTO ls_elem.
ls_elem->get_attribute( EXPORTING name = 'RFID' IMPORTING value = ls_pobj_extid-pobj_extid ).
APPEND ls_pobj_extid TO lt_pobj_extid.
ENDLOOP.
CATCH cx_root.
ENDTRY.
CALL FUNCTION '/AIN/PUB_POBJ_SIMPLEBY_EXTIDS'
TABLES
it_pobj_extid = lt_pobj_extid
et_pobj_extid_link = lt_pobj_extid_link
* ET_RETURN =
EXCEPTIONS
technical_level_error = 1
business_level_error_input = 2
OTHERS = 3.
IF sy-subrc = 0.
IF wd_this->mv_ms_flag IS NOT INITIAL.
LOOP AT lt_pobj_extid_link INTO ls_pobj_extid_link.
ls_btd_obj_act_key-btd_intid = btd_intid.
ls_btd_obj_act_key-pobj_intid = ls_pobj_extid_link-pobj_intid.
ls_btd_obj_act_key-action_type = 'MOVE'.
APPEND ls_btd_obj_act_key TO lt_btd_obj_act_key.
ls_pobj_tab-pobj_intid = ls_pobj_extid_link-pobj_intid.
APPEND ls_pobj_tab TO lt_pobj_tab.
ENDLOOP.
LOOP AT lt_pobj_tab INTO ls_pobj_tab.
ls_pobj_othattr-attribute_name = zcl_wd_assistance=>gc_pobj_attr_ms_btd_id.
ls_pobj_othattr-pobj_intid = ls_pobj_tab-pobj_intid.
ls_pobj_othattr-update_user = sy-uname.
CLEAR ls_pobj_othattr-attribute_value.
APPEND ls_pobj_othattr TO lt_pobj_othattr.
ENDLOOP.
CALL FUNCTION '/AIN/PUB_POBJ_OTHATT_MODIFY'
TABLES
it_pobj_othattr = lt_pobj_othattr
et_return = lt_return
EXCEPTIONS
technical_level_error = 1
business_level_error_input = 2
OTHERS = 3.
IF sy-subrc <> 0.
ev_msg = 'Ошибка модификации атрибутов метки'.
ENDIF.
ENDIF.
IF permanent IS NOT INITIAL.
LOOP AT lt_pobj_extid_link INTO ls_pobj_extid_link.
ls_btd_obj_act_key-btd_intid = btd_intid.
ls_btd_obj_act_key-pobj_intid = ls_pobj_extid_link-pobj_intid.
ls_btd_obj_act_key-action_type = 'MOVE'.
APPEND ls_btd_obj_act_key TO lt_btd_obj_act_key.
ls_pobj_tab-pobj_intid = ls_pobj_extid_link-pobj_intid.
APPEND ls_pobj_tab TO lt_pobj_tab.
ENDLOOP.
* CALL FUNCTION '/AIN/PUB_POBJ_BY_INTIDS'
* TABLES
* IT_POBJ_INTID = LT_POBJ_TAB
** ET_POBJ_HEADER = ET_POBJ_HEADER
* ET_POBJ_ID = LT_POBJ_ID
* ET_POBJ_OTHATTR = lt_pobj_othattr
* ET_RETURN = lt_return
** ET_POBJ_AGGR = ET_POBJ_AGGR
** ET_QCHAR_COMB =
* EXCEPTIONS
* TECHNICAL_LEVEL_ERROR = 1
* BUSINESS_LEVEL_ERROR_INPUT = 2
* OTHERS = 3.
* LOOP AT LT_POBJ_ID INTO LS_POBJ_ID.
LOOP AT lt_pobj_tab INTO ls_pobj_tab.
ls_pobj_othattr-pobj_intid = ls_pobj_tab-pobj_intid.
GET TIME STAMP FIELD ls_pobj_othattr-update_time .
ls_pobj_othattr-update_user = sy-uname.
ls_pobj_othattr-attribute_name = 'ZEXCLUDED'.
ls_pobj_othattr-attribute_value = 'B'.
APPEND ls_pobj_othattr TO lt_pobj_othattr.
* добавляем информацию о пользователе, услючающем метки
ls_pobj_othattr-attribute_name = 'ZEXCLUDE_BY'.
ls_pobj_othattr-attribute_value = sy-uname.
APPEND ls_pobj_othattr TO lt_pobj_othattr.
ls_pobj_othattr-attribute_name = 'ZEXCLUDE_TIME'.
ls_pobj_othattr-attribute_value = ls_pobj_othattr-update_time.
APPEND ls_pobj_othattr TO lt_pobj_othattr.
ENDLOOP.
* ENDLOOP.
CALL FUNCTION '/AIN/PUB_POBJ_OTHATT_MODIFY'
TABLES
it_pobj_othattr = lt_pobj_othattr
et_return = lt_return
EXCEPTIONS
technical_level_error = 1
business_level_error_input = 2
OTHERS = 3.
IF sy-subrc <> 0.
ev_msg = 'Ошибка модификации атрибутов метки'.
ENDIF.
ENDIF.
IF lt_btd_obj_act_key IS INITIAL.
LOOP AT lt_pobj_extid_link INTO ls_pobj_extid_link.
ls_btd_obj_act_key-btd_intid = btd_intid.
ls_btd_obj_act_key-pobj_intid = ls_pobj_extid_link-pobj_intid.
ls_btd_obj_act_key-action_type = 'MOVE'.
APPEND ls_btd_obj_act_key TO lt_btd_obj_act_key.
ENDLOOP.
ENDIF.
CALL FUNCTION '/AIN/PUB_BTD_DELETE'
TABLES
* IT_BTD_INTID = Lt_BTD_INTID
it_btd_obj_act_key = lt_btd_obj_act_key
et_return = lt_return
EXCEPTIONS
OTHERS = 1.
CALL FUNCTION '/AIN/PUB_BO_SAVE'
EXCEPTIONS
technical_level_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
ev_msg = 'Ошибка сохранения атрибутов метки'.
ENDIF.
ENDIF.
ELSE.
ev_msg = 'Для удаления не выбраны элементы'.
ENDIF.
wd_this->gv_res = ev_msg.
wd_this->fire_remove_rfid_evt( res = ev_msg ).
ENDMETHOD.