运输要求ABAP

时间:2018-08-06 13:55:59

标签: sap abap transport

我有一个运输请求代码,问题是每当我按下“添加到交易”按钮时,它就会创建一个新对象(我不理解)。

代码是:

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行): chose 2 line add to task

作为2次显示的结果(向任务添加3行): chose 3 line add to task

如您所见,它使第二个对象+我想添加到第一个对象中的任务添加3行。 请解释一下我如何以编程方式在1个对象中实现(我知道se01中的排序和压缩)。 非常感谢您提供的任何信息和好运!

1 个答案:

答案 0 :(得分:0)

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

call function 'TR_SORT_AND_COMPRESS_COMM'   
        exporting
          iv_trkorr                      = lf_ev_task    " Request

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