首页 > 解决方案 > 压缩传输请求中的行

问题描述

我有一个用于传输请求的代码,问题是每次按下“添加到事务”按钮时它都会创建一个新对象(据我所知)。

代码是:

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.

由于它显示了 1 次(我选择了 2 行添加到任务): 选择了 2 行添加到任务

由于 2 次它向我显示(选择 3 行添加到任务): 选择了 3 行添加到任务

如您所见,它使第二个对象+添加了我想在第一个对象中添加到任务中的 3 行。

请解释一下我如何以编程方式在 1 个对象中实现它(我知道 se01 中的排序和压缩)。

非常感谢您提供的任何信息,祝您好运!

标签: abaptransportsap-basis

解决方案


直到今天我都试图找到正确的解决方案,我可以说我们只能做一件事就是使用 modul 'TR_SORT_AND_COMPRESS_COMM' :

call function 'TR_SORT_AND_COMPRESS_COMM'   
        exporting
          iv_trkorr                      = lf_ev_task    " Request

在将对象和键添加到任务后进行排序和压缩


推荐阅读