You are on page 1of 10

*&---------------------------------------------------------------------*

*& Report RSDG_TRFN_ACTIVATE


*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
report rsdg_trfn_activate.

type-pools: rstr, rsdg, rsds, rsaa, rsau.


include rstran_migration_repair_f01.
tables sscrfields. "For user-commands on selection-screen
tables rstran. "for select options only
data: g_r_tranid type rstranid.
data: tlogorstlogo type rstlogo.
data: sourcetype type rstlogo.
data: sourcename type sobj_name.
data: targettype type rstlogo.
data: targetname type sobj_name.
DATA: tlogo_type TYPE rstlogo.
DATA: objnm_type TYPE sobj_name.
data: tranid type rstranid.
data: iobjnm type sobj_name.
data: objst type rsobjstat.
data: objvers type rsobjvers.
data: objvrs type rsobjvers.
data: dtp_m type rs_bool.
DATA: check_o TYPE rs_bool.
DATA: set_inactive TYPE rs_bool.
data: rtstpnm type rstran-tstpnm.
data: rtime type rstran-timestmp.
data: gs_text type ts_text,
gt_text_all type tt_text.
data: gt_tr_object type rs_t_tr_object.
data: l_msgty type sy-msgty.
data: l_inconsistent type rs_bool.
data: l_text type c length 150.
data: l_detlevel type ballevel.
data: l_string type string.
data: l_string_1 type string.
data: l_string_2 type string.
data: lt_text type table of string.
data: lt_text_all type table of string.
DATA: l_obj LIKE balhdri-object.
DATA: l_sub LIKE balhdri-subobject.
DATA: l_extnumber TYPE bal_s_log-extnumber.
data: l_subrc type sy-subrc.
data: ls_tran type rstran.
data: lt_tran type standard table of rstran with non-unique default k
ey.
data: lt_tran_sel type sorted table of rstran
with unique key tranid objvers.
data: lt_tran_sel_ina type sorted table of rstran
with unique key tranid objvers.
data: ls_dtp type rsbkdtp.
data: lt_dtp_all type standard table of rsbkdtp with non-unique default
key.
data: lt_dtp_m type standard table of rsbkdtp with non-unique default
key.
data: lt_dtp_a type standard table of rsbkdtp with non-unique default
key.
data: l_tgt type rsbktgtnm.
data: l_src type rsbksrcnm.
data: l_tgttp type rsbktgttp.
data: l_srctp type rsbksrctp.
data: l_subrc_n type numc1.

* selection screen
* main screen
selection-screen begin of block act with frame title text-001.
select-options tran_id for tranid.
parameters objstat like objst default rs_c_objstat-inactive obligatory.
select-options src_type for sourcetype.
select-options src_name for sourcename.
select-options trg_type for targettype.
select-options trg_name for targetname.
SELECT-OPTIONS mst_type FOR tlogo_type.
SELECT-OPTIONS mst_name FOR objnm_type.
selection-screen begin of block set with frame title text-003.
selection-screen begin of line.
PARAMETERS: chk_only LIKE check_o . "'Check only'.
SELECTION-SCREEN COMMENT (25) txt_chck. " FOR FIELD chk_only.
PARAMETERS: set_ina LIKE set_inactive.
SELECTION-SCREEN COMMENT (45) txt_ina.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
parameters: dtp_mod like dtp_m . "'Use M-version of DTP if exists'.
selection-screen comment (75) text. " FOR FIELD dtp_mod.
selection-screen end of line.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: with_cto TYPE rs_bool.
PARAMETERS: free TYPE rs_bool NO-DISPLAY DEFAULT rs_c_true.
PARAMETERS: p_obj LIKE balhdri-object NO-DISPLAY.
PARAMETERS: p_sub LIKE balhdri-subobject NO-DISPLAY.
PARAMETERS: p_ext LIKE balhdri-extnumber NO-DISPLAY.
PARAMETERS: p_debug TYPE rs_bool NO-DISPLAY DEFAULT rs_c_false.
SELECTION-SCREEN COMMENT (75) trsp. " FOR FIELD dtp_mod.
SELECTION-SCREEN END OF LINE.
selection-screen end of block set.
selection-screen end of block act.

selection-screen begin of block tec with frame title text-002.


select-options tstpnm for rtstpnm.
select-options tstp for rtime no-extension.
selection-screen end of block tec.
at selection-screen output.
text = 'Use M-version of DTP if exists'(s01).
txt_chck = 'Check Only'(s02).
txt_ina = 'Set erroneous objects to INA'(s04).
trsp = 'Transport recording for TRFN / DTP'(s03).

start-of-selection.
IF chk_only IS NOT INITIAL AND with_cto IS NOT INITIAL.
MESSAGE 'You cannot use ''Transport recording'' in combination with ''CHECK
ONLY'''(013) TYPE 'S'.
EXIT.
ENDIF.
IF set_ina IS NOT INITIAL AND chk_only IS INITIAL.
MESSAGE 'You can use ''Set INA'' only in combination with ''CHECK ONLY'''(01
4) TYPE 'S'.
EXIT.
ENDIF.
IF p_debug EQ rs_c_true.
CALL FUNCTION 'RSSM_SLEEP_DEBUG'
EXPORTING
i_always = p_debug
i_seconds = 100.
ENDIF.
IF cl_rso_application_log=>appl_log_get_log_handle( ) IS INITIAL.
IF p_obj IS NOT INITIAL.
l_obj = p_obj.
ELSE.
l_obj = rstr_c_appl_log_trfn.
ENDIF.
IF p_sub IS NOT INITIAL.
l_sub = p_sub.
ELSE.
l_sub = rstr_c_appl_log_trfn_content.
ENDIF.
IF p_ext IS NOT INITIAL.
l_extnumber = p_ext.
ELSE.
l_extnumber = 'RSDG_TRFN_ACTIVATE'.
ENDIF.
CALL METHOD cl_rso_application_log=>appl_log_create
EXPORTING
i_object = l_obj
i_subobject = l_sub
i_extnumber = l_extnumber.
endif.
cl_rs_utilities=>set_force_reload_off( ).
select * from rstran into table lt_tran_sel
where objvers = rs_c_objvers-active
and objstat = objstat
and tranid in tran_id
and sourcetype in src_type
and sourcename in src_name
and targettype in trg_type
and targetname in trg_name
and tstpnm in tstpnm
and timestmp in tstp
AND tlogo_owned_by IN mst_type
AND objnm_owned_by IN mst_name
and is_shadow = space.
if objstat = rs_c_objstat-inactive.
*-- add inactive 'M'-Version with corresponding A-Version objstat = 'ACT'
select * from rstran as t into table lt_tran_sel_ina
where ( objvers = rs_c_objvers-modified
and objstat = objstat )
and exists ( select * from rstran
where tranid = t~tranid
and objstat = rs_c_objstat-active )
and tranid in tran_id
and sourcetype in src_type
and sourcename in src_name
and targettype in trg_type
and targetname in trg_name
and tstpnm in tstpnm
and timestmp in tstp
AND tlogo_owned_by IN mst_type
AND objnm_owned_by IN mst_name
and is_shadow = space.
insert lines of lt_tran_sel_ina into table lt_tran_sel.
delete adjacent duplicates from lt_tran_sel comparing tranid.
endif.
lt_tran = lt_tran_sel.
*-- Transformations
clear gt_text_all.
loop at lt_tran into ls_tran.
* --
clear: lt_text[],
lt_text_all[].
CLEAR l_subrc.
clear l_inconsistent.
concatenate 'TRANID =' ls_tran-tranid 'OBJVERS =' ls_tran-objvers
into l_string separated by space.
append l_string to lt_text.
*--
concatenate ls_tran-sourcetype
ls_tran-sourcename
'->'
ls_tran-targettype
ls_tran-targetname
into l_string separated by space.
append l_string to lt_text.

loop at lt_text into l_string.


l_msgty = rs_c_info.
if sy-tabix = 1.
l_detlevel = 2.
else.
l_detlevel = 3.
endif.
l_text = l_string.
call method cl_rso_application_log=>if_rso_application_log~add_text
exporting
i_text = l_text
i_msgty = l_msgty
i_detlevel = l_detlevel.
endloop.
if ls_tran-objvers = rs_c_objvers-modified.
*-- transformation was select by M-Version + conditions, but always use A-Versio
n for the mass-activation
ls_tran-objvers = rs_c_objvers-active.
endif.
IF chk_only = rs_c_true.
PERFORM check_trfn
USING ls_tran-tranid
ls_tran-objvers
rs_c_false "without save
rs_c_true "with a-m version compare
with_cto "without transport
rs_c_true "with check
set_ina "set erroneus_object to ina in check mode
free "free the instance
CHANGING gt_text_all
l_subrc.
IF l_subrc NE 0.
l_text = 'Error / warning occurred'(t06).
CALL METHOD cl_rso_application_log=>if_rso_application_log~add_text
EXPORTING
i_text = l_text
i_msgty = rs_c_error
i_detlevel = '3'.
ENDIF.
PERFORM write_to_log
CHANGING gt_text_all.
ELSE.
perform activate_trfn
using ls_tran-tranid
ls_tran-objvers
rs_c_false "without save
rs_c_true "with a-m version compare
with_cto "from parameter
rs_c_true "with check
free "free the instance
CHANGING gt_text_all
l_subrc.
if l_subrc = 0.
*-- register DTP for processing later
l_src = ls_tran-sourcename.
case ls_tran-sourcetype.
when 'RSDS'.
l_srctp = 'DTASRC'.
when 'IOBJ'.
if ls_tran-sourcesubtype = 'TEXT'.
l_srctp = 'IOBJT'.
else.
l_srctp = 'IOBJA'.
endif.
when 'TRCS'. " InfoSource non persistent doesn't exist in DTP
clear l_src.
when others.
l_srctp = ls_tran-sourcetype.
endcase.
l_tgt = ls_tran-targetname.
case ls_tran-targettype.
when 'IOBJ'.
if ls_tran-targetsubtype = 'TEXT'.
l_tgttp = 'IOBJT'.
else.
l_tgttp = 'IOBJA'.
endif.
when 'TRCS'. " InfoSource non persistent doesn't exist in DTP
clear l_tgt.
when others.
l_tgttp = ls_tran-targettype.
endcase.
if l_src is not initial and l_tgt is not initial.
select * from rsbkdtp as t into table lt_dtp_a where
objvers = rs_c_objvers-active and
src = l_src and
srctp = l_srctp and
tgt = l_tgt and
tgttp = l_tgttp and
exists ( select * from rsbkdtpstat where
dtp = t~dtp and
objstat = rs_c_objstat-inactive ).
*-- always look for existing m-versions and merge
select * from rsbkdtp into table lt_dtp_m where
( objvers = rs_c_objvers-modified or objvers = rs_c_objvers-active
) and
src = l_src and
srctp = l_srctp and
tgt = l_tgt and
tgttp = l_tgttp.
elseif l_src is not initial.
select * from rsbkdtp as t into table lt_dtp_a where
objvers = rs_c_objvers-active and
src = l_src and
srctp = l_srctp and
exists ( select * from rsbkdtpstat where
dtp = t~dtp and
objstat = rs_c_objstat-inactive ).
*-- always look for existing m-versions and merge
select * from rsbkdtp into table lt_dtp_m where
( objvers = rs_c_objvers-modified or objvers = rs_c_objvers-active )
and
src = l_src and
srctp = l_srctp.
elseif l_tgt is not initial.
select * from rsbkdtp as t into table lt_dtp_a where
objvers = rs_c_objvers-active and
tgt = l_tgt and
tgttp = l_tgttp and
exists ( select * from rsbkdtpstat where
dtp = t~dtp and
objstat = rs_c_objstat-inactive ).
*-- always look for existing m-versions and merge
select * from rsbkdtp into table lt_dtp_m where
( objvers = rs_c_objvers-modified or objvers = rs_c_objvers-active )
and
tgt = l_tgt and
tgttp = l_tgttp.
endif.
loop at lt_dtp_m into ls_dtp
where objvers = rs_c_objvers-modified.
read table lt_dtp_m transporting no fields
with key dtp = ls_dtp-dtp
objvers = rs_c_objvers-active.
if sy-subrc = 0.
read table lt_dtp_a transporting no fields
with key dtp = ls_dtp-dtp.
if sy-subrc = 0.
if dtp_mod is initial.
delete lt_dtp_a index sy-tabix.
concatenate ls_dtp-dtp `: ` 'M-version vorhanden, Aktivierung nich
t durchgefhrt'(t01) into l_text.
call method cl_rso_application_log=>if_rso_application_log~add_tex
t
exporting
i_text = l_text
i_msgty = rs_c_warning
i_detlevel = '3'.
else.
modify lt_dtp_a from ls_dtp index sy-tabix transporting objvers.
endif.
else.
if dtp_mod is initial.
concatenate ls_dtp-dtp `: ` 'M-version exist, activation skipped'(
t01) into l_text.
call method cl_rso_application_log=>if_rso_application_log~add_tex
t
exporting
i_text = l_text
i_msgty = rs_c_warning
i_detlevel = '3'.
else.
append ls_dtp to lt_dtp_a.
endif.
endif.
*-- else "skip no active version before
endif.
endloop.
append lines of lt_dtp_a to lt_dtp_all.
else.
l_text = 'Error / warning occurred, activate manually with TRFN UI'(t02).
call method cl_rso_application_log=>if_rso_application_log~add_text
exporting
i_text = l_text
i_msgty = rs_c_error
i_detlevel = '3'.
endif.
perform write_to_log
changing gt_text_all.
ENDIF. " check transformations only
endloop.
IF chk_only = rs_c_false.
*-- DTPs
clear gt_text_all.
sort lt_dtp_all by dtp objvers.
delete adjacent duplicates from lt_dtp_all comparing dtp.
loop at lt_dtp_all into ls_dtp.
CLEAR l_subrc.
l_msgty = rs_c_info.
l_detlevel = '2'.
l_string = ls_dtp-dtp.
concatenate 'DTP: ' l_string into l_text.
call method cl_rso_application_log=>if_rso_application_log~add_text
exporting
i_text = l_text
i_msgty = l_msgty
i_detlevel = l_detlevel.
if ls_dtp-objvers = rs_c_objvers-modified.
l_text = 'M-version fr DTP Activation used., DTP_MOD Parameter set'(t03).
call method cl_rso_application_log=>if_rso_application_log~add_text
exporting
i_text = l_text
i_msgty = rs_c_warning
i_detlevel = '3'.
endif.
perform activate_dtp
using ls_dtp-dtp
ls_dtp-objvers
with_cto
free " free the instance
CHANGING gt_text_all
l_subrc.
if l_subrc <> 0.
l_text = 'Error / warning occurred, activate manually with DTP UI'(t04).
call method cl_rso_application_log=>if_rso_application_log~add_text
exporting
i_text = l_text
i_msgty = rs_c_error
i_detlevel = '3'.
endif.
perform write_to_log
changing gt_text_all.
endloop.
ENDIF. " check Transformations only
call method cl_rso_application_log=>if_rso_application_log~appl_log_save.
cl_rso_application_log=>appl_log_show_as_popup( ).
cl_rso_application_log=>appl_log_delete( ).
*&---------------------------------------------------------------------*
*& Form ACTIVATE_DTP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LS_DTP_DTP text
* -->P_LS_DTP_OBJVERS text
* <--P_GT_TEXT_ALL text
* <--P_L_SUBRC text
*----------------------------------------------------------------------*
form activate_dtp
using p_dtp type rsbkdtp-dtp
p_objvers type rsobjvers
p_with_cto type rs_bool
p_with_free TYPE rs_bool
CHANGING ct_text TYPE tt_text
cv_subrc type sysubrc.
data: l_errors_found type rs_bool,
lv_subrc type sysubrc,
lr_messages type ref to cl_rso_msg,
lt_messages type rs_t_msg,
ls_messages type rs_s_msg,
lr_collection type ref to cl_rsbk_dtp_collection,
lv_objnm type sobj_name,
ls_text type ts_text,
lv_not_modifyable type rs_bool,
lt_tlogo TYPE rso_th_tlogo,
l_r_dtp TYPE REF TO cl_rsbk_dtp.

create object lr_collection.


*--------------------------------------------------------------------*
*activate DTP
lv_objnm = p_dtp.
CALL METHOD cl_rsbk_dtp=>factory
EXPORTING
i_dtp = p_dtp
RECEIVING
r_r_dtp = l_r_dtp.

try.
call method lr_collection->add_tlogo
exporting
i_objnm = lv_objnm
i_with_cto = p_with_cto
importing
e_not_modifyable = lv_not_modifyable.
catch cx_rs_existing .
catch cx_rs_not_found .
endtry.
if lv_not_modifyable is not initial.
concatenate 'DTP' p_dtp 'nicht nderbar'(t05)
into ls_text-text
separated by space.
ls_text-status = gc_error.
ls_text-level = 3.
append ls_text to ct_text.
clear ls_text.
else.
try.
call method lr_collection->activate
exporting
i_with_cto = p_with_cto
i_force_activation = 'X'
i_show_check_protocol = ''
i_detlevel = '3'
importing
e_th_tlogo_error = lt_tlogo.
catch cx_rs_cancelled .
exit.
endtry.
if lt_tlogo is not initial.
cv_subrc = 99.
endif.
IF l_r_dtp IS BOUND.
CALL METHOD l_r_dtp->if_rso_tlogo_maintain~dequeue.
ENDIF.
ENDIF.
IF p_with_free IS NOT INITIAL.
IF l_r_dtp IS BOUND.
CALL METHOD l_r_dtp->if_rsbk_dtp_display~free.
ENDIF.
endif.
endform. " ACTIVATE_DTP