Quantcast
Channel: SCN : Document List - ABAP Development
Viewing all articles
Browse latest Browse all 935

Easing the pain in TMS - using transports of copies

$
0
0
Maybe you know the problem - QA queue is full of old requests, nobody
knows which one is relevant (sometimes the programmer isn't even
working for your company any more). The answer is transport of copies!
This way, you can test your programs in qa system without filling the qa
queue with requests - when your program is working, you release the
original request and import it in production.
Educating
programmers is the next step. But how about automation? SAP delivers
BAdI CTS_REQUEST_CHECK with method CHECK_BEFORE_RELEASE - just implement
it and you can do various checks before releasing requests. First you
have to check the transport type - just use a case condition:
  1. CASE type.
  2.        WHEN 'K' OR 'W'.

This way, only workbench and customizing requests are taken in account - the BAdI ignores everything else including tasks.

Creating transport of copies

First, you need a popup to decide whether changes are final: 

  1. CALL FUNCTION 'POPUP_TO_CONFIRM'
  2.              EXPORTING
  3.                titlebar       = 'Final?'
  4.                text_question  = 'Are your developments final?'
  5.                text_button_1  = 'Final'(001)
  6.                text_button_2  = 'ToC'(002)
  7.              IMPORTING
  8.                answer         = lv_answer
  9.              EXCEPTIONS
  10.                text_not_found = 1
  11.                OTHERS         = 2.

To create a new request, you can use FM TR_INSERT_REQUEST_WITH_TASKS:

  1. CALL FUNCTION 'TR_INSERT_REQUEST_WITH_TASKS'
  2.                  EXPORTING
  3.                    iv_type           = 'T'
  4.                    iv_text           = lv_new_text
  5.                    iv_owner          = owner
  6.                    iv_target         = tarsystem
  7.                  IMPORTING
  8.                    es_request_header = lv_request_header
  9.                    et_task_headers   = lv_task_headers
  10.                  EXCEPTIONS
  11.                    insert_failed     = 1
  12.                    enqueue_failed    = 2
  13.                    OTHERS            = 3.

T

stands for transport of copies, I create a new description with "[TvK]

<old text>" to see which transport was created by BAdI. owner and

tarsystem is taken from original request. Next step is to copy all

objects: 

  1. CALL FUNCTION 'TR_COPY_COMM'
  2.                    EXPORTING
  3.                      wi_dialog                = abap_false
  4.                      wi_trkorr_from           = request
  5.                      wi_trkorr_to             = lv_request_header-trkorr
  6.                      wi_without_documentation = abap_false
  7.                    EXCEPTIONS
  8.                      db_access_error          = 1
  9.                      trkorr_from_not_exist    = 2
  10.                      trkorr_to_is_repair      = 3
  11.                      trkorr_to_locked         = 4
  12.                      trkorr_to_not_exist      = 5
  13.                      trkorr_to_released       = 6
  14.                      user_not_owner           = 7
  15.                      no_authorization         = 8
  16.                      wrong_client             = 9
  17.                      wrong_category           = 10
  18.                      object_not_patchable     = 11
  19.                      OTHERS                   = 12.

TR_COPY_COMM copies all objects in background.

Releasing and importing the created transport

Next step is to release your request, ignoring object locks:

  1. CALL FUNCTION 'TRINT_RELEASE_REQUEST'
  2.                      EXPORTING
  3.                        iv_trkorr                   = lv_request_header-trkorr
  4.                        iv_dialog                   = ' '
  5.                        iv_without_locking          = 'X'
  6.                      IMPORTING
  7.                        es_request                  = lv_request
  8.                        et_deleted_tasks            = lt_deleted_tasks
  9.                        et_messages                 = lt_messages
  10.                      EXCEPTIONS
  11.                        cts_initialization_failure  = 1
  12.                        enqueue_failed              = 2
  13.                        no_authorization            = 3
  14.                        invalid_request             = 4
  15.                        request_already_released    = 5
  16.                        repeat_too_early            = 6
  17.                        object_lock_error           = 7
  18.                        object_check_error          = 8
  19.                        docu_missing                = 9
  20.                        db_access_error             = 10
  21.                        action_aborted_by_user      = 11
  22.                        export_failed               = 12
  23.                        execute_objects_check       = 13
  24.                        release_in_bg_mode          = 14
  25.                        release_in_bg_mode_w_objchk = 15
  26.                        error_in_export_methods     = 16
  27.                        object_lang_error           = 17
  28.                        OTHERS                      = 18.

Other standard FMs don't ignore object locks, so you need TRINT_RELEASE_REQUEST with the option iv_without_locking.Since adding to the target buffer can take some time, I advise to do a loop:

  1. DO 5 TIMES.
  2.                        CALL FUNCTION 'TRINT_GET_LOG_OVERVIEW'
  3.                          EXPORTING
  4.                            iv_request                = lv_request_header-trkorr
  5.                            iv_with_transport_targets = 'X'
  6.                          IMPORTING
  7.                            et_log_overview           = lt_log_overview.
  8.                        lv_check = 0.
  9.                        LOOP AT lt_log_overview INTO wa_log_overview WHERE sysnam = '<sys>' AND rc = 'W'.
  10.                        ENDLOOP.
  11.                        IF sy-subrc = 0.
  12.                          lv_check = 1.
  13.                        ENDIF.
  14.                        IF lv_check = 1.
  15.                          EXIT.
  16.                        ENDIF.
  17.                        WAIT UP TO 1 SECONDS.
  18.                      ENDDO.

When everything is fine, you can import the created request:

  1. CALL FUNCTION 'TMS_MGR_IMPORT_TR_REQUEST'
  2.                          EXPORTING
  3.                            iv_system                  = 'Q01'
  4.                            iv_request                 = lv_request_header-trkorr
  5.                            iv_ignore_cvers            = 'X'
  6.                            iv_monitor                 = ' '
  7.                            iv_verbose                 = ' '
  8.                          IMPORTING
  9.                            ev_tp_ret_code             = lv_trretcode
  10.                            es_exception               = wa_exception
  11.                          EXCEPTIONS
  12.                            read_config_failed         = 1
  13.                            table_of_requests_is_empty = 2
  14.                            OTHERS                     = 3.

Done!

Viewing all articles
Browse latest Browse all 935

Trending Articles