Saturday 9 September 2017

Adding multiple transport requests to import queue

Introduction

A good habit is to clean up import queues (STMS), so the overview of all that remains to be done is best. You can always search the histroy for what has been done.

SAP provides the menu function to remove already imported requests, and maybe soms old and obsolete transports, that have not been imported, from before the acceptation environments new client copy, can be removed also.

You might want to add requests again, of maybe a company provides you with a set of requests to add.

The STMS menu provides you with a on-at-a-time solution:

SAP ABAP Tutorials and Materials, SAP ABAP Certifications, SAP ABAP Guides

SAP ABAP Tutorials and Materials, SAP ABAP Certifications, SAP ABAP Guides

In this blog I will provide an ABAP solution to add multiple requests in a queue for an environment.

Solution


The function module that SAP used to add a request is:  TMS_MGR_FORWARD_TR_REQUEST.

A small ABAP around this function will help you:

*&---------------------------------------------------------------------*
*& Report  ZTMS_ADD_TO_IMPORT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT  ztms_add_to_import.

TABLES: tmsbuffer.
TABLES: tmscsys.

PARAMETERS: p_syst LIKE tmscsys-sysnam OBLIGATORY DEFAULT 'AEJ'.
SELECT-OPTIONS: s_req FOR tmsbuffer-trkorr .

DATA g_trkorr TYPE tmsbuffer-trkorr.

at SELECTION-SCREEN on s_req.
*--------------------------------------------------------------------*
   if  s_req is initial.
    check sy-ucomm <> '1'.
    message e000(38) with 'Selection obligatory'.
  endif.


START-OF-SELECTION.
*--------------------------------------------------------------------*

LOOP AT s_req WHERE sign = 'I' AND option = 'EQ'.

  g_trkorr = s_req-low.

  CALL FUNCTION 'TMS_MGR_FORWARD_TR_REQUEST'
    EXPORTING
      iv_request                       = g_trkorr
      iv_target                        = p_syst
*   IV_TARDOM                        =
   IV_TARCLI                        = sy-mandt
*   IV_SOURCE                        =
*   IV_SRCDOM                        =
*   IV_NO_DELIVERY                   =
*   IV_WRONG_POS                     =
   iv_import_again                  = 'X'
*   IV_MONITOR                       = 'X'
*   IV_VERBOSE                       =
*   IT_REQUESTS                      =
* IMPORTING
*   EV_DIFFERENT_GROUPS              =
*   EV_TP_RET_CODE                   =
*   EV_TP_ALOG                       =
*   EV_TP_SLOG                       =
*   EV_TP_PID                        =
*   ES_EXCEPTION                     =
*   ET_TP_FORWARDS                   =
* TABLES
*   TT_STDOUT                        =
 EXCEPTIONS
   read_config_failed               = 1
   table_of_requests_is_empty       = 2
   OTHERS                           = 3
            .
  IF sy-subrc <> 0.
    WRITE: / g_trkorr, 'ERROR' COLOR COL_NEGATIVE.

* Implement suitable error handling here
  ENDIF.

ENDLOOP.

Remarks


The order in which you provide the select-option with requests is also the order in which the requests are added to the import queue. However, if you already have certain transports in the queue, they are not removed first. You have to remove these first from the queue, so they can be added in the right order.

I have to mention that the order of transports is very important, because while importing SAP follows the list and imports later request over earlier.

3 comments:

  1. I need say thank you and thank you for writing this, helped me a lot.

    Keep blogging Pinto.

    ReplyDelete
  2. Very good program, i don't know how can i thank you :)

    ReplyDelete
  3. Thank you very very much dear Sabrina Pinto. You're a hero!

    ReplyDelete