代码之家  ›  专栏  ›  技术社区  ›  letronas

向传输请求添加表行

  •  0
  • letronas  · 技术社区  · 8 年前

    我在用编程的方式向传输请求添加表行时遇到问题。

    当我写下传输请求号码时,我得到错误:

    不能使用请求EAMK913244

    我用来传输日期的代码是:

    form add_data_to_transaction .
      data lt_variable_changed type table of ztable_task2 .
    
      data:
        l_request   type trkorr,
        lt_e071     type tr_objects,
        lt_e071k    type tr_keys,
        lv_position type ddposition,
        lv_tabkey   type trobj_name,
        ls_e071     type e071,
        ls_e071k    type e071k.
    
    
      "before adding to transort request check for transport query
      if var_query is not initial.
    
        call method grid->get_selected_rows                              " get index of row
          importing
            et_index_rows = lt_rows.
    
        "rows that i need to add to the table
        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.
        else.
          message 'Select 1 or more rows' type 'I'.
        endif.
        if lt_rows is not initial.
          ""e071 contains only one row per table. the objfunc is 'K' if we need to transport //specific entries as specified in the e071k structure.
          "ls_e071-trkorr   = var_query.
          "ls_e071-as4pos   = 1.
          ls_e071-pgmid    = 'R3TR'.
          ls_e071-object   = 'TABU'.                            "for table
          ls_e071-obj_name = 'ZTABLE_TASK2'.
          ls_e071-objfunc  = 'K'.
          ls_e071-lang     = sy-langu.
    
          append ls_e071 to lt_e071.
          clear ls_e071.
          clear lv_position.
          "add all table entries in table zxa_header that need to be transported to lt_e071k
          loop at lt_variable_changed into ls_variable.
    
            lv_position = lv_position + 1.
    
            lv_tabkey = ls_variable-num.
    
            "ls_e071k-trkorr     = var_query.
            ls_e071k-pgmid      = 'R3TR'.
            ls_e071k-object     = 'TABU'.
            ls_e071k-objname    = 'ZTABLE_TASK2'.
            "ls_e071k-as4pos     = lv_position.
            ls_e071k-mastertype = 'TABU'.
            ls_e071k-mastername = 'ZTABLE_TASK2'.
            ls_e071k-lang       = sy-langu.
            ls_e071k-tabkey     = lv_tabkey.
    
    
            append ls_e071k to lt_e071k.
            clear ls_e071k.
          endloop.
    
          call function 'TR_REQUEST_CHOICE'
            exporting
              iv_suppress_dialog   = 'X'
              iv_request           = var_query
              it_e071              = lt_e071
              it_e071k             = lt_e071k.
    
          message 'Ok' type 'I'.
        endif.
      else.
        message 'Fill in tranport request number' type 'I'.
      endif.
    endform.
    

    se01屏幕:

    image

    谢谢你的帮助,祝你好运!

    1 回复  |  直到 8 年前
        1
  •  1
  •   Trevor Zhang    8 年前

    应使用三个功能模块来传输变更

    call function 'TR_ORDER_CHOICE_CORRECTION'
      exporting
        iv_category            = 'CUST'
      importing
        ev_order               = ev_request
        ev_task                = ev_task
      exceptions
        invalid_category       = 1
        no_correction_selected = 2
        others                 = 3.
    
      call function 'TR_OBJECTS_CHECK'
        exporting
          iv_no_show_option       = abap_true
        tables
          wt_ko200                = lt_ko200_customizing
          wt_e071k                = lt_e071k_customizing
        exceptions
          cancel_edit_other_error = 1
          show_only_other_error   = 2
          others                  = 3.
    
      call function 'TR_OBJECTS_INSERT'
        exporting
          wi_order                = lv_request
          iv_no_show_option       = abap_true
        tables
          wt_ko200                = lt_ko200_customizing
          wt_e071k                = lt_e071k_customizing
        exceptions
          cancel_edit_other_error = 1
          show_only_other_error   = 2
          others                  = 3.