Skip to Content

Hello Everyone,

 

Many Times we face a issue where we need to capture the Table entries in a TR to move it across the SAP client. I also faced the similar issue and hence I thought rather than doing it manually lets write a code to make it work.

In this blog I am explaining a way to capture the Table entries for the table in TR using code.

 

For our example we will try to capture the entries of T012K(House Bank Accounts) Table

Step 1) Create a WorkBench TR and keep note of the TR#

Step 2) Create a Report

*&---------------------------------------------------------------------*
*& Report ZTRANSPORT_TABLE
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ztransport_table.
DATA:
  lv_request   TYPE trkorr VALUE 'SYSXXXXXXX', "Change the value with your TR#
  lt_e071     TYPE tr_objects,
  lt_e071k    TYPE tr_keys,
  ls_e071     TYPE e071,
  ls_e071k    TYPE e071k,
  lv_position TYPE ddposition,
  lv_tabkey   TYPE trobj_name,

"Define Internal Table and Workarea of Type the Table which Data we want to capture in TR
  lt_t012k TYPE TABLE OF t012k
  ls_t012k TYPE t012k.

"Fetch the data which we want to capture in TR
SELECT * FROM t012k INTO TABLE lt_t012k.
SORT lt_t012k BY bukrs hbkid hktid.

"Fill the workarea and append it in Internal Table
ls_e071-trkorr   = lv_request.
ls_e071-as4pos   = 1.
ls_e071-pgmid    = 'R3TR'.
ls_e071-object   = 'TABU'.
ls_e071-obj_name = 'T012K'.
ls_e071-objfunc  = 'K'.
APPEND ls_e071 TO lt_e071.
CLEAR ls_e071.

CLEAR lv_position.

"Loop on the data and fill the E021K Table entry
LOOP AT lt_t012k INTO ls_t012k.
  lv_position = lv_position + 1.
"Concatenate all the Key Values of the Table
  CONCATENATE sy-mandt ls_t012k-bukrs ls_t012k-hbkid ls_t012k-hktid INTO lv_tabkey RESPECTING BLANKS.
  ls_e071k-trkorr     = lv_request.
  ls_e071k-pgmid      = 'R3TR'.
  ls_e071k-object     = 'TABU'.
  ls_e071k-objname    = 'T012K'.
  ls_e071k-objfunc    = 'K'.
  ls_e071k-as4pos     = lv_position.
  ls_e071k-mastertype = 'TABU'.
  ls_e071k-mastername = 'T012K'.
  ls_e071k-tabkey     = lv_tabkey.

  APPEND ls_e071k TO lt_e071k.
  CLEAR ls_e071k.
ENDLOOP.

*"to add entries to the transport request we call the following function module
  call function 'TR_REQUEST_CHOICE'
    exporting
      iv_suppress_dialog   = 'X'
      iv_request           = lv_request
      it_e071              = lt_e071
      it_e071k             = lt_e071k.

 

The above report will capture the fetched entries from table in the given TR.

 

We can even make this code dynamic so that it will capture any table data in a TR making developer’s life easy 🙂

 

To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

  1. Michael Biber

    There are two more UI-options.

    1. SM30: If a dynpro for table maintenance exists you can add table entries via this transaction.
    2. SE16N: In theory there is a menu function to transport selected table entries. In my current test system this optioin is greyed out so I am not sure, if it works for all tables.
    (0) 
    1. Amit Diwane Post author

      Hello Michael,

       

      Thanks. This code is written to handle the second scenario where the option to ‘add entries in Transport’ is disabled as we do not have TMG created for it.

       

       

      (0) 

Leave a Reply