Версия имеет шаблон X.X.X.XXXX
Номер версии в SMW0 (в моем случае) хранится в описании (wwwdata-text)
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 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
*&---------------------------------------------------------------------* *& Report ZUPLOAD_EXE_TO_SMW0 *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT zupload_exe_to_smw0. TYPE-POOLS ole2. PARAMETERS : p_fpath TYPE rlgrap-filename OBLIGATORY. AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fpath. PERFORM f4_file. START-OF-SELECTION. CONSTANTS : relid TYPE wwwdatatab-relid VALUE 'MI'. CONSTANTS : objid TYPE wwwdatatab-objid VALUE 'ZFILE'. **compare version DATA lv_file_version TYPE cntlstrinf-version. PERFORM get_version_from_file USING p_fpath CHANGING lv_file_version. IF lv_file_version IS INITIAL. WRITE : / 'Версия у файла отсутствует'. RETURN. ENDIF. DATA lv_current_version TYPE wwwdata-text. PERFORM get_current_version CHANGING lv_current_version. DATA lv_continue TYPE flag. PERFORM compare_versions USING lv_file_version lv_current_version CHANGING lv_continue. IF lv_continue IS INITIAL. WRITE : / 'Отменено'. RETURN. ENDIF. **upload to smw0 DATA ls_key TYPE wwwdatatab . ls_key-relid = relid . ls_key-objid = objid. ls_key-text = lv_file_version. DATA lv_version TYPE sy-subrc. CALL FUNCTION 'UPLOAD_WEB_OBJECT' EXPORTING key = ls_key temp = p_fpath IMPORTING rc = lv_version. IF sy-subrc = 0. WRITE : / 'success'. ELSE. WRITE : / 'error!'. ENDIF. *&---------------------------------------------------------------------* *& Form compare_versions *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->I_CURRENT_VER text * -->I_FILE_VER text *----------------------------------------------------------------------* FORM compare_versions USING i_current_ver TYPE any i_file_ver TYPE any CHANGING c_success TYPE flag. c_success = 'X'. DATA lv_absolute_equals TYPE flag. DATA lt_file_ver TYPE TABLE OF char128 WITH HEADER LINE. DATA lt_smw0_ver TYPE TABLE OF char128 WITH HEADER LINE. SPLIT i_current_ver AT '.' INTO TABLE lt_file_ver[]. SPLIT i_file_ver AT '.' INTO TABLE lt_smw0_ver[]. DESCRIBE TABLE lt_smw0_ver[]. DO sy-tfill TIMES. READ TABLE lt_file_ver INDEX sy-index. CHECK sy-subrc = 0. READ TABLE lt_smw0_ver INDEX sy-index. CHECK sy-subrc = 0. IF lt_file_ver < lt_smw0_ver. CLEAR c_success. ENDIF. IF lt_file_ver = lt_smw0_ver. lv_absolute_equals = 'X'. ELSE. CLEAR lv_absolute_equals. ENDIF. ENDDO. IF c_success IS INITIAL. DATA answer_loc TYPE char1. CLEAR answer_loc. CALL FUNCTION 'POPUP_TO_CONFIRM' EXPORTING text_question = 'Версия в загружаемом файле меньше, чем в SMW0. Продолжить?'(001) display_cancel_button = '' IMPORTING answer = answer_loc EXCEPTIONS text_not_found = 1 " ДА OTHERS = 2. " НЕТ IF answer_loc = '1'. c_success = 'X'. ENDIF. ENDIF. IF lv_absolute_equals = 'X'. CLEAR c_success. CLEAR answer_loc. CALL FUNCTION 'POPUP_TO_CONFIRM' EXPORTING text_question = 'Версии совпадают. Продолжить?'(002) display_cancel_button = '' IMPORTING answer = answer_loc EXCEPTIONS text_not_found = 1 " ДА OTHERS = 2. " НЕТ IF answer_loc = '1'. c_success = 'X'. ENDIF. ENDIF. ENDFORM. "compare_versions *&---------------------------------------------------------------------* *& Form compare_version *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* FORM get_current_version CHANGING c_version TYPE wwwdata-text. DATA key TYPE wwwdatatab. key-objid = objid. key-relid = relid. DATA wwwdata TYPE wwwdata. SELECT SINGLE * INTO wwwdata FROM wwwdata WHERE relid = key-relid AND objid = key-objid. c_version = wwwdata-text. ENDFORM. "compare_version *&---------------------------------------------------------------------* *& Form get_version *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->I_PATH text * -->C_VERSION text *----------------------------------------------------------------------* FORM get_version_from_file USING i_path TYPE rlgrap-filename CHANGING c_version TYPE cntlstrinf-version. CONSTANTS: get_version TYPE i VALUE 1. DATA: h_com1 TYPE ole2_object. CREATE OBJECT h_com1 'SAPINFO' NO FLUSH. CALL METHOD OF h_com1 'GetFileInfo' = c_version EXPORTING #1 = i_path #2 = get_version. ENDFORM. "get_version *&---------------------------------------------------------------------* *& Form f4_file *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* FORM f4_file. DATA lt_ft TYPE filetable. DATA lv_rc TYPE i. cl_gui_frontend_services=>file_open_dialog( EXPORTING * default_extension = 'Exe' file_filter = '(*.exe)|*.exe|' CHANGING file_table = lt_ft rc = lv_rc EXCEPTIONS file_open_dialog_failed = 1 cntl_error = 2 error_no_gui = 3 not_supported_by_gui = 4 OTHERS = 5 ). CHECK sy-subrc = 0. FIELD-SYMBOLS <ls_fpath> LIKE LINE OF lt_ft. READ TABLE lt_ft INDEX 1 ASSIGNING <ls_fpath>. CHECK sy-subrc = 0. p_fpath = <ls_fpath>. ENDFORM. "f4_file |