ABAP Blog Posts
cancel
Showing results for 
Search instead for 
Did you mean: 
Sandra_Rossi
Active Contributor
865

I have created this program in a system with ABAP 7.58 to transport the objects from many packages + include objects from additional transport requests.

For one or few packages, it's best to transport manually via official SE80 > Select package > Context menu "Write transport request".

It was developed quick & dirty.

It's not using any official API, so use it at your own risk.

The only screen:

Sandra_Rossi_3-1760711732980.png

For information, this program relies on the code triggered via SE80 for one package:

Sandra_Rossi_0-1760708594427.png

Happy transport!

Sandra

Here is the code. I have indicated from which subroutines I have copied the code.

 

REPORT z_transport_many_packages.

DATA gv_devclass TYPE tadir-devclass.
DATA gv_trkorr   TYPE e070-trkorr.

SELECTION-SCREEN BEGIN OF BLOCK source WITH FRAME TITLE text_001.
  SELECT-OPTIONS s_devcla FOR gv_devclass.
  SELECT-OPTIONS s_trkorr FOR gv_trkorr.
SELECTION-SCREEN END OF BLOCK source.

SELECTION-SCREEN BEGIN OF BLOCK target WITH FRAME TITLE text_002.
  PARAMETERS p_trkorr TYPE trkorr.
SELECTION-SCREEN END OF BLOCK target.

INITIALIZATION.
  text_001 = 'Source'(001).
  text_002 = 'Target'(002).
  %_S_DEVCLA_%_APP_%-TEXT = 'Packages to transport'(003).
  %_S_TRKORR_%_APP_%-TEXT = 'TRs to include in transport'(004).
  %_P_TRKORR_%_APP_%-TEXT = 'Target Transport Request'(005).

START-OF-SELECTION.
  IF s_devcla IS NOT INITIAL.
    SELECT devclass
      FROM tdevc
      WHERE devclass IN @s_devcla
      INTO TABLE @DATA(gt_tdevc).
  ENDIF.

  IF s_trkorr IS NOT INITIAL.
    SELECT trkorr
      FROM e070
      WHERE trkorr IN @s_trkorr
      INTO TABLE @DATA(gt_e070).
  ENDIF.

  LOOP AT gt_tdevc REFERENCE INTO DATA(ls_tdevc).

    " Code from subroutine TRANSPORT_DEVCLASS_OBJECTS of program SAPLSEAP
    " (called by subroutine TRANSPORT_OBJECT_PART_2 of program SAPLSEAP,
    "  itself called by subroutine TRANSPORT_OBJECT_PART_1 of program SAPLSEAP)
    DATA(l_tadir_objs) = VALUE scts_tadir( ).
    CALL FUNCTION 'TRINT_SELECT_OBJECTS'
      EXPORTING  iv_devclass              = ls_tdevc->devclass
                 iv_only_existing_objects = abap_false
                 iv_via_selscreen         = abap_false
      IMPORTING
                 et_objects_tadir         = l_tadir_objs
      EXCEPTIONS cancelled_by_user        = 1
                 invalid_input            = 2
                 OTHERS                   = 3.
    IF sy-subrc <> 0.
      MESSAGE 'Error in TRINT_SELECT_OBJECTS' TYPE 'S' DISPLAY LIKE 'E'.
      STOP.
    ENDIF.
    DATA l_e071_obj TYPE trwbo_s_e071.
    DATA l_ddlname  TYPE ddlname.
    DATA l_objects  TYPE trwbo_t_e071.
    LOOP AT l_tadir_objs ASSIGNING FIELD-SYMBOL(<l_tadir_obj>) WHERE object <> 'STOB'.
      IF <l_tadir_obj>-object = 'VIEW'.
        CLEAR l_ddlname.
        PERFORM get_ddl_source USING    <l_tadir_obj>-obj_name
                               CHANGING l_ddlname.
        IF l_ddlname IS NOT INITIAL.
          CONTINUE.
        ENDIF.
      ENDIF.

      l_e071_obj-pgmid    = <l_tadir_obj>-pgmid.
      l_e071_obj-object   = <l_tadir_obj>-object.
      l_e071_obj-obj_name = <l_tadir_obj>-obj_name.
      APPEND l_e071_obj TO l_objects.
    ENDLOOP.
  ENDLOOP.

  " Code from TRANSPORT_OBJECT_PART_1
  IF l_objects IS NOT INITIAL.
    DATA l_suppress_dialog TYPE trparflag VALUE space.
    DATA l_es_request      TYPE trwbo_request_header.

    IF p_trkorr IS NOT INITIAL.
      l_suppress_dialog = 'X'.
    ENDIF.
    CALL FUNCTION 'TR_REQUEST_CHOICE'
      EXPORTING
                 iv_suppress_dialog   = l_suppress_dialog
                 it_e071              = l_objects
                 iv_request           = p_trkorr
      IMPORTING
                 es_request           = l_es_request
      EXCEPTIONS
                 invalid_request      = 1
                 invalid_request_type = 2
                 user_not_owner       = 3
                 no_objects_appended  = 4
                 enqueue_error        = 5
                 cancelled_by_user    = 6
                 recursive_call       = 7
                 OTHERS               = 8.
    IF sy-subrc = 0.
      p_trkorr = l_es_request-trkorr.
      IF l_suppress_dialog IS NOT INITIAL.
        MESSAGE s033(to) WITH l_es_request-trkorr.
      ENDIF.
    ELSE.
      IF p_trkorr IS NOT INITIAL.
        " do it again with dialog enabled:
        CALL FUNCTION 'TR_REQUEST_CHOICE'
          EXPORTING
                     it_e071              = l_objects
                     iv_request           = p_trkorr
          IMPORTING
                     es_request           = l_es_request
          EXCEPTIONS
                     invalid_request      = 1
                     invalid_request_type = 2
                     user_not_owner       = 3
                     no_objects_appended  = 4
                     enqueue_error        = 5
                     cancelled_by_user    = 6
                     recursive_call       = 7
                     OTHERS               = 8.
      ENDIF.
      IF sy-subrc = 0.
        p_trkorr = l_es_request-trkorr.
        MESSAGE s033(to) WITH l_es_request-trkorr.
      ELSE.
        MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        STOP.
      ENDIF.
    ENDIF.
  ELSE.
    MESSAGE s604(eu).
  ENDIF.

  " Subroutine COPY_OBJECT_LIST of program SAPLSTRH
  LOOP AT gt_e070 REFERENCE INTO DATA(ls_e070).
    CALL FUNCTION 'TR_COPY_COMM'
      EXPORTING  wi_dialog                = 'X'
                 wi_trkorr_from           = ls_e070->trkorr
                 wi_trkorr_to             = p_trkorr
                 wi_without_documentation = abap_false
      EXCEPTIONS OTHERS                   = 1.
    IF sy-subrc <> 0.
      MESSAGE 'Error in TR_COPY_COMM' TYPE 'S' DISPLAY LIKE 'E'.
      STOP.
    ENDIF.
  ENDLOOP.

  COMMIT WORK.

FORM get_ddl_source USING    p_viewname TYPE csequence
                    CHANGING p_ddlname  TYPE ddlname.

  DATA handler TYPE REF TO if_dd_ddl_handler.

  TRY.
      handler = cl_dd_ddl_handler_factory=>create( ).
      p_ddlname = handler->get_ddl_name_4_dd_artefact( CONV ddobjname( p_viewname ) ).
    CATCH cx_dd_ddl_exception ##NO_HANDLER.
  ENDTRY.
ENDFORM.

 

 

3 Comments
OlegBash
Active Participant
0 Kudos

Thank you for sharing. it is good idea to collect objects into ToC by package.

as I understood you are not going to put it into separate github-repository?
if yes, then could you please allow me to put it into this repo (it is also about transporting of copies, but by transport request only)?

Sandra_Rossi
Active Contributor

@OlegBash

It was faster for me to post here first, maybe I'll post to GitHub later.

Thanks for asking. Granted. I'm not sure I can say it's my property though, I didn't ask SAP the authorization to copy and adapt their code.

PS: I'm wondering what are the legal terms for property of what's posted by people and what's copied and adapted from SAP code. Terms of use - 9. INTELLECTUAL PROPERTY RIGHTS: "All Intellectual Proprietary Rights in and to any SAP Software, the SAP Websites, SAP Materials, and User Content belongs exclusively to SAP or the original submitting individual or entity ."

OlegBash
Active Participant
0 Kudos

Thank you! 

Top kudoed authors