Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | CLASS zcl_abapgit_sap_package DEFINITION PUBLIC CREATE PRIVATE GLOBAL FRIENDS zcl_abapgit_factory . PUBLIC SECTION. INTERFACES zif_abapgit_sap_package . METHODS constructor IMPORTING !iv_package TYPE devclass . PROTECTED SECTION. PRIVATE SECTION. DATA: mv_package TYPE devclass. METHODS get_transport_layer RETURNING VALUE(rv_transport_layer) TYPE devlayer RAISING zcx_abapgit_exception . ENDCLASS. CLASS zcl_abapgit_sap_package IMPLEMENTATION. METHOD constructor. mv_package = iv_package. ENDMETHOD. METHOD zif_abapgit_sap_package~are_changes_recorded_in_tr_req. DATA: li_package TYPE REF TO if_package. cl_package_factory=>load_package( EXPORTING i_package_name = mv_package IMPORTING e_package = li_package EXCEPTIONS object_not_existing = 1 unexpected_error = 2 intern_err = 3 no_access = 4 object_locked_and_modified = 5 OTHERS = 6 ). CASE sy-subrc. WHEN 0. rv_are_changes_rec_in_tr_req = li_package->wbo_korr_flag. WHEN 1. " For new packages, derive from package name rv_are_changes_rec_in_tr_req = boolc( mv_package(1) <> '$' AND mv_package(1) <> 'T' ). WHEN OTHERS. zcx_abapgit_exception=>raise_t100( ). ENDCASE. ENDMETHOD. METHOD zif_abapgit_sap_package~create. DATA: lv_err TYPE string, li_package TYPE REF TO if_package, ls_package TYPE scompkdtln. ASSERT NOT is_package-devclass IS INITIAL. cl_package_factory=>load_package( EXPORTING i_package_name = is_package-devclass EXCEPTIONS object_not_existing = 1 unexpected_error = 2 intern_err = 3 no_access = 4 object_locked_and_modified = 5 ). IF sy-subrc = 0. " Package already exists. We assume this is fine. Its properties might be changed later at " DEVC deserialization. RETURN. ENDIF. MOVE-CORRESPONDING is_package TO ls_package. " Set software component to 'HOME' if none is set at this point. " Otherwise SOFTWARE_COMPONENT_INVALID will be raised. IF ls_package-dlvunit IS INITIAL. ls_package-dlvunit = 'HOME'. ENDIF. " For transportable packages, get default transport and layer IF ls_package-devclass(1) <> '$' AND ls_package-pdevclass IS INITIAL. ls_package-pdevclass = get_transport_layer( ). ENDIF. cl_package_factory=>create_new_package( EXPORTING i_reuse_deleted_object = abap_true * i_suppress_dialog = abap_true " does not exist in 730 IMPORTING e_package = li_package CHANGING c_package_data = ls_package EXCEPTIONS object_already_existing = 1 object_just_created = 2 not_authorized = 3 wrong_name_prefix = 4 undefined_name = 5 reserved_local_name = 6 invalid_package_name = 7 short_text_missing = 8 software_component_invalid = 9 layer_invalid = 10 author_not_existing = 11 component_not_existing = 12 component_missing = 13 prefix_in_use = 14 unexpected_error = 15 intern_err = 16 no_access = 17 * invalid_translation_depth = 18 * wrong_mainpack_value = 19 * superpackage_invalid = 20 * error_in_cts_checks = 21 OTHERS = 18 ). IF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. li_package->save( * EXPORTING * i_suppress_dialog = abap_true " Controls whether popups can be transmitted EXCEPTIONS object_invalid = 1 object_not_changeable = 2 cancelled_in_corr = 3 permission_failure = 4 unexpected_error = 5 intern_err = 6 OTHERS = 7 ). IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 INTO lv_err. " Here we have to delete the package, " otherwise it would remain in the memory " and cannot created again in this session. li_package->delete( EXCEPTIONS object_not_empty = 1 object_not_changeable = 2 object_invalid = 3 intern_err = 4 OTHERS = 5 ). zcx_abapgit_exception=>raise( lv_err ). ENDIF. li_package->set_changeable( abap_false ). ENDMETHOD. METHOD zif_abapgit_sap_package~create_child. DATA: li_parent TYPE REF TO if_package, ls_child TYPE zif_abapgit_sap_package=>ty_create. cl_package_factory=>load_package( EXPORTING i_package_name = mv_package IMPORTING e_package = li_parent EXCEPTIONS object_not_existing = 1 unexpected_error = 2 intern_err = 3 no_access = 4 object_locked_and_modified = 5 ). IF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. ls_child-devclass = iv_child. ls_child-dlvunit = li_parent->software_component. ls_child-component = li_parent->application_component. ls_child-ctext = iv_child. ls_child-parentcl = mv_package. ls_child-pdevclass = li_parent->transport_layer. ls_child-as4user = sy-uname. zif_abapgit_sap_package~create( ls_child ). ENDMETHOD. METHOD zif_abapgit_sap_package~create_local. DATA: ls_package TYPE zif_abapgit_sap_package=>ty_create. ls_package-devclass = mv_package. ls_package-ctext = mv_package. ls_package-parentcl = '$TMP'. ls_package-dlvunit = 'LOCAL'. ls_package-as4user = sy-uname. zif_abapgit_sap_package~create( ls_package ). ENDMETHOD. METHOD zif_abapgit_sap_package~exists. cl_package_factory=>load_package( EXPORTING i_package_name = mv_package EXCEPTIONS object_not_existing = 1 unexpected_error = 2 intern_err = 3 no_access = 4 object_locked_and_modified = 5 ). rv_bool = boolc( sy-subrc <> 1 ). ENDMETHOD. METHOD get_transport_layer. " Get default transport layer CALL FUNCTION 'TR_GET_TRANSPORT_TARGET' EXPORTING iv_use_default = abap_true iv_get_layer_only = abap_true IMPORTING ev_layer = rv_transport_layer EXCEPTIONS wrong_call = 1 invalid_input = 2 cts_initialization_failure = 3 OTHERS = 4. IF sy-subrc <> 0. " Return empty layer (i.e. "local workbench request" for the package) CLEAR rv_transport_layer. ENDIF. ENDMETHOD. METHOD zif_abapgit_sap_package~get_transport_type. DATA: lv_pkg_name TYPE e071-obj_name, lv_obj_name TYPE tadir-obj_name, lv_role TYPE trnrole. lv_pkg_name = mv_package. lv_obj_name = mv_package. CALL FUNCTION 'TR_GET_REQUEST_TYPE' EXPORTING iv_pgmid = 'R3TR' iv_object = 'DEVC' iv_obj_name = lv_pkg_name IMPORTING ev_request_type = rs_transport_type-request ev_task_type = rs_transport_type-task EXCEPTIONS no_request_needed = 1 invalid_object = 2 system_error = 3 OTHERS = 4. CASE sy-subrc. WHEN 0 OR 1. RETURN. WHEN 2. " For new packages, set to workbench request rs_transport_type-request = 'K'. CALL FUNCTION 'TR_GET_NAMESPACE_AND_ROLE' EXPORTING iv_pgmid = 'R3TR' iv_object = 'DEVC' iv_objname = lv_obj_name IMPORTING ev_role = lv_role EXCEPTIONS namespace_not_existing = 1 invalid_object = 2 namespace_not_determinable = 3 OTHERS = 4. IF sy-subrc = 0 AND lv_role = 'C'. " Namespace with repair license requires repair task rs_transport_type-task = 'R'. ELSE. " Otherwise use correction task rs_transport_type-task = 'S'. ENDIF. WHEN OTHERS. zcx_abapgit_exception=>raise_t100( ). ENDCASE. ENDMETHOD. METHOD zif_abapgit_sap_package~list_subpackages. DATA: lt_list LIKE rt_list. SELECT devclass FROM tdevc INTO TABLE lt_list WHERE parentcl = mv_package ORDER BY PRIMARY KEY. "#EC CI_SUBRC "#EC CI_GENBUFF rt_list = lt_list. WHILE lines( lt_list ) > 0. SELECT devclass FROM tdevc INTO TABLE lt_list FOR ALL ENTRIES IN lt_list WHERE parentcl = lt_list-table_line ORDER BY PRIMARY KEY. "#EC CI_SUBRC "#EC CI_GENBUFF APPEND LINES OF lt_list TO rt_list. ENDWHILE. ENDMETHOD. METHOD zif_abapgit_sap_package~list_superpackages. DATA: lt_list LIKE rt_list, lv_parent TYPE tdevc-parentcl. APPEND mv_package TO rt_list. lv_parent = zif_abapgit_sap_package~read_parent( ). IF sy-subrc = 0 AND NOT lv_parent IS INITIAL. lt_list = zcl_abapgit_factory=>get_sap_package( lv_parent )->list_superpackages( ). APPEND LINES OF lt_list TO rt_list. ENDIF. ENDMETHOD. METHOD zif_abapgit_sap_package~read_description. SELECT SINGLE ctext FROM tdevct INTO rv_description WHERE devclass = mv_package AND spras = sy-langu ##SUBRC_OK. ENDMETHOD. METHOD zif_abapgit_sap_package~read_parent. SELECT SINGLE parentcl FROM tdevc INTO rv_parentcl WHERE devclass = mv_package. "#EC CI_GENBUFF IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |Inconsistent package structure! Cannot find parent for { mv_package }| ). ENDIF. ENDMETHOD. METHOD zif_abapgit_sap_package~read_responsible. SELECT SINGLE as4user FROM tdevc INTO rv_responsible WHERE devclass = mv_package ##SUBRC_OK. "#EC CI_GENBUFF ENDMETHOD. METHOD zif_abapgit_sap_package~validate_name. IF mv_package IS INITIAL. zcx_abapgit_exception=>raise( 'Package name must not be empty' ). ENDIF. IF mv_package = '$TMP'. zcx_abapgit_exception=>raise( 'It is not possible to use $TMP, use a different (local) package' ). ENDIF. " Check if package name is allowed cl_package_helper=>check_package_name( EXPORTING i_package_name = mv_package EXCEPTIONS undefined_name = 1 wrong_name_prefix = 2 reserved_local_name = 3 invalid_package_name = 4 ). IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |Package name { mv_package } is not valid| ). ENDIF. ENDMETHOD. ENDCLASS. |