Add table rows to the transport request

萝らか妹 提交于 2020-06-08 15:01:43

问题


I have a problem with adding rows of table to the transport request in programming way.

When i wrote down the transport request number i get the error:

You cannot use request EAMK913244

the code that i used for transporting date is:

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.

Screen from se01:

Thanks for help and good luck!


回答1:


three function modules shall be used to transport changes

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.


来源:https://stackoverflow.com/questions/51672657/add-table-rows-to-the-transport-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!