method AIN IF_ACTIVITY EXECUTE data lv_prefix TYPE string data lv_chec

  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
method /AIN/IF_ACTIVITY~EXECUTE.
data: lv_prefix TYPE string.
data: lv_check_part TYPE string.
data: lv_prefix_len TYPE i.
data lv_msg TYPE string.
data:
* lt_obs TYPE /AIN/ACTIVITY_OBSERVATION_TAB,
* ls_obs LIKE LINE OF lt_obs,
lt_epcdata TYPE /AIN/ACTIVITY_EPC_DATA_TAB,
ls_epcdata LIKE LINE OF LT_EPCDATA,
lt_ctx_epclist TYPE /AIN/ACTIVITY_CTX_EPC_TAB,
ls_ctx_epclist LIKE LINE OF LT_CTX_EPCLIST,
lv_was_ok TYPE BOOLEAN,
lv_was_ex TYPE BOOLEAN,
lv_assign_check_off TYPE boolean.
data ls_tdocassign TYPE /AIN/TDOCASSIGN.
field-symbols: <ls_parameter> like line of it_parameter.
FIELD-SYMBOLS <msg> TYPE /AIN/ACTIVITY_MSG_SENSOR_STR.
FIELD-SYMBOLS <fs_obs> like <msg>-OBSERVATION.
FIELD-SYMBOLS <fs_obs_line> like LINE OF <fs_obs>.
FIELD-SYMBOLS <fs_epc_data> like <FS_OBS_LINE>-EPC_DATA.
FIELD-SYMBOLS <fs_epc_data_line> like line of <FS_EPC_DATA>.
FIELD-SYMBOLS <fs_context> like cs_context.
ASSIGN is_msg->* to <msg>.
ASSIGN CS_CONTEXT to <FS_CONTEXT>.
* lt_obs = <msg>-OBSERVATION.
loop at it_parameter assigning <ls_parameter>.
case <ls_parameter>-param_name.
when GC_PREFIX_TO_CHECK.
LV_PREFIX = <LS_PARAMETER>-PARAM_VALUE.
LV_PREFIX_LEN = strlen( LV_PREFIX ).
when GC_ASSIGN_CHECK_OFF.
LV_ASSIGN_CHECK_OFF = <LS_PARAMETER>-PARAM_VALUE.
endcase.
endloop.
IF LV_PREFIX is NOT INITIAL.
LOOP AT <msg>-OBSERVATION ASSIGNING <FS_OBS_LINE>.
* We do this check because of violent behavior possibility
IF LV_ASSIGN_CHECK_OFF ne abap_true.
select SINGLE * from /AIN/TDOCASSIGN INTO LS_TDOCASSIGN WHERE DEVGRP_ID = <FS_OBS_LINE>-DEVGRP_ID.
IF sy-SUBRC is NOT INITIAL.
LOOP AT <FS_OBS_LINE>-EPC_DATA INTO LS_EPCDATA.
delete table <FS_OBS_LINE>-EPC_DATA from LS_EPCDATA.
ENDLOOP.
ENDIF.
ENDIF.
LOOP AT <FS_OBS_LINE>-EPC_DATA ASSIGNING <FS_EPC_DATA_LINE>.
IF strlen( <FS_EPC_DATA_LINE>-EPC ) >= LV_PREFIX_LEN.
LV_CHECK_PART = <FS_EPC_DATA_LINE>-EPC.
* CONCATENATE <FS_EPC_DATA_LINE>-EPC LV_MSG INTO LV_MSG SEPARATED BY ','.
* LV_CHECK_PART = LV_CHECK_PART(LV_PREFIX_LEN).
data lv_len TYPE i.
data lv_off TYPE i.
FIND REGEX LV_PREFIX IN LV_CHECK_PART MATCH OFFSET LV_OFF MATCH LENGTH LV_LEN.
* IF LV_CHECK_PART ne LV_PREFIX.
if not sy-subrc = 0.
APPEND <FS_EPC_DATA_LINE> to LT_EPCDATA.
ENDIF.
ENDIF.
ENDLOOP.
IF LT_EPCDATA is NOT INITIAL.
data lv_src_lines TYPE i.
data lv_dest_lines TYPE i.
DESCRIBE TABLE LT_EPCDATA LINES LV_DEST_LINES.
DESCRIBE TABLE <FS_OBS_LINE>-EPC_DATA LINES LV_SRC_LINES.
IF LV_DEST_LINES = LV_SRC_LINES.
LV_WAS_EX = abap_true.
else.
LV_WAS_OK = abap_true.
ENDIF.
LOOP AT LT_EPCDATA INTO LS_EPCDATA.
DELETE <FS_CONTEXT>-EPCLIST WHERE EPC = LS_EPCDATA-EPC.
DELETE <FS_OBS_LINE>-EPC_DATA WHERE EPC = LS_EPCDATA-EPC.
ENDLOOP.
else.
LV_WAS_OK = abap_true.
ENDIF.
ENDLOOP.
ENDIF.
IF LV_WAS_ok is INITIAL.
EV_STATUS = /AIN/CL_ACTIVITY_C=>STATUS_EXIT.
ELSE.
* CALL METHOD IO_LOG->ADD_MESSAGE
* EXPORTING
* I_MSGTY = /ain/cl_c=>info
* I_MSGNO = '016'
* I_MSGV1 = lv_msg.
ENDIF.
endmethod.