0

I have a code for trasport request and the problem is that it creates a new object (as I understand) every single time I press the button "add to transaction".

The code is:

data lt_variable_changed type table of ztr_req .

  data:
    lf_e071  type  e071,
    lf_e071k type  e071k,
    lt_e071  type table of e071,
    lt_e071k type table of e071k.

  "before adding to transort request check for transport query
  if var_query is not initial.
    clear lt_variable_changed.

    call method grid->get_selected_rows                              " get index of row
      importing
        et_index_rows = lt_rows.


    if lt_rows is not initial.

      loop at lt_rows into ls_row.                           
        read table lt_variable index ls_row into ls_variable.
        append ls_variable to lt_variable_changed.
      endloop.

     

      lf_ev_order = 'EASK900417'. " Selected request
      lf_ev_task  = var_query.  "  Selected Task

      call function 'TR_ORDER_CHOICE_CORRECTION'  
        exporting
          iv_category            = 'SYST'
        importing
          ev_order               = lf_ev_order       " Selected request EASK900415
          ev_task                = lf_ev_task        " Selected Task    EASK900416
        exceptions
          invalid_category       = 1
          no_correction_selected = 2
          others                 = 3.
      if sy-subrc <> 0.
        exit.
      endif.

      lf_e071-pgmid = 'R3TR'.
      lf_e071-object = 'TABU'.
      lf_e071-obj_name = 'ZTR_REQ'.
      lf_e071-objfunc = 'K'.
      lf_e071-lang = sy-langu.
      append lf_e071 to lt_e071.

      "add all table entries in table zxa_header that need to be transported to lt_e071k
      loop at lt_variable_changed into ls_variable.

        lf_e071k-pgmid = 'R3TR'.
        lf_e071k-object = 'TABU'.
        lf_e071k-objname = 'ZTR_REQ'.
        lf_e071k-mastertype = 'TABU'.
        lf_e071k-mastername = 'ZTR_REQ'.
        lf_e071k-lang       = sy-langu.
        lf_e071k-tabkey     = |{ sy-mandt }{ ls_variable-num }|.

        append lf_e071k to lt_e071k.
        clear lf_e071k.
      endloop.


      call function 'TR_APPEND_TO_COMM_OBJS_KEYS'   
        exporting
          wi_trkorr                      = lf_ev_task
        tables
          wt_e071                        = lt_e071
          wt_e071k                       = lt_e071k
        exceptions
          others                         = 68.

    endif.
  endif.

as a result of 1 time it shows (I chose 2 line add to task): chose 2 line add to task

as a result of 2 time it shows me(chose 3 line add to task): chose 3 line add to task

As you can see it makes second object + add 3-line that I want to add to the task in a first one object.

Please, explain me how I can make it in 1 object in programming way (I know about sort and compress in se01).

Thanks a lot for any info and good luck!

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
letronas
  • 145
  • 1
  • 13
  • Does this answer your question? [Add table rows to the transport request](https://stackoverflow.com/questions/51672657/add-table-rows-to-the-transport-request) – Suncatcher Jun 01 '20 at 14:50

1 Answers1

0

till this day I tried to find out the right solution and I can say that there is only one thing we can do is to use modul 'TR_SORT_AND_COMPRESS_COMM' :

call function 'TR_SORT_AND_COMPRESS_COMM'   
        exporting
          iv_trkorr                      = lf_ev_task    " Request

to make a sort and compress after added objects and keys to a task

letronas
  • 145
  • 1
  • 13