El siguiente report modifica el de Álvaro Tejada, porque lo copié tal cual y no me compilaba. Le metes un programa o transacción, y te dice las órdenes de transporte que afectan a dicho programa; muy útil si tienes que hacer un listado de las órdenes que has liberado y no tienes ni idea, sobre todo en empresas donde el usuario de desarrollo es para varias personas.
report z_ordenes.
*-----------------------------------------------------------------*
* Lista las órdenes de transporte de un programa o transacción *
* p_tcode --> transacción *
* p_pgmna --> programa *
*-----------------------------------------------------------------*
* Alberto García de Haro, 09/08/2007 *
*-----------------------------------------------------------------*
*-----------------------------------------------------------------*
* DECLARACION DE TYPES *
*-----------------------------------------------------------------*
types: begin of ty_e071,
trkorr type e071-trkorr,
object type e071-object,
obj_name type e071-obj_name,
end of ty_e071.
types: begin of ty_e071_entry,
trkorr type e071-trkorr,
end of ty_e071_entry.
types: begin of ty_e070,
trkorr type e070-trkorr,
trstatus type e070-trstatus,
tarsystem type e070-tarsystem,
as4user type e070-as4user,
as4date type e070-as4date,
as4time type e070-as4time,
as4text type e07t-as4text,
end of ty_e070.
types: begin of ctslg_action,
date like tstrfcofil-trdate,
time like tstrfcofil-trtime,
rc like tstrfcofil-retcode,
end of ctslg_action,
ctslg_actions type sorted table of ctslg_action
with unique key date time
initial size 2,
begin of ctslg_step,
clientid like tstrfcofil-tarclient,
stepid like tstrfcofil-function,
rc like tstrfcofil-retcode,
actions type ctslg_actions,
end of ctslg_step,
ctslg_steps type ctslg_step occurs 10,
begin of ctslg_system,
systemid like tstrfcofil-tarsystem,
rc like tstrfcofil-retcode,
steps type ctslg_steps,
end of ctslg_system,
ctslg_systems type ctslg_system occurs 10,
begin of ctslg_mergeline,
trkorr type trkorr,
rc like tstrfcofil-retcode,
end of ctslg_mergeline,
ctslg_mergelines type ctslg_mergeline occurs 0,
begin of ctslg_cofile,
exists type c,
imported type c,
del_lines_only type c,
systems type ctslg_systems,
merges type ctslg_mergelines,
rc type i,
end of ctslg_cofile.
*-----------------------------------------------------------------*
* DECLARACION DE TABLAS INTERNAS *
*-----------------------------------------------------------------*
data: t_e071 type standard table of ty_e071 with header line,
t_e070 type standard table of ty_e070 with header line,
t_e071_entry type standard table of ty_e071_entry
with header line,
doma_values type standard table of rpy_dval
with header line,
es_cofile type standard table of ctslg_cofile
with header line,
es_systems type standard table of ctslg_system,
wa_systems type ctslg_systems with header line,
es_steps type ctslg_steps,
wa_steps type ctslg_steps with header line,
es_actions type ctslg_actions,
wa_actions type ctslg_actions with header line.
*-----------------------------------------------------------------*
* DECLARACION DE VARIABLES *
*-----------------------------------------------------------------*
data: w_pgmna type tstc-pgmna,
w_name(41) type c,
w_flag type c.
*-----------------------------------------------------------------*
* DECLARACION DE FIELD-SYMBOLS *
*-----------------------------------------------------------------*
field-symbols:like line of t_e071,
like line of t_e070.
*-----------------------------------------------------------------*
* SELECTION-SCREEN *
*-----------------------------------------------------------------*
selection-screen begin of block data.
parameters:
p_tcode like tstc-tcode,
p_pgmna like tstc-pgmna.
selection-screen end of block data.
*-----------------------------------------------------------------*
* START-OF-SELECTION *
*-----------------------------------------------------------------*
start-of-selection.
perform validar_entrada.
if w_flag eq space.
perform obtener_ordenes.
perform imprimir_ordenes.
endif.
*&----------------------------------------------------------------*
*& Form VALIDAR_ENTRADA *
*&----------------------------------------------------------------*
form validar_entrada.
if p_tcode ne space.
select single pgmna
into w_pgmna
from tstc
where tcode eq p_tcode.
if sy-subrc eq 0.
w_flag = space.
else.
message s368(00) with 'La transacción solicitada no existe'.
w_flag = 'X'.
endif.
elseif p_pgmna ne space.
select single pgmna
into w_pgmna
from tstc
where pgmna eq p_pgmna.
if sy-subrc eq 0.
w_flag = space.
else.
message s368(00) with 'El programa solicitado no existe'.
w_flag = 'X'.
endif.
endif.
endform. " VALIDAR_ENTRADA
*&----------------------------------------------------------------*
*& Form OBTENER_ORDENES *
*&----------------------------------------------------------------*
form obtener_ordenes.
call function 'RPY_DOMAIN_READ'
exporting
doma_name = 'TRSTATUS'
language = sy-langu
tables
doma_values = doma_values
exceptions
cancelled = 1
not_found = 2
permission_error = 3
illegal_type = 4
others = 5.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
concatenate w_pgmna '%'
into w_name.
select trkorr object obj_name
into table t_e071
from e071
where obj_name like w_name
and object eq 'REPS'.
if not t_e071[] is initial.
loop at t_e071 assigning.
moveto t_e071_entry.
append t_e071_entry.
endloop.
sort t_e071_entry.
delete adjacent duplicates from t_e071_entry.
if not t_e071_entry[] is initial.
select e070~trkorr trstatus tarsystem
as4user as4date as4time
as4text
into table t_e070
from ( e070 inner join e07t
on e070~trkorr eq e07t~trkorr )
for all entries in t_e071_entry
where e070~trkorr eq t_e071_entry-trkorr
and langu eq sy-langu.
sort t_e070 by as4date as4time descending.
endif.
endif.
endform. " OBTENER_ORDENES
*&----------------------------------------------------------------*
*& Form IMPRIMIR_ORDENES *
*&----------------------------------------------------------------*
form imprimir_ordenes.
data: w_trkorr type e070-trkorr.
write:
1 'Orden' ,12 'Estado',
22 'Destino', 31 'Nombre',92 'Fecha',104 'Hora'.
loop at t_e070 assigning .
clear: es_cofile.
refresh: es_cofile.
call function 'TR_READ_GLOBAL_INFO_OF_REQUEST'
exporting
iv_trkorr =-trkorr
iv_dir_type = 'T'
importing
es_cofile = es_cofile.
append es_cofile.
read table es_cofile index 1.
move es_cofile-systems to es_systems.
loop at es_systems into wa_systems.
move wa_systems-steps to es_steps.
loop at es_steps into wa_steps. "WHERE STEPID EQ 'G'.
move wa_steps-actions to es_actions.
loop at es_actions into wa_actions.
endloop.
read table doma_values
with key domvalue_l =-trstatus.
if w_trkorr ne-trkorr.
w_trkorr =-trkorr.
skip 1.
endif.
write:/1-trkorr,12 doma_values-ddtext,
22 wa_systems-systemid,31-as4text,
92 wa_actions-date,104 wa_actions-time.
endloop.
endloop.
endloop.
endform. " IMPRIMIR_ORDENES
*-----------------------------------------------------------------*
* Lista las órdenes de transporte de un programa o transacción *
* p_tcode --> transacción *
* p_pgmna --> programa *
*-----------------------------------------------------------------*
* Alberto García de Haro, 09/08/2007 *
*-----------------------------------------------------------------*
*-----------------------------------------------------------------*
* DECLARACION DE TYPES *
*-----------------------------------------------------------------*
types: begin of ty_e071,
trkorr type e071-trkorr,
object type e071-object,
obj_name type e071-obj_name,
end of ty_e071.
types: begin of ty_e071_entry,
trkorr type e071-trkorr,
end of ty_e071_entry.
types: begin of ty_e070,
trkorr type e070-trkorr,
trstatus type e070-trstatus,
tarsystem type e070-tarsystem,
as4user type e070-as4user,
as4date type e070-as4date,
as4time type e070-as4time,
as4text type e07t-as4text,
end of ty_e070.
types: begin of ctslg_action,
date like tstrfcofil-trdate,
time like tstrfcofil-trtime,
rc like tstrfcofil-retcode,
end of ctslg_action,
ctslg_actions type sorted table of ctslg_action
with unique key date time
initial size 2,
begin of ctslg_step,
clientid like tstrfcofil-tarclient,
stepid like tstrfcofil-function,
rc like tstrfcofil-retcode,
actions type ctslg_actions,
end of ctslg_step,
ctslg_steps type ctslg_step occurs 10,
begin of ctslg_system,
systemid like tstrfcofil-tarsystem,
rc like tstrfcofil-retcode,
steps type ctslg_steps,
end of ctslg_system,
ctslg_systems type ctslg_system occurs 10,
begin of ctslg_mergeline,
trkorr type trkorr,
rc like tstrfcofil-retcode,
end of ctslg_mergeline,
ctslg_mergelines type ctslg_mergeline occurs 0,
begin of ctslg_cofile,
exists type c,
imported type c,
del_lines_only type c,
systems type ctslg_systems,
merges type ctslg_mergelines,
rc type i,
end of ctslg_cofile.
*-----------------------------------------------------------------*
* DECLARACION DE TABLAS INTERNAS *
*-----------------------------------------------------------------*
data: t_e071 type standard table of ty_e071 with header line,
t_e070 type standard table of ty_e070 with header line,
t_e071_entry type standard table of ty_e071_entry
with header line,
doma_values type standard table of rpy_dval
with header line,
es_cofile type standard table of ctslg_cofile
with header line,
es_systems type standard table of ctslg_system,
wa_systems type ctslg_systems with header line,
es_steps type ctslg_steps,
wa_steps type ctslg_steps with header line,
es_actions type ctslg_actions,
wa_actions type ctslg_actions with header line.
*-----------------------------------------------------------------*
* DECLARACION DE VARIABLES *
*-----------------------------------------------------------------*
data: w_pgmna type tstc-pgmna,
w_name(41) type c,
w_flag type c.
*-----------------------------------------------------------------*
* DECLARACION DE FIELD-SYMBOLS *
*-----------------------------------------------------------------*
field-symbols:
*-----------------------------------------------------------------*
* SELECTION-SCREEN *
*-----------------------------------------------------------------*
selection-screen begin of block data.
parameters:
p_tcode like tstc-tcode,
p_pgmna like tstc-pgmna.
selection-screen end of block data.
*-----------------------------------------------------------------*
* START-OF-SELECTION *
*-----------------------------------------------------------------*
start-of-selection.
perform validar_entrada.
if w_flag eq space.
perform obtener_ordenes.
perform imprimir_ordenes.
endif.
*&----------------------------------------------------------------*
*& Form VALIDAR_ENTRADA *
*&----------------------------------------------------------------*
form validar_entrada.
if p_tcode ne space.
select single pgmna
into w_pgmna
from tstc
where tcode eq p_tcode.
if sy-subrc eq 0.
w_flag = space.
else.
message s368(00) with 'La transacción solicitada no existe'.
w_flag = 'X'.
endif.
elseif p_pgmna ne space.
select single pgmna
into w_pgmna
from tstc
where pgmna eq p_pgmna.
if sy-subrc eq 0.
w_flag = space.
else.
message s368(00) with 'El programa solicitado no existe'.
w_flag = 'X'.
endif.
endif.
endform. " VALIDAR_ENTRADA
*&----------------------------------------------------------------*
*& Form OBTENER_ORDENES *
*&----------------------------------------------------------------*
form obtener_ordenes.
call function 'RPY_DOMAIN_READ'
exporting
doma_name = 'TRSTATUS'
language = sy-langu
tables
doma_values = doma_values
exceptions
cancelled = 1
not_found = 2
permission_error = 3
illegal_type = 4
others = 5.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
concatenate w_pgmna '%'
into w_name.
select trkorr object obj_name
into table t_e071
from e071
where obj_name like w_name
and object eq 'REPS'.
if not t_e071[] is initial.
loop at t_e071 assigning
move
append t_e071_entry.
endloop.
sort t_e071_entry.
delete adjacent duplicates from t_e071_entry.
if not t_e071_entry[] is initial.
select e070~trkorr trstatus tarsystem
as4user as4date as4time
as4text
into table t_e070
from ( e070 inner join e07t
on e070~trkorr eq e07t~trkorr )
for all entries in t_e071_entry
where e070~trkorr eq t_e071_entry-trkorr
and langu eq sy-langu.
sort t_e070 by as4date as4time descending.
endif.
endif.
endform. " OBTENER_ORDENES
*&----------------------------------------------------------------*
*& Form IMPRIMIR_ORDENES *
*&----------------------------------------------------------------*
form imprimir_ordenes.
data: w_trkorr type e070-trkorr.
write:
1 'Orden' ,12 'Estado',
22 'Destino', 31 'Nombre',92 'Fecha',104 'Hora'.
clear: es_cofile.
refresh: es_cofile.
call function 'TR_READ_GLOBAL_INFO_OF_REQUEST'
exporting
iv_trkorr =
iv_dir_type = 'T'
importing
es_cofile = es_cofile.
append es_cofile.
read table es_cofile index 1.
move es_cofile-systems to es_systems.
loop at es_systems into wa_systems.
move wa_systems-steps to es_steps.
loop at es_steps into wa_steps. "WHERE STEPID EQ 'G'.
move wa_steps-actions to es_actions.
loop at es_actions into wa_actions.
endloop.
read table doma_values
with key domvalue_l =
if w_trkorr ne
w_trkorr =
skip 1.
endif.
write:/1
22 wa_systems-systemid,31
92 wa_actions-date,104 wa_actions-time.
endloop.
endloop.
endloop.
endform. " IMPRIMIR_ORDENES
No hay comentarios:
Publicar un comentario