0% found this document useful (0 votes)
767 views28 pages

ZTOC Request Report Configuration

This document defines classes and declares data objects used to display data in an ALV grid. It retrieves request data from the system and loads it into internal tables for display. User selections on the grid will trigger event methods to perform further processing.

Uploaded by

ozgocer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
767 views28 pages

ZTOC Request Report Configuration

This document defines classes and declares data objects used to display data in an ALV grid. It retrieves request data from the system and loads it into internal tables for display. User selections on the grid will trigger event methods to perform further processing.

Uploaded by

ozgocer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

report zbc_toc_request line-size 255.

data: gr_salv type ref to cl_salv_table.


class lcl_handle_events definition deferred.
data: gr_events type ref to lcl_handle_events.

data: g_log type ref to cl_ptu_message.

*data: gt_out type table of trwbo_s_e071 .


types: begin of ty_out,
as4user type e070-as4user,
trstatus type e070-trstatus.
include type e071.
types: vers type text10,
udat type trdir-udat,
unam type trdir-unam.
types: end of ty_out.

data: gt_out type table of ty_out.

data: gs_out like line of gt_out.


data: gt_request type table of trwbo_request.
data: gs_request like line of gt_request.
data: gs_objects like line of gs_request-objects.
data: gs_keys type trwbo_s_e071k.
*data: gs_attributes type trwbo_s_e070a.

data: gv_request type trkorr.


data: gv_toc type trkorr.
data: gv_text type as4text.
data: gr_display type ref to cl_salv_display_settings.

selection-screen begin of block blk with frame title text-001.


parameters: r_none radiobutton group g1 user-command comm1,
* r_dp radiobutton group g1,
r_qas radiobutton group g1 default 'X'.
* r_mig radiobutton group g1,
* r_ppr radiobutton group g1,
* r_qal radiobutton group g1.
selection-screen skip.
parameters: p_reqst type trkorr obligatory.
parameters: p_target type tr_target .
parameters: p_toc type trkorr.
parameters: p_modif as checkbox.
parameters: p_sortcd as checkbox.
selection-screen end of block blk.

initialization.
p_target = 'DEQ.100'.
* if sy-sysid+0(1) = 'D'.
* concatenate 'P' sy-sysid+1(2) '.6' sy-mandt+1(2) into p_target.
** concatenate 'P' sy-sysid+1(2) into p_target.
* else.
* concatenate 'D' sy-sysid+1(2) '.1' sy-mandt+1(2) into p_target.
** concatenate 'D' sy-sysid+1(2) into p_target.
* endif.
at selection-screen output.
loop at screen.
if screen-name eq 'P_TARGET'.
screen-input = 0.
modify screen.
exit.
endif.
endloop.

at selection-screen.
perform selection_screen.

at selection-screen on value-request for p_reqst.


perform search_help using abap_false.

at selection-screen on value-request for p_toc.


perform search_help using abap_true.

*----------------------------------------------------------------------*
* CLASS lcl_handle_events DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_handle_events definition.
public section.
methods:
on_user_command for event added_function of cl_salv_events_table
importing e_salv_function,
on_double_click for event double_click of cl_salv_events_table
importing row column,
on_link_click for event link_click of cl_salv_events_table
importing row column.
endclass. "lcl_handle_events DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_handle_events IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_handle_events implementation.
method on_user_command.
perform user_command using e_salv_function.
endmethod. "on_user_command

method on_double_click.
perform on_double_click using row column.
endmethod.

method on_link_click.
perform on_double_click using row column.
endmethod.

endclass. "lcl_handle_events IMPLEMENTATION

start-of-selection.
create object g_log.
perform get_data.

end-of-selection.
perform display_alv.
*&---------------------------------------------------------------------*
*& Form SEARCH_HELP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form search_help
using p_param type abap_bool.

data: lv_request type trkorr.


data: ls_request type trwbo_request_header.

if p_param eq abap_false.
call function 'TR_F4_REQUESTS'
exporting
iv_username = sy-uname
iv_trfunctions = 'KWRSXQ' "'K W'
iv_client = sy-mandt
iv_via_selection_screen = 'X'
iv_complete_requests = 'X'
importing
ev_selected_request = lv_request
es_selected_request = ls_request.

p_reqst = lv_request.

elseif p_param eq abap_true.


call function 'TR_F4_REQUESTS'
exporting
iv_username = sy-uname
iv_trfunctions = 'T'
iv_trstatus = 'D'
iv_client = sy-mandt
iv_via_selection_screen = 'X'
iv_complete_requests = 'X'
importing
ev_selected_request = lv_request
es_selected_request = ls_request.

p_toc = lv_request.

endif.

endform.

*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form get_data .

* data: lt_attributes type table of scts_attr.


* data: ls_attributes like line of lt_attributes.

data: lv_client like e070c-client.


data: lv_user type tr_as4user.
data: lv_date type as4date.
data: lv_datum type c length 10.
data: lv_desc like e07t-as4text.
gv_request = p_reqst.
gv_toc = p_toc.

call function 'TR_READ_REQUEST_WITH_TASKS'


exporting
iv_trkorr = gv_request
importing
et_requests = gt_request
exceptions
invalid_input = 1
others = 2.

if sy-subrc eq 0.
call method g_log->add_text
exporting
iv_type = 'S'
iv_text = 'Requeste ait objeler okundu'.
elseif sy-subrc <> 0 and sy-msgid is not initial.
g_log->add_message_simple( ).
endif.

loop at gt_request into gs_request.


if p_modif eq abap_true.
check gs_request-h-trstatus eq 'D'
and gs_request-h-strkorr is not initial.
endif.

loop at gs_request-objects into gs_objects.


move-corresponding gs_request-h to gs_out.
move-corresponding gs_objects to gs_out.

perform get_last_changed changing gs_out.


gs_out-vers = 'Versiyon'.

append gs_out to gt_out.


clear gs_out.
endloop.
* loop at gs_request-attributes into gs_attributes.
* ls_attributes-attribute = gs_attributes-attribute.
* ls_attributes-value = gs_attributes-reference.
* append ls_attributes to lt_attributes.
* clear gs_attributes.
* endloop.
clear gs_request.
endloop.

read table gt_request into gs_request with key h-trkorr = gv_request.


lv_client = gs_request-h-client.
lv_user = gs_request-h-as4user.
lv_date = gs_request-h-as4date.
lv_desc = gs_request-h-as4text.
concatenate lv_date+6(2) '.' lv_date+4(2) '.' lv_date+0(4) into lv_datum.
concatenate 'TOC' p_reqst lv_client lv_user lv_datum lv_desc into gv_text
separated by space.

endform.

*&---------------------------------------------------------------------*
*& Form GET_LAST_CHANGED
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_GS_OUT text
*----------------------------------------------------------------------*
form get_last_changed changing gs_out type ty_out.

types: begin of ty_changes,


udat type trdir-udat,
unam type trdir-unam,
end of ty_changes.

data: lo_clsref type ref to cl_oo_include_naming,


lo_class_incl type ref to if_oo_clif_incl_naming,
lt_includes type seoincl_t,
lv_object type char9,
lv_master type d010inc-master,
lv_include type rs38l-include,
lv_obj1 type char50,
lv_obj2 type char50,
lt_changes type table of ty_changes,
ls_out type ty_out.

concatenate gs_out-pgmid gs_out-object into lv_object separated by space.

case lv_object.

when 'R3TR PROG' or


'LIMU REPS' or
'LIMU REPT' or
'LIMU CINC'.

select single udat unam into (gs_out-udat, gs_out-unam)


from trdir
where name eq gs_out-obj_name.

when 'LIMU DYNP'.

lv_obj1 = substring( val = gs_out-obj_name len = ( strlen( gs_out-obj_name )


- 4 ) ).
lv_obj2 = substring( val = gs_out-obj_name off = ( strlen( gs_out-obj_name )
- 4 ) ).

select single dgen into (gs_out-udat)


from d020s
where prog eq lv_obj1
and dnum eq lv_obj2.

when 'LIMU CUAD'.

select single vdatum vautor into (gs_out-udat, gs_out-unam)


from eudb
where relid eq 'CU'
and name eq gs_out-obj_name(40)
and sprsl eq 'D'
and srtf2 eq 0.

if gs_out-udat is initial.
select single datum autor into (gs_out-udat, gs_out-unam)
from eudb
where relid eq 'CU'
and name eq gs_out-obj_name(40)
and sprsl eq 'D'
and srtf2 eq 0.
endif.

when 'R3TR TABL' or


'R3TR VIEW' or
'LIMU TABD' or
'LIMU VIED' or
'LIMU TABT'.

select single as4date as4user into (gs_out-udat, gs_out-unam)


from dd02l
where tabname eq gs_out-obj_name
and as4local eq 'A'
and as4vers eq ''.

when 'R3TR TTYP'


or 'LIMU TTYD'.

select single as4date as4user into (gs_out-udat, gs_out-unam)


from dd40l
where typename eq gs_out-obj_name
and as4local eq 'A'.

when 'R3TR DOMA' or


'LIMU DOMD'.

select single as4date as4user into (gs_out-udat, gs_out-unam)


from dd01l
where domname eq gs_out-obj_name
and as4local eq 'A'
and as4vers eq ''.

when 'R3TR DTEL' or


'LIMU DTED'.

select single as4date as4user into (gs_out-udat, gs_out-unam)


from dd04l
where rollname eq gs_out-obj_name
and as4local eq 'A'
and as4vers eq ''.

when 'R3TR SHLP'


or 'LIMU SHLD'.

select single as4date as4user into (gs_out-udat, gs_out-unam)


from dd30l
where shlpname eq gs_out-obj_name
and as4local eq 'A'.

when 'R3TR FUGR'


or 'LIMU FUGT'.

lv_master = 'SAPL' && gs_out-obj_name.


lv_include = 'L' && gs_out-obj_name && '%'.

* call function 'GET_INCLUDES'


select include from d010inc
into table lt_includes
where master eq lv_master
and include like lv_include
and include not like '%$__'.

if lt_includes is not initial.


select udat unam
into table lt_changes
from trdir
for all entries in lt_includes
where name eq lt_includes-table_line
and unam ne 'SAP'.

if sy-subrc eq 0.
sort lt_changes by udat descending.
delete lt_changes where udat ne lt_changes[ 1 ]-udat.
if lines( lt_changes ) > 1.
delete lt_changes where unam eq 'SAP*'.
endif.

gs_out-udat = lt_changes[ 1 ]-udat.


gs_out-unam = lt_changes[ 1 ]-unam.
endif.
endif.

when 'LIMU FUNC'


or 'R3TR SRFC'.

call function 'FUNCTION_EXISTS'


exporting
funcname = conv rs38l_fnam( gs_out-obj_name )
importing
include = lv_include
exceptions
others = 2.
if sy-subrc = 0.
select single udat unam into (gs_out-udat, gs_out-unam)
from trdir
where name eq lv_include.
endif.

when 'R3TR XSLT'.

lv_include = '==============================XT'.
overlay lv_include with |{ gs_out-obj_name }| only '='.

select single udat unam into (gs_out-udat, gs_out-unam)


from trdir
where name eq lv_include.

when 'R3TR CLAS'.

cl_oo_classname_service=>get_all_class_includes(
exporting
class_name = conv #( gs_out-obj_name )
receiving
result = lt_includes
exceptions
no_such_class = 1
others = 2 ).

if sy-subrc = 0.
select udat unam
into table lt_changes
from trdir
for all entries in lt_includes
where name eq lt_includes-table_line.

if sy-subrc eq 0.
sort lt_changes by udat descending.
gs_out-udat = lt_changes[ 1 ]-udat.
gs_out-unam = lt_changes[ 1 ]-unam.
endif.
endif.

when 'R3TR INTF' or


'LIMU CLSD' or
'LIMU CPRI' or
'LIMU CPRO' or
'LIMU CPUB'.

clear lv_include.

call method cl_oo_include_naming=>get_include_by_trkey


exporting
pgmid = gs_out-pgmid
object = gs_out-object
obj_name = gs_out-obj_name
importing
progname = lv_include
prognames = lt_includes
exceptions
others = 3.

if lt_includes is not initial.


lv_include = lt_includes[ 1 ].
endif.

if lv_include is not initial.


select single udat unam into (gs_out-udat, gs_out-unam)
from trdir
where name eq lv_include.
endif.

when 'LIMU METH'.

lo_clsref ?= cl_oo_include_naming=>get_instance_by_trkey(
pgmid = gs_out-pgmid
object = gs_out-object
obj_name = gs_out-obj_name ).

if lo_clsref is bound.
clear lv_include.

call method lo_clsref->if_oo_class_incl_naming~get_include_by_mtdname


exporting
mtdname = conv #( gs_out-obj_name+30 )
receiving
progname = lv_include
exceptions
others = 1.
if sy-subrc is initial.
select single udat unam into (gs_out-udat, gs_out-unam)
from trdir
where name eq lv_include.
endif.
endif.

when 'R3TR MSAG'.

select single ldate lastuser into (gs_out-udat, gs_out-unam)


from t100a
where arbgb eq gs_out-obj_name.

when 'LIMU MESS'.

lv_obj1 = substring( val = gs_out-obj_name len = ( strlen( gs_out-obj_name )


- 3 ) ).
lv_obj2 = substring( val = gs_out-obj_name off = ( strlen( gs_out-obj_name )
- 3 ) ).

select single datum name into (gs_out-udat, gs_out-unam)


from t100u
where arbgb eq lv_obj1
and msgnr eq lv_obj2.

when 'LIMU DOCU'.

select single dokldate dokluser into (gs_out-udat, gs_out-unam)


from dokhl
where id eq gs_out-obj_name(2)
and object eq gs_out-obj_name+2.
if gs_out-udat is initial.
select single dokfdate dokfuser into (gs_out-udat, gs_out-unam)
from dokhl
where id eq gs_out-obj_name(2)
and object eq gs_out-obj_name+2.
endif.

when 'R3TR TOBJ'.

lv_obj1 = substring( val = gs_out-obj_name len = ( strlen( gs_out-obj_name )


- 1 ) ).
lv_obj2 = substring( val = gs_out-obj_name off = ( strlen( gs_out-obj_name )
- 1 ) ).
select single ldate luser into (gs_out-udat, gs_out-unam)
from objh
where objectname eq lv_obj1
and objecttype eq lv_obj2.

when 'R3TR VCLS'.

select single changedate author into (gs_out-udat, gs_out-unam)


from vcldir
where vclname eq gs_out-obj_name.

when 'R3TR ENHO'.

select logdate loguser up to 1 rows


into (gs_out-udat, gs_out-unam)
from enhlog
where enhname eq gs_out-obj_name
order by logdate descending logtime descending.
endselect.

when 'R3TR ENHS'.

select single changedon changedby into (gs_out-udat, gs_out-unam)


from enhspotheader
where enhspot eq gs_out-obj_name.

when 'R3TR IDOC'.

select single ldate plast into (gs_out-udat, gs_out-unam)


from edbas
where idoctyp eq gs_out-obj_name.

when 'R3TR NROB'.

select single udate username into (gs_out-udat, gs_out-unam)


from cdhdr
where objectclas eq 'NRKROBJ'
and objectid eq gs_out-obj_name
and changenr eq ( select max( changenr ) from cdhdr as h2
where h2~objectclas eq cdhdr~objectclas
and h2~objectid eq cdhdr~objectid ).

when 'R3TR SFPF'.

select single lastdate lastuser into (gs_out-udat, gs_out-unam)


from fpcontext
where name eq gs_out-obj_name
and state eq 'A'.

when 'R3TR SFPI'.

select single lastdate lastuser into (gs_out-udat, gs_out-unam)


from fpinterface
where name eq gs_out-obj_name
and state eq 'A'.

when 'R3TR SSFO'.

select single lastdate lastuser into (gs_out-udat, gs_out-unam)


from stxfadm
where formname eq gs_out-obj_name.

when 'R3TR SSST'.

select single lastdate lastuser into (gs_out-udat, gs_out-unam)


from stxsadm
where stylename eq gs_out-obj_name.

when 'R3TR TRAN'.

select single created_on author into (gs_out-udat, gs_out-unam)


from tadir
where pgmid eq gs_out-pgmid
and object eq gs_out-object
and obj_name eq gs_out-obj_name.

when 'R3TR CMOD'.

select single udat unam into (gs_out-udat, gs_out-unam)


from modattr
where name eq gs_out-obj_name.

when 'R3TR DEVC'.

select single changed_on changed_by into (gs_out-udat, gs_out-unam)


from tdevc
where devclass eq gs_out-obj_name.

when 'R3TR ENHC'.

select single changedon changedby into (gs_out-udat, gs_out-unam)


from enhcompheader
where enhcomposite eq gs_out-obj_name
and version eq 'A'.

when 'R3TR SXCI'.

select single adate aname into (gs_out-udat, gs_out-unam)


from sxc_attr
where imp_name eq gs_out-obj_name.

when 'R3TR SPRX'.


ls_out = gs_out.
ls_out-object = gs_out-obj_name(4).
ls_out-obj_name = gs_out-obj_name+4.
perform get_last_changed using ls_out.
gs_out-udat = ls_out-udat.
gs_out-unam = ls_out-unam.

endcase.

if gs_out-udat is initial.
gs_out-udat = '11111111'.
endif.

endform. " GET_LAST_CHANGED

*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form display_alv .

** Declarations for ALV Functions


data : gr_functions type ref to cl_salv_functions_list.
** declaration for Layout Settings
data: gr_layout type ref to cl_salv_layout,
gr_layout_key type salv_s_layout_key.
data: lv_header type c length 80.

data: lv_repid type sy-repid.


try.

call method cl_salv_table=>factory


importing
r_salv_table = gr_salv
changing
t_table = gt_out[].

*... §7 selections
data: lr_selections type ref to cl_salv_selections,
lr_sort type ref to cl_salv_sorts.

lr_selections = gr_salv->get_selections( ).

*... §7.1 set selection mode


lr_selections->set_selection_mode( if_salv_c_selection_mode=>row_column ).

lv_repid = sy-repid.

gr_salv->set_screen_status(
pfstatus = 'STANDARD'
report = lv_repid
set_functions = gr_salv->c_functions_all ).

* sort
lr_sort = gr_salv->get_sorts( ).

if p_sortcd eq abap_true.
lr_sort->add_sort( columnname = 'UDAT' sequence = if_salv_c_sort=>sort_down
).
endif.
lr_sort->add_sort( 'AS4USER' ).
lr_sort->add_sort( 'TRSTATUS' ).
lr_sort->add_sort( 'PGMID' ).
lr_sort->add_sort( 'OBJECT' ).
lr_sort->add_sort( 'OBJ_NAME' ).

*--------------------------------------------------------------------*
*change description of text column
* Get the column object
data: lr_columns type ref to cl_salv_columns_table,
lr_column type ref to cl_salv_column_table.
lr_columns = gr_salv->get_columns( ).
lr_columns->set_optimize( 'X' ).

lr_columns->get_column( 'AS4POS' )->set_visible( abap_false ).

lr_column ?= lr_columns->get_column( 'VERS' ).


lr_column->set_long_text( 'Versiyon' ).
lr_column->set_cell_type( if_salv_c_cell_type=>hotspot ).

data: lr_events type ref to cl_salv_events_table,


lx_salv type ref to cx_salv_error.
lr_events = gr_salv->get_event( ).
create object gr_events.

*... §6.1 register to the event USER_COMMAND


set handler gr_events->on_user_command for lr_events.
set handler gr_events->on_double_click for lr_events.
set handler gr_events->on_link_click for lr_events.

*--------------------------------------------------------------------*
** Get functions details
gr_functions = gr_salv->get_functions( ).
** Activate All Buttons in Tool Bar
gr_functions->set_all( if_salv_c_bool_sap=>true ).

******* Layout Settings *******


move sy-repid to gr_layout_key-report.
"Set Report ID as Layout Key"

gr_layout = gr_salv->get_layout( ).
"Get Layout of Table"
gr_layout->set_key( gr_layout_key ).
"Set Report Id to Layout"
gr_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
gr_layout->set_default( if_salv_c_bool_sap=>true ).

gr_display = gr_salv->get_display_settings( ).
gr_display->set_striped_pattern( if_salv_c_bool_sap=>true ).

concatenate p_reqst 'Requestine ait objeler' into lv_header separated by


space.
gr_display->set_list_header( | { lv_header } | ).

gr_salv->display( ).

catch cx_salv_error into lx_salv .


message lx_salv type 'I'.
endtry.

endform.
*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_E_SALV_FUNCTION text
*----------------------------------------------------------------------*
form user_command using i_function type salv_de_function.
data: lv_header type c length 80,
lv_target like p_target,
ls_e070 type e070.

case i_function.
when 'OBJE_EKLE'.
perform obje_ekle.
concatenate gv_toc 'TOC Requestine eklenecek objeler' into lv_header
separated by space.
gr_display->set_list_header( | { lv_header } | ).
gr_salv->refresh( refresh_mode = if_salv_c_refresh=>full ).

when 'RELEASE'.
perform release_et.
gr_salv->refresh( refresh_mode = if_salv_c_refresh=>full ).
perform log_show.

when 'IMPORT'.
while ls_e070-trstatus na 'RN' and sy-index < 20.
select single * from e070 into ls_e070 where trkorr = gv_toc.
wait up to '0.5' seconds.
endwhile.
if ls_e070-trstatus na 'RN'.
g_log->add_text( iv_type = 'E'
iv_text = 'TOC request henüz release edilmedi, tekrar
deneyiniz.' ).
else.

* if r_qal = abap_true.
** perform fill_req_target
** using r_dp r_mig r_ppr r_qas r_qal
** changing lv_target.
** Mig
* perform fill_req_target
* using abap_false abap_true abap_false abap_false
abap_false
* changing lv_target.
* perform import_et using lv_target.
**- Pre-Prod
* perform fill_req_target
* using abap_false abap_false abap_true abap_false
abap_false
* changing lv_target.
* perform import_et using lv_target.
**- QAS
* perform fill_req_target
* using abap_false abap_false abap_false abap_true
abap_false
* changing lv_target.
* perform import_et using lv_target.
*
* else.
perform import_et using p_target.

* endif.
endif.

gr_salv->refresh( refresh_mode = if_salv_c_refresh=>full ).


perform log_show.
when 'LOG'.
perform log_show.

when 'SREPO'.
perform compare_repository.

when 'SCU0'.
perform compare_customizing.

endcase.
endform.

*&---------------------------------------------------------------------*
*& Form ON_DOUBLE_CLICK
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form on_double_click using row type salv_de_row
column type salv_de_column.

read table gt_out into gs_out index row.


check sy-subrc eq 0.

case column.
when 'VERS'.
submit rsvcdi01
with objtype = gs_out-object
with objname = gs_out-obj_name
and return.

when others.
call function 'TR_OBJECT_JUMP_TO_TOOL'
exporting
iv_pgmid = gs_out-pgmid
iv_object = gs_out-object
iv_obj_name = gs_out-obj_name
iv_action = 'SHOW'.
endcase.

* Tıklanan satırı seçili hale getir


data(lo_selections) = gr_salv->get_selections( ).
lo_selections->set_selected_rows( value #( ( row ) ) ).

endform.

*&---------------------------------------------------------------------*
*& Form OBJE_EKLE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form obje_ekle .

data: lt_e071 type table of e071.


data: ls_e071 like line of lt_e071.
data: lt_e071k type table of e071k.
data:
lt_rows type salv_t_row,
wa_rows like line of lt_rows.
data: lv_e071 type trpari-w_e071.
data: lv_e071k type trpari-w_e071k.
data: lv_text_toc type ptu_text.
data: lv_clientedit type t000-cccoractiv.

if gv_toc is not initial.


select count(*) from e070
where trkorr = gv_toc
and trstatus in ('D','L').
if sy-subrc ne 0.
message 'Request release edilmiş' type 'I' display like 'E'.
return.
endif.
endif.

lt_e071 = value #( (
trkorr = gv_request
pgmid = 'CORR'
object = 'MERG'
obj_name = gv_text
) ).

if gv_toc is initial.

call function 'TR_SYS_PARAMS'


importing
system_client_edit = lv_clientedit
exceptions
no_systemname = 1
no_systemtype = 2
others = 3.
if lv_clientedit eq '1'.
perform create_request.
else.
message 'TOC Requestini uyarlama client ında alınız!' type 'W'.
endif.
endif.

check gv_toc is not initial.

lt_rows = gr_salv->get_selections( )->get_selected_rows( ).

if lines( lt_rows ) eq 0.
g_log->add_text(
iv_type = 'W'
iv_text = 'Obje eklemek için lütfen seçim yapınız!' ).
else.

loop at lt_rows into wa_rows.


read table gt_out into gs_out index wa_rows.
if sy-subrc eq 0.
loop at gt_request into gs_request.
loop at gs_request-objects into gs_objects .
if gs_objects-trkorr eq gs_out-trkorr and gs_objects-as4pos eq gs_out-
as4pos.
append gs_objects to lt_e071.
endif.
clear gs_objects.
endloop.
loop at gs_request-keys into gs_keys.
if gs_keys-trkorr eq gs_out-trkorr and gs_keys-mastertype eq gs_out-
object.
append gs_keys to lt_e071k.
endif.
clear gs_keys.
endloop.
clear gs_request.
endloop.
endif.
endloop.

if lt_e071 is not initial.


lv_e071 = 'X'.
endif.
if lt_e071k is not initial.
lv_e071k = 'X'.
endif.

call function 'TRINT_APPEND_COMM'


exporting
wi_exclusive = ' '
wi_sel_e071 = lv_e071
wi_sel_e071k = lv_e071k
wi_trkorr = gv_toc
tables
wt_e071 = lt_e071
wt_e071k = lt_e071k
exceptions
e071k_append_error = 01
e071_append_error = 02
trkorr_empty = 03.

if sy-subrc <> 0.
if sy-msgid is not initial.
g_log->add_message_simple( ).
else.
g_log->add_text( iv_type = 'E' iv_text = 'Requeste eklenirken hata oluştu!'
).
endif.
else.
concatenate 'Seçilen objeler' gv_toc 'numaralı TOC requestine eklendi.' into
lv_text_toc separated by space.

call method g_log->add_text


exporting
iv_type = 'S'
iv_text = lv_text_toc.
endif.

refresh lt_e071.
refresh lt_e071k.
endif.

perform log_show.

endform.
*&---------------------------------------------------------------------*
*& Form RELEASE_ET
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form release_et .

if gv_toc is not initial.


select count(*) from e070
where trkorr = gv_toc
and trstatus in ('D','L').
if sy-subrc ne 0.
message 'Request release edilmiş' type 'S'.
return.
endif.
endif.

call function 'TRINT_RELEASE_REQUEST'


exporting
iv_trkorr = gv_toc
iv_success_message = ''
iv_without_objects_check = 'X'
iv_without_locking = 'X'
exceptions
cts_initialization_failure = 1
enqueue_failed = 2
no_authorization = 3
invalid_request = 4
request_already_released = 5
repeat_too_early = 6
object_lock_error = 7
object_check_error = 8
docu_missing = 9
db_access_error = 10
action_aborted_by_user = 11
export_failed = 12
execute_objects_check = 13
release_in_bg_mode = 14
release_in_bg_mode_w_objchk = 15
error_in_export_methods = 16
object_lang_error = 17
others = 18.
if sy-subrc = 0.
call method g_log->add_text
exporting
iv_type = 'S'
iv_text = 'Oluşturulan TOC requesti release edildi'.
else.
call function 'TRINT_RELEASE_REQUEST'
exporting
iv_trkorr = gv_toc
iv_success_message = ''
iv_dialog = 'X'
iv_without_objects_check = 'X'
iv_without_locking = 'X'
exceptions
cts_initialization_failure = 1
enqueue_failed = 2
no_authorization = 3
invalid_request = 4
request_already_released = 5
repeat_too_early = 6
object_lock_error = 7
object_check_error = 8
docu_missing = 9
db_access_error = 10
action_aborted_by_user = 11
export_failed = 12
execute_objects_check = 13
release_in_bg_mode = 14
release_in_bg_mode_w_objchk = 15
error_in_export_methods = 16
object_lang_error = 17
others = 18.
if sy-subrc = 0.
call method g_log->add_text
exporting
iv_type = 'S'
iv_text = 'Oluşturulan TOC requesti release edildi'.
else.
g_log->add_message_simple( ).
return.
endif.

endif.

* call function 'CTS_WBO_API_RELEASE_REQ'


* exporting
* trkorr = gv_toc
* importing
* result = lv_result
* messages = ls_messages
* request = ls_request.
*
* if lv_result eq 'E'.
* loop at ls_messages assigning field-symbol(<ls_messages>).
* g_log->add_text( iv_type = <ls_messages>-severity
* iv_text = conv #( <ls_messages>-text ) ).
* endloop.
* else.
* call method g_log->add_text
* exporting
* iv_type = 'S'
* iv_text = 'Oluşturulan TOC requesti release edildi'.
* endif.

endform.

*&---------------------------------------------------------------------*
*& Form IMPORT_ET
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form import_et using p_req_target.

data: lt_req type table of cts_req,


lt_req_buff type tmsiqreqs with header line,
lt_req_trs type stms_tr_requests with header line.

data: ls_req like line of lt_req.


data: lv_sysname type tmssysnam.
data: lv_client type c length 3.

data: lv_message type c length 80.


data: lv_retcode type c length 3.
lv_sysname = p_req_target+0(3).
lv_client = p_req_target+4(3).

if r_qas = abap_false.
data lv_target like lv_sysname.
call function 'TMS_UI_FORWARD_TR_REQUEST'
exporting
iv_request = gv_toc
iv_target = lv_sysname
importing
ev_target = lv_target
exceptions
cancelled_by_user = 1
forward_request_failed = 2
others = 3.
if sy-subrc = 1.
return.
elseif sy-subrc <> 0.
g_log->add_message_simple( ).
* return.
elseif lv_target <> lv_sysname.
g_log->add_text( iv_type = 'E'
iv_text = 'Hedef sistemi değiştirmeyin.'
).
return.
endif.
endif.

call function 'TMS_UIQ_IQD_READ_QUEUE'


exporting
iv_system = lv_sysname
iv_collect = 'X'
iv_max_exp = '010'
iv_monitor = 'X'
iv_verbose = ''
iv_use_data = ''
iv_read_shadow = 'X'
importing
et_requests = lt_req_buff[]
exceptions
read_queue_failed = 1
others = 2.

if sy-subrc <> 0.
if sy-msgty = 'X'.
sy-msgty = 'E'.
endif.
g_log->add_message_simple( ).
return.
endif.

loop at lt_req_buff where "nodataflg = abap_true and


actflg <> 'D'.
if lt_req_buff-trkorr = gv_toc.
move-corresponding lt_req_buff to lt_req_trs.
append lt_req_trs.
endif.
endloop.

check lines( lt_req_trs ) > 0.


* loop at lt_req_trs where nodataflg = abap_true.
*
* endloop.
*
* if sy-subrc = 0.

call function 'TMS_UI_TRANSMIT_TR_QUEUE' "TMS_MGR_TRANSMIT_TR_QUEUE


exporting
iv_system = lv_sysname
it_requests = lt_req_trs[]
exceptions
cancelled_by_user = 1
without_refresh = 2
transmit_queue_failed = 3
others = 4.
if sy-subrc = 1.
return.
elseif sy-subrc <> 0.
if sy-msgty = 'X'.
sy-msgty = 'E'.
endif.

g_log->add_message_simple( ).
return.
endif.

lt_req = value #( ( request = gv_toc ) ).

call function 'CTS_API_IMPORT_CHANGE_REQUEST'


exporting
system = lv_sysname+0(3)
client = lv_client
importing
message = lv_message
retcode = lv_retcode
tables
requests = lt_req.

* call function 'TMW_IMPORT_REQUESTS'


* destination lv_rfcdest
* exporting
** IV_IMPORT_PROJECT =
** IV_READ_SHADOW =
** IV_ONLINE =
* iv_transport_track = ''
** IV_IGNORE_LOCK =
** IV_ALL_ALERTS =
** IV_MONITOR =
** IV_VERBOSE =
** IV_TRANSMIT_TR_QUEUE =
** IV_FEEDBACK =
** IS_BATCH =
** IT_PROJECTS =
* it_request = lt_request
* is_target = ls_target
* it_pre_systems = lt_pre_sys
** IMPORTING
** EV_TP_RET_CODE =
** ET_TP_IMPORTS =
** ET_ALERT =
** EXCEPTIONS
** READ_CONFIG_FAILED = 1
** TABLE_OF_PROJECTS_IS_EMPTY = 2
** TABLE_OF_REQUESTS_IS_EMPTY = 3
** OTHERS = 4
* .
* if sy-subrc <> 0.
* Implement suitable error handling here
* endif.

if lv_retcode eq 0.
call method g_log->add_text
exporting
iv_type = 'S'
iv_text = |{ lv_message }|. "conv #( lv_message )
else.
call method g_log->add_text
exporting
iv_type = 'E'
iv_text = |Kod: { lv_retcode } Msg: { lv_message }|. "conv #( lv_message )
endif.

endform.
*&---------------------------------------------------------------------*
*& Form CREATE_REQUEST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form create_request .
data: lt_users type scts_users.
data: ls_request_header type trwbo_request_header.
data: lt_task_headers type table of trwbo_request_header.
data lt_attributes type scts_attrs.
data: lv_type type c length 1.
data: lv_target type tr_target.

lv_type = 'T'.
lv_target = p_target+0(3).
append sy-uname to lt_users.

call function 'TR_INSERT_REQUEST_WITH_TASKS'


exporting
iv_type = lv_type
iv_text = gv_text
iv_owner = sy-uname
iv_target = lv_target
it_attributes = lt_attributes
it_users = lt_users
importing
es_request_header = ls_request_header
et_task_headers = lt_task_headers
exceptions
insert_failed = 1
enqueue_failed = 2
others = 3.

if sy-subrc eq 0.
call method g_log->add_text
exporting
iv_type = 'S'
iv_text = 'TOC requesti oluşturuldu'.
elseif sy-subrc <> 0.
if sy-msgid is not initial.
g_log->add_message_simple( ).
else.
g_log->add_text( iv_type = 'E' iv_text = 'Request yaratılırken bilinmeyen bir
hata oluştu' ).
endif.
perform log_show.
endif.

gv_toc = ls_request_header-trkorr.

endform.

*&---------------------------------------------------------------------*
*& Form LOG_SHOW
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form log_show .

call method g_log->display_log


exporting
iv_title = 'LOG LİSTESİ'
iv_tree_by_detlevel = 'X'
iv_as_popup = 'X'
iv_use_grid = 'X'
exceptions
internal_error = 1
others = 2.

endform.
*&---------------------------------------------------------------------*
*& Form SELECTION_SCREEN
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form selection_screen .
data: lt_requests type table of trwbo_request.
data: ls_requests like line of lt_requests.

if r_none eq abap_true.
message 'Lütfen hedef sistem seçiniz.' type 'E'.
endif.

condense: p_reqst no-gaps, p_toc no-gaps.

if p_toc is not initial.

call function 'TR_READ_REQUEST_WITH_TASKS'


exporting
iv_trkorr = p_toc
importing
et_requests = lt_requests
exceptions
invalid_input = 1
others = 2.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
loop at lt_requests into ls_requests where h-trkorr eq p_toc.
if ls_requests-h-as4text np 'TOC *' or
ls_requests-h-as4text+4(3) <> sy-sysid or
ls_requests-h-as4text+15(3) <> sy-mandt.
message 'TOC Request ZTOCR programı ile oluşturulmamış' type 'E'.
endif.
endloop.
endif.

perform fill_req_target
* using r_dp r_mig r_ppr r_qas r_qal

changing p_target.
**

endform.
*&---------------------------------------------------------------------*
*& Form FILL_REQ_TARGET
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_P_TARGET text
*----------------------------------------------------------------------*
form fill_req_target "using p_r_dp p_r_mig p_r_ppr p_r_qas p_r_qal
changing p_req_target.

data: lt_requests type table of trwbo_request.


data: ls_requests like line of lt_requests.

call function 'TR_READ_REQUEST_WITH_TASKS'


exporting
iv_trkorr = p_reqst
importing
et_requests = lt_requests
exceptions
invalid_input = 1
others = 2.
if sy-subrc <> 0.
* message id sy-msgid type sy-msgty number sy-msgno
* with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
loop at lt_requests into ls_requests.
if ls_requests-h-trkorr eq p_reqst and
ls_requests-h-trfunction eq 'T'.
message 'TOC Requestler referans alınamaz !' type 'E'.
clear ls_requests.
exit.
endif.
endloop.

* case abap_true.
* when p_r_dp.
* if sy-sysid+0(1) = 'D'.
* concatenate 'P' sy-sysid+1(2) '.6' sy-mandt+1(2) into p_req_target.
* else.
* concatenate 'D' sy-sysid+1(2) '.1' sy-mandt+1(2) into p_req_target.
* endif.
* when p_r_mig.
* if sy-sysid+0(1) = 'D'.
* concatenate 'D' sy-sysid+1(1) 'M.300' into p_req_target.
* else.
* concatenate 'P' sy-sysid+1(1) 'M.800' into p_req_target.
* endif.
* when p_r_ppr.
* if sy-sysid+0(1) = 'D'.
* concatenate 'D' sy-sysid+1(1) 'R.300' into p_req_target.
* else.
* concatenate 'P' sy-sysid+1(1) 'R.800' into p_req_target.
* endif.
* when p_r_qas or p_r_qal.
if p_reqst is not initial.
loop at lt_requests into ls_requests.
if ls_requests-h-trkorr eq p_reqst.
if ls_requests-h-tarsystem is initial.
select single tarsystem from e070 into ls_requests-h-tarsystem where
trkorr = ls_requests-h-strkorr.
endif.
* if ls_requests-h-tarsystem+0(1) = 'D'.
concatenate ls_requests-h-tarsystem '.100' into p_req_target.
* else.
* concatenate ls_requests-h-tarsystem '.800' into p_req_target.
* endif.
exit.
endif.
endloop.
else.
p_target = ' '.
endif.
* when others.
* endcase.

endform.

*&---------------------------------------------------------------------*
*& Form COMPARE_REPOSITORY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form compare_repository.

data lv_rfcdest type rfcdest.

concatenate p_target+0(3) 'CLNT' p_target+4(3) into lv_rfcdest.

data(lt_bdcdata) = value bdcdata_tab(


( program = 'RSSYSCOMP' dynpro = '0100' dynbegin = 'X' )
( fnam = 'BDC_OKCODE' fval = '=BILD_CROSS' )
( fnam = 'VERS_DEST-RFCDEST' fval = lv_rfcdest )
( fnam = 'RADIO_PAKET' fval = '' )
( fnam = 'RADIO_REQ' fval = 'X' )
( fnam = 'REQ_NAME' fval = p_reqst )

( program = 'RSSYSCOMP' dynpro = '0200' dynbegin = 'X' )


( fnam = 'BDC_OKCODE' fval = '=COMP_VERS' )
( fnam = 'LV_COMPLANGS' fval = 'X' )

( program = 'RSSYSCOMP' dynpro = '0300' dynbegin = 'X' )


( fnam = 'BDC_OKCODE' fval = '' ) "=EXIT

( program = 'SAPLSPO1' dynpro = '0500' dynbegin = 'X' )


( fnam = 'BDC_OKCODE' fval = '=OPT2' )

( program = 'RSSYSCOMP' dynpro = '0200' dynbegin = 'X' )


( fnam = 'BDC_OKCODE' fval = '=EXIT' )

( program = 'RSSYSCOMP' dynpro = '0100' dynbegin = 'X' )


( fnam = 'BDC_OKCODE' fval = '=EXIT' ) ).

call function 'ABAP4_CALL_TRANSACTION'


starting new task 'ZTOCR'
exporting
tcode = 'SREPO'
mode_val = 'E'
tables
using_tab = lt_bdcdata
exceptions
call_transaction_denied = 1
tcode_invalid = 2
others = 3.

if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.

endform. " COMPARE_REPOSITORY

*&---------------------------------------------------------------------*
*& Form COMPARE_CUSTOMIZING
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form compare_customizing.

data lv_rfcdest type rfcdest.

concatenate p_target+0(3) 'CLNT' p_target+4(3) into lv_rfcdest.

data(lt_bdcdata) = value bdcdata_tab(


( program = 'SAPLSCT1' dynpro = '0310' dynbegin = 'X' )
( fnam = 'BDC_OKCODE' fval = '=CRE' )
( fnam = 'GS_DYN310-SEL_PROJ_IMG' fval = '' )
( fnam = 'GS_DYN310-SEL_TRANS' fval = 'X' )

( program = 'SAPLSCT1' dynpro = '0313' dynbegin = 'X' )


( fnam = 'BDC_OKCODE' fval = '=OKAY' )
( fnam = 'GS_DYN313-TRKORR' fval = p_reqst )

( program = 'SAPLSCT1' dynpro = '0315' dynbegin = 'X' )


( fnam = 'BDC_OKCODE' fval = '=CMPO' )
( fnam = 'GS_DYN315-WLTEXT' fval = 'ZTOCR' )
( fnam = 'GS_DYN315-CLIDEP' fval = 'X' )
( fnam = 'GS_DYN315-CLIIND' fval = 'X' )
( fnam = 'GS_DYN315-RFC_DEST' fval = lv_rfcdest )

"( program = 'SAPMSSY0' dynpro = '0120' dynbegin = 'X' )


).

call function 'ABAP4_CALL_TRANSACTION'


starting new task 'ZTOCR'
exporting
tcode = 'SCU0'
mode_val = 'E'
tables
using_tab = lt_bdcdata
exceptions
call_transaction_denied = 1
tcode_invalid = 2
others = 3.

if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform. " COMPARE_CUSTOMIZING

You might also like