简体   繁体   中英

Add table rows to a TR programmatically?

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 I use is

  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_tabkey   type trobj_name,
        ls_e071     type e071,
        ls_e071k    type e071k.

      ls_e071-pgmid    = 'R3TR'.
      ls_e071-object   = 'TABU'.                            "for table
      ls_e071-obj_name = 'ZTABLE_TASK2'.
      ls_e071-objfunc  = 'K'.
      append ls_e071 to lt_e071.

      loop at lt_variable_changed into ls_variable.
        lv_tabkey = ls_variable-num.
        ls_e071k-pgmid      = 'R3TR'.
        ls_e071k-object     = 'TABU'.
        ls_e071k-objname    = 'ZTABLE_TASK2'.
        ls_e071k-mastertype = 'TABU'.
        ls_e071k-mastername = 'ZTABLE_TASK2'.
        ls_e071k-tabkey     = lv_tabkey.
        append ls_e071k to lt_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'.

Screen from se01:

图片

Thanks for help and good luck!

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.

You can also use object-oriented approach for transporting tables.

This piece creates a customizing request and puts contents of a table in it:

DATA(instance) = cl_adt_cts_management=>create_instance( ).
TRY.
  instance->insert_objects_in_wb_request( EXPORTING pgmid    = 'R3TR'
                                                    object   = 'TABU'
                                                    obj_name = CONV trobj_name( 'Z_TABLE' )
                                          CHANGING  trkorr   = l_trkorr ).
  CATCH cx_adt_cts_insert_error.
    RETURN.
ENDTRY.

This piece uses ADT CTS classes and is very flexible. Despite the name wb_request this method is adaptive and will create workbench or customizing request depending on the objects passed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM