Function module to create transport request with code.
Import Parameters:


Result:

Codes:
FUNCTION ZTB_CREATE_TRANSPORT_REQUEST.
*”———————————————————————-
*”*”Local Interface:
*” IMPORTING
*” REFERENCE(I_TYPE) TYPE STRING
*” REFERENCE(I_TEXT) TYPE STRING OPTIONAL
*” REFERENCE(I_OWNER) TYPE STRING OPTIONAL
*” REFERENCE(I_TARGET) TYPE STRING
*” REFERENCE(IT_USERS) TYPE STRING_TABLE OPTIONAL
*”———————————————————————-
* iv_type = ‘W’ or iv_type = ‘K’
* W – Customized
* K – Workbench request
* iv_text = Description of request
* iv_owner = Owner of the request
* iv_target = Target system of request
* it_users = Users who want to create task
types: trwbo_charflag(1) type c.
types: begin of trwbo_request_header.
include structure e070.
types: as4text like e07t–as4text,
as4text_filled type trwbo_charflag,
client like e070c–client,
tarclient like e070c–tarclient,
clients_filled type trwbo_charflag,
tardevcl like e070m–tardevcl,
devclass like e070m–devclass,
tarlayer like e070m–tarlayer,
e070m_filled type trwbo_charflag,
end of trwbo_request_header.
types: trwbo_request_headers type trwbo_request_header occurs 0.
data:
“Import Data
lv_type type trfunction,
lv_text type as4text,
lv_owner type as4user,
lv_target type tr_target,
lt_users type scts_users,
ls_users type scts_user,
“Export Data
ls_request_header type trwbo_request_header,
lt_task_headers type trwbo_request_headers,
“General Data
lv_string type string.
lv_type = i_type.
lv_text = i_text.
lv_owner = i_owner.
if lv_owner is initial.
lv_owner = sy–uname.
endif.
lv_target = i_target.
loop at it_users into lv_string.
clear ls_users.
ls_users–user = lv_string.
ls_users–type = lv_type.
append ls_users to lt_users.
endloop.
call function ‘TR_INSERT_REQUEST_WITH_TASKS’
exporting
iv_type = lv_type
iv_text = lv_text
iv_owner = lv_owner
iv_target = lv_target
* it_attributes =
it_users = lt_users
* iv_tardevcl =
* iv_devclass =
* iv_tarlayer =
importing
es_request_header = ls_request_header
et_task_headers = lt_task_headers
* exceptions
* insert_failed = 1
* enqueue_failed = 2
* others = 3
.