Mick
Mick

Reputation: 111

How to add a whole package to transport request by code?

My task is to do all these steps programmatically:

My problem is that I can manually add the package to the transport request via transaction SE03 and then release it with FM TR_RELEASE_REQUEST, but that is not the goal, everything from step 1 to 3 has to happen in one program execution if anyone can guide me how to do step 2 it would be very helpful, thanks in advance.

Upvotes: 1

Views: 2594

Answers (3)

Suncatcher
Suncatcher

Reputation: 10621

To add the whole project into request you must first select all the objects from package and add them one by one. You can do it like this:

DATA: l_trkorr  TYPE trkorr,
      l_package TYPE devclass VALUE 'ZPACKAGE'.

cl_pak_package_queries=>get_all_subpackages( EXPORTING im_package     = l_package
                                             IMPORTING et_subpackages = DATA(lt_descendant) ).

INSERT VALUE cl_pak_package_queries=>ty_subpackage_info( package = l_package ) INTO TABLE lt_descendant.

SELECT pgmid, object, obj_name FROM tadir
  INTO TABLE @DATA(lt_segw_objects)
   FOR ALL ENTRIES IN @lt_descendant
 WHERE devclass = @lt_descendant-package.

DATA(instance) = cl_adt_cts_management=>create_instance( ).

LOOP AT lt_segw_objects ASSIGNING FIELD-SYMBOL(<fs_obj>).
  TRY.
      instance->insert_objects_in_wb_request( EXPORTING pgmid        = <fs_obj>-pgmid
                                                        object       = <fs_obj>-object
                                                        obj_name     = CONV trobj_name( <fs_obj>-obj_name )
                                              IMPORTING result       = DATA(result)
                                                        request      = DATA(request)
                                              CHANGING  trkorr       = l_trkorr ).
    CATCH cx_adt_cts_insert_error.
  ENDTRY.
ENDLOOP.

Note, that you cannot add objects that are already locked in another request, it will give you cx_adt_cts_insert_error exception. There is no way to unlock objects programmatically, only via SE03 tool.

Upvotes: 1

Sandra Rossi
Sandra Rossi

Reputation: 13656

In your program, you must :

  • First get the list of objects which belong to the package, via the table TADIR (object in columns PGMID, OBJECT, OBJ_NAME, and package in column DEVCLASS)
  • And add these objects to the task or transport request via the non-released function modules TRINT_APPEND_COMM or TR_APPEND_TO_COMM_OBJS_KEYS.

Upvotes: 1

mkysoft
mkysoft

Reputation: 5758

You can check code behind, Write Transport Entry in SE80 right click on package menu.

Upvotes: 0

Related Questions