用STARTING NEW TASK 方式调用函数ABAP4_CALL_TRANSACTION,会打开一个新的窗口(session)运行tcode。
![2017-02-28_18-00-48](http://www.baidusap.com/wp-content/uploads/2017-02-28_18-00-48.png)
函数ABAP4_CALL_TRANSACTION本质上是封装了CALL TRANSACTION
![2017-02-28_18-04-12](http://www.baidusap.com/wp-content/uploads/2017-02-28_18-04-12.png)
代码:
REPORT ztest_open_tcode.
CALL FUNCTION 'ABAP4_CALL_TRANSACTION'
STARTING NEW TASK 'NEW_SESSION'
EXPORTING
tcode = 'SE38'
* SKIP_SCREEN = ' '
* MODE_VAL = 'A'
* UPDATE_VAL = 'A'
* IMPORTING
* SUBRC =
* TABLES
* USING_TAB =
* SPAGPA_TAB =
* MESS_TAB =
EXCEPTIONS
call_transaction_denied = 1
tcode_invalid = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.