Mit der Transaktion SMW0 können SAP Web Repository Objekte gepflegt werden. Die Transaktion ist sehr simpel und der Funktionsumfang reicht aus, solange man nur einzelne Objekte bearbeiten bzw. aktualisieren möchte. Sobald man aber eine ganze Fülle an Objekten bearbeiten möchte, steht man mit diesem Werkzeug schnell mal an.
Für die Massenbearbeitung habe ich ein kleines Programm geschrieben, mit dem sich mehrere Objekte auf einmal exportieren bzw. importieren lassen.
Kleine Anmerkung am Rande: Wer sich alle SAP Ikonen exportieren lassen möchte, kann dies mit diesem Report ebenfalls tun. Sämtliche SAP Ikonen befinden sich im Paket SWWW…
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 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | *&---------------------------------------------------------------------* *& Report Z_SMW0_TRANSFER * *& * *&---------------------------------------------------------------------* *& * *& * *&---------------------------------------------------------------------* report z_smw0_transfer . type-pools: vrm . data: lf_devc type devclass , lf_name type w3objid , lt_objects type standard table of wwwdatatab , lf_path_old type string , lf_path_new type string , lt_lb_values type vrm_values , lf_value , lt_data type standard table of w3mime , lf_param(255) , lf_filesize type i , lf_filename type string , lf_res type flag , lf_count type i , lt_files type table of file , lf_objid type w3objid , lf_subrc type sysubrc , lf_new type flag . field-symbols: <obj> type wwwdatatab , <lb_value> type vrm_value , <file> type file . selection-screen begin of block bl1 with frame title text-001. parameters: p_act as listbox visible length 20 default 'E' user-command dmy. select-options: p_devc for lf_devc , p_name for lf_name . parameters: p_path type char255 , p_overr as checkbox default 'X' , p_create as checkbox default '' , p_test as checkbox default 'X' . selection-screen end of block bl1. initialization. append initial line to lt_lb_values assigning <lb_value>. <lb_value>-key = 'E'. <lb_value>-text = 'Exportieren'. append initial line to lt_lb_values assigning <lb_value>. <lb_value>-key = 'I'. <lb_value>-text = 'Importieren'. call function 'VRM_SET_VALUES' exporting id = 'P_ACT' values = lt_lb_values exceptions others = 1. if sy-subrc <> 0. message id sy-msgid type 'A' number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. endif. at selection-screen on value-request for p_path. clear lf_path_old. call method cl_gui_frontend_services=>directory_browse exporting initial_folder = lf_path_old changing selected_folder = lf_path_new exceptions others = 1. check sy-subrc = 0 and not lf_path_new is initial. p_path = lf_path_new. at selection-screen output. loop at screen. if screen-name = 'P_OVERR'. if p_act = 'E'. screen-input = '1'. else. screen-input = '0'. endif. modify screen. elseif screen-name = 'P_CREATE'. if p_act = 'I'. screen-input = '1'. else. screen-input = '0'. endif. modify screen. endif. endloop. start-of-selection. if p_path is initial. message i008(/pronovia/basic) with 'Bitte wählen Sie einen Pfad'. exit. endif. perform check_slash_at_path_end in program /pronovia/saplsdf changing p_path. format color col_background intensified off. if p_act = 'E'. select * from wwwdata as f inner join tadir as p on f~objid = p~obj_name into corresponding fields of table lt_objects where f~srtf2 = 0 and f~relid = 'MI' and p~pgmid = 'R3TR' and p~object = 'W3MI' and p~devclass in p_devc and p~obj_name in p_name. loop at lt_objects assigning <obj>. write: / <obj>-devclass, <obj>-objid, <obj>-text. if p_test is initial. clear lt_data[]. * Get Filename call function 'WWWPARAMS_READ' exporting relid = <obj>-relid objid = <obj>-objid name = 'filename' importing value = lf_param exceptions others = 1. if sy-subrc = 0. call function 'CV120_SPLIT_FILE' exporting pf_file = lf_param importing pfx_dotextension = lf_param. concatenate <obj>-objid lf_param into lf_filename. translate lf_filename using '/¦'. concatenate p_path lf_filename into lf_filename. else. format color col_negative intensified on. write: / 'Fehler beim Lesen aus der Datenbank'. format color col_background intensified off. continue. endif. * Prüfen, ob Datei existiert if p_overr = space. call method cl_gui_frontend_services=>file_exist exporting file = lf_filename receiving result = lf_res exceptions others = 1. . if sy-subrc <> 0 or lf_res <> space. format color col_total intensified off. write: / 'Die Datei existiert bereits'. format color col_background intensified off. continue. endif. endif. call function 'WWWDATA_IMPORT' exporting key = <obj> tables mime = lt_data exceptions others = 1. if sy-subrc <> 0. format color col_negative intensified on. write: / 'Fehler beim Lesen aus der Datenbank'. format color col_background intensified off. continue. endif. * Get Filesize call function 'WWWPARAMS_READ' exporting relid = <obj>-relid objid = <obj>-objid name = 'filesize' importing value = lf_param exceptions others = 1. if sy-subrc = 0. lf_filesize = lf_param. else. format color col_negative intensified on. write: / 'Fehler beim Lesen aus der Datenbank'. format color col_background intensified off. continue. endif. call function 'GUI_DOWNLOAD' exporting bin_filesize = lf_filesize filename = lf_filename filetype = 'BIN' tables data_tab = lt_data exceptions others = 1. if sy-subrc <> 0. format color col_negative intensified on. write: / 'Fehler beim Schreiben der Datei'. format color col_background intensified off. continue. else. format color col_positive intensified on. write: / 'Datei wurde exportiert'. format color col_background intensified off. endif. endif. endloop. elseif p_act = 'I'. lf_path_new = p_path. call method cl_gui_frontend_services=>directory_list_files exporting directory = lf_path_new files_only = 'X' changing file_table = lt_files count = lf_count exceptions others = 1. if sy-subrc <> 0. message id sy-msgid type sy-msgty number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. exit. endif. loop at lt_files assigning <file>. lf_param = <file>. call function 'CV120_SPLIT_FILE' exporting pf_file = lf_param importing pfx_file = lf_param. lf_objid = lf_param. translate lf_objid using '¦/'. * Passt name? check lf_objid in p_name. * Gibt es die Datei im Repositoy und passt die DevClass select * from wwwdata as f inner join tadir as p on f~objid = p~obj_name into corresponding fields of table lt_objects up to 1 rows where f~srtf2 = 0 and f~relid = 'MI' and p~pgmid = 'R3TR' and p~object = 'W3MI' and p~devclass in p_devc and p~obj_name = lf_objid. if sy-subrc <> 0. if p_create = space. continue. else. lf_new = 'X'. append initial line to lt_objects assigning <obj>. <obj>-relid = 'MI'. <obj>-objid = lf_objid. endif. else. lf_new = space. endif. write: / lf_objid. check p_test = space. read table lt_objects assigning <obj> index 1. concatenate p_path <file> into lf_param. call function 'UPLOAD_WEB_OBJECT' exporting key = <obj> temp = lf_param importing rc = lf_subrc. if lf_subrc <> 0. format color col_negative intensified on. write: / 'Fehler beim Schreiben der Datenbank'. format color col_background intensified off. continue. else. format color col_positive intensified on. if lf_new = 'X'. write: / 'Objekt wurde neu angelegt und Datei wurde importiert'. else. write: / 'Datei wurde importiert'. endif. format color col_background intensified off. endif. endloop. endif. end-of-selection. |
