You are on page 1of 18

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

*& Report Z_REQUEST_PROGRAM_COMPARE


*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Programa: Z_REQUEST_PROGRAM_COMPARE
*
*& Descrio: Relatrio de comparao de request para objetos
*
*& Transao: *
*& Autor: Renato Martins
Data: 08.05.2014 *
*& Funcional Responsvel: *
*&---------------------------------------------------------------------*
*& Alterao 001
*
*& Autor: Renato Martins
Data: 23.05.2014 *
*& Informao: insero de informaes de hora e data de transporte
*
*&
da request, sem compara com os demais dados
*
*&---------------------------------------------------------------------*
************************************************************************
*** Declaraes
***
************************************************************************
REPORT z_request_program_compare.
************************************************************************
*** TYPE-POOLS
***
************************************************************************
TYPE-POOLS: icon, slis, kkblo.
************************************************************************
*** TABLES
***
************************************************************************
TABLES: e070.
************************************************************************
*** Definio de types
***
************************************************************************
TYPES: BEGIN OF gy_req,
trkorr TYPE e070-trkorr,
as4user TYPE e070-as4user,
END OF gy_req.
TYPES: BEGIN OF gy_reqt,
trkorr TYPE e07t-trkorr,
as4text TYPE e07t-as4text,
END OF gy_reqt.
TYPES: BEGIN OF gy_req_obj,
trkorr TYPE e071-trkorr,
object TYPE e071-object,
obj_name TYPE e071-obj_name,
pgmid
TYPE e071-pgmid,
END OF gy_req_obj.
TYPES: BEGIN OF
sysnam
ststxt
ordem

gy_ambiente,
TYPE tmscsys-sysnam,
TYPE tmscsys-systxt,
TYPE i,

END OF gy_ambiente.
TYPES: BEGIN OF gy_lista,
trkorr TYPE e070-trkorr,
as4text TYPE e07t-as4text,
as4user TYPE e070-as4user,
trs1_dt TYPE sy-datum,
trs1_uz TYPE sy-uzeit,
trs2_dt TYPE sy-datum,
trs2_uz TYPE sy-uzeit,
trs3_dt TYPE sy-datum,
trs3_uz TYPE sy-uzeit,
trs4_dt TYPE sy-datum,
trs4_uz TYPE sy-uzeit,
trs5_dt TYPE sy-datum,
trs5_uz TYPE sy-uzeit,
trs6_dt TYPE sy-datum,
trs6_uz TYPE sy-uzeit,
trs7_dt TYPE sy-datum,
trs7_uz TYPE sy-uzeit,
object TYPE e071-object,
obj_name TYPE e071-obj_name,
status TYPE icons-text,
amb1_tr TYPE e070-trkorr,
amb1_dt TYPE sy-datum,
amb1_uz TYPE sy-uzeit,
amb2_tr TYPE e070-trkorr,
amb2_dt TYPE sy-datum,
amb2_uz TYPE sy-uzeit,
amb3_tr TYPE e070-trkorr,
amb3_dt TYPE sy-datum,
amb3_uz TYPE sy-uzeit,
amb4_tr TYPE e070-trkorr,
amb4_dt TYPE sy-datum,
amb4_uz TYPE sy-uzeit,
amb5_tr TYPE e070-trkorr,
amb5_dt TYPE sy-datum,
amb5_uz TYPE sy-uzeit,
amb6_tr TYPE e070-trkorr,
amb6_dt TYPE sy-datum,
amb6_uz TYPE sy-uzeit,
amb7_tr TYPE e070-trkorr,
amb7_dt TYPE sy-datum,
amb7_uz TYPE sy-uzeit,
END OF gy_lista.
************************************************************************
*** Definio de tababelas internas
***
************************************************************************
DATA: gt_req
TYPE TABLE OF gy_req,
gt_req_rel
TYPE TABLE OF gy_req,
gt_reqt
TYPE TABLE OF gy_reqt,
gt_reqt_rel
TYPE TABLE OF gy_reqt,
gt_req_obj
TYPE TABLE OF gy_req_obj,
gt_req_obj_rel TYPE TABLE OF gy_req_obj,
gt_log_transp TYPE TABLE OF tstrfcofil,
gt_amb_flow
TYPE TABLE OF tmsfsysl,
gt_amb_trans TYPE TABLE OF v_clidest,
gt_ambiente
TYPE TABLE OF gy_ambiente,
gt_lista
TYPE TABLE OF gy_lista.

************************************************************************
*** Definio de Tabelas Internas / Workareas
***
************************************************************************
DATA: gs_ambiente TYPE gy_ambiente,
gs_lista
TYPE gy_lista.
************************************************************************
*** Definio de Variveis
***
************************************************************************
DATA: gv_max_amb TYPE i.
************************************************************************
*** Definio de field_symbol
***
************************************************************************
FIELD-SYMBOLS: <gf_req>
TYPE gy_req,
<gf_req_rel>
TYPE gy_req,
<gf_reqt>
TYPE gy_reqt,
<gf_req_relt>
TYPE gy_reqt,
<gf_req_obj>
TYPE gy_req_obj,
<gf_req_obj_rel> TYPE gy_req_obj,
<gf_amb_flow>
TYPE tmsfsysl,
<gf_log_transp> TYPE tstrfcofil,
<gf_ambiente>
TYPE gy_ambiente,
<gf_lista>
TYPE gy_lista.
************************************************************************
*** Definio de objetos
***
************************************************************************
************************************************************************
*** Definio de constantes
***
************************************************************************
CONSTANTS: gc_corr TYPE e071-pgmid
VALUE 'CORR',
gc_tabu TYPE e071-pgmid
VALUE 'TABU',
gc_e
TYPE char1
VALUE 'E',
gc_g
TYPE char1
VALUE 'G',
gc_a
TYPE char1
VALUE 'A',
gc_status TYPE e070-trstatus VALUE 'R'.
************************************************************************
*** Definio de Ranges
***
************************************************************************
************************************************************************
*** Definio de variveis ALV
***
************************************************************************
DATA: gt_header
TYPE kkblo_t_listheader,
gt_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
DATA: gt_sort TYPE TABLE OF slis_sortinfo_alv.
DATA: gs_header TYPE kkblo_listheader,
gs_layout TYPE slis_layout_alv,
gs_sort TYPE slis_sortinfo_alv.
************************************************************************
*** Parmetros
***

************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK bloco01 WITH FRAME TITLE TEXT-010.
SELECT-OPTIONS: p_trkorr FOR e070-trkorr NO INTERVALS.
SELECTION-SCREEN END OF BLOCK bloco01.
************************************************************************
*** Include
***
************************************************************************
************************************************************************
*** INITIALIZATION
***
************************************************************************
INITIALIZATION.
************************************************************************
*** AT SELECTION-SCREEN
***
************************************************************************
AT SELECTION-SCREEN.
************************************************************************
*** AT SELECTION-SCREEN OUTPUT
***
************************************************************************
AT SELECTION-SCREEN OUTPUT.
************************************************************************
*** AT SELECTION-SCREEN ON VALUE-REQUEST
***
************************************************************************
************************************************************************
*** START-OF-SELECTION
***
************************************************************************
START-OF-SELECTION.
*** Obter ambientes
PERFORM f_obter_ambiente.
IF NOT gt_ambiente[] IS INITIAL.
*** Obter informaes da request inicial
PERFORM f_request_compare.
*** Criando tabela de sada
IF NOT gt_req[] IS INITIAL.
PERFORM f_criar_saida.
*** Processando request individualmente
UNASSIGN: <gf_req>.
LOOP AT gt_req
ASSIGNING <gf_req>.
READ TABLE gt_req_obj
TRANSPORTING NO FIELDS
WITH KEY trkorr = <gf_req>-trkorr

BINARY SEARCH.
UNASSIGN: <gf_req_obj>.
LOOP AT gt_req_obj
ASSIGNING <gf_req_obj>
FROM sy-tabix.
*** Obtendo request relacionadas
IF <gf_req_obj>-trkorr = <gf_req>-trkorr.
PERFORM f_request_relacionada USING <gf_req_obj>-trkorr
<gf_req_obj>-object
<gf_req_obj>-obj_name.
ELSE.
EXIT.
ENDIF.
ENDLOOP.
ENDLOOP.
ENDIF.
IF NOT gt_lista[] IS INITIAL.
*** Preenchendo status para lista final
PERFORM f_status_lista.
*** Exibindo resultado
PERFORM f_gerar_alv.
ENDIF.
ENDIF.
END-OF-SELECTION.
************************************************************************
*** FORMS
***
************************************************************************
*&---------------------------------------------------------------------*
*& Form: f_obter_ambiente
*
*& Descrio: Obtem ambientes e ordem de transporte
*
*&---------------------------------------------------------------------*
FORM f_obter_ambiente.
*** Varivel local
DATA: lv_ordem TYPE i VALUE 1.
*** Obtendo ambientes
CLEAR: gt_amb_flow, gt_amb_trans.
FREE: gt_amb_flow, gt_amb_trans.
CALL FUNCTION 'TMW_GET_TARGET_SYSTEMS'
EXPORTING
IV_SYSTEM
= sy-sysid
IV_CLIENT
= sy-mandt
TABLES
ET_TARGETS
= gt_amb_flow
ET_TRANSLAYERS
= gt_amb_trans
EXCEPTIONS
CANNOT_READ_CONFIGURATION = 1
OTHERS
= 2.
SORT gt_amb_flow ASCENDING BY sort.

*** Obtendo descries


IF sy-subrc EQ 0.
CLEAR: gt_ambiente, gs_ambiente.
FREE: gt_ambiente.
SELECT SINGLE sysnam systxt
INTO gs_ambiente
FROM tmscsys
WHERE sysnam = sy-sysid.
gs_ambiente-ordem = lv_ordem.
APPEND gs_ambiente TO gt_ambiente.
UNASSIGN: <gf_amb_flow>.
LOOP AT gt_amb_flow
ASSIGNING <gf_amb_flow>.
CLEAR:
SELECT
INTO
FROM
WHERE

gs_ambiente.
SINGLE sysnam systxt
gs_ambiente
tmscsys
sysnam = <gf_amb_flow>-sysnam.

lv_ordem = lv_ordem + 1.
gs_ambiente-ordem = lv_ordem.
APPEND gs_ambiente TO gt_ambiente.
ENDLOOP.
SORT gt_ambiente ASCENDING BY ordem.
gv_max_amb = LINES( gt_ambiente ).
ENDIF.
ENDFORM.

"f_obter_ambiente

*&---------------------------------------------------------------------*
*& Form: f_request_compare
*
*& Descrio: Obtem informao das request iniciais (filtro)
*
*&---------------------------------------------------------------------*
FORM f_request_compare.
*** Obtendo lista de objetos por request
CLEAR: gt_req.
FREE: gt_req.
SELECT trkorr as4user
INTO TABLE gt_req
FROM e070
WHERE trkorr IN p_trkorr
AND trstatus = gc_status.
SORT gt_req ASCENDING by trkorr.
IF NOT gt_req[] IS INITIAL.
CLEAR: gt_reqt.
FREE: gt_reqt.
SELECT trkorr as4text
INTO TABLE gt_reqt
FROM e07t
FOR ALL ENTRIES IN gt_req
WHERE trkorr = gt_req-trkorr.

SORT gt_reqt ASCENDING BY trkorr.


*** Obtendo objetos da request
CLEAR: gt_req_obj.
FREE: gt_req_obj.
SELECT trkorr object obj_name pgmid
INTO TABLE gt_req_obj
FROM e071
FOR ALL ENTRIES IN gt_req
WHERE trkorr = gt_req-trkorr.
*** Restries de objetos
*** CORR = textos
*** TABU = TVDIR e TDDAT
DELETE gt_req_obj WHERE pgmid = gc_corr.
DELETE gt_req_obj WHERE object = gc_tabu.
SORT gt_req_obj ASCENDING BY trkorr obj_name.
ENDIF.
ENDFORM.

"f_request_compare

*&---------------------------------------------------------------------*
*& Form: f_criar_saida
*
*& Descrio: Criao da informao de sada
*
*&---------------------------------------------------------------------*
FORM f_criar_saida.
*** Variveis locais
DATA: lv_cmp_dt TYPE fieldname,
lv_cmp_uz TYPE fieldname,
lv_ordem TYPE char1.
FIELD-SYMBOLS: <lf_cmp_dt> TYPE any,
<lf_cmp_uz> TYPE any.
CONSTANTS: lc_cmp_lst TYPE fieldname VALUE 'gs_lista-trs',
lc_cmp_dt TYPE fieldname VALUE '_dt',
lc_cmp_uz TYPE fieldname VALUE '_uz'.
*** Montando incio da tabela de sada
CLEAR: gt_lista.
FREE: gt_lista.
UNASSIGN: <gf_req_obj>.
LOOP AT gt_req_obj
ASSIGNING <gf_req_obj>.
CLEAR: gs_lista.
gs_lista-trkorr = <gf_req_obj>-trkorr.
gs_lista-object = <gf_req_obj>-object.
gs_lista-obj_name = <gf_req_obj>-obj_name.
UNASSIGN: <gf_req>.
READ TABLE gt_req
ASSIGNING <gf_req>
WITH KEY trkorr = <gf_req_obj>-trkorr
BINARY SEARCH.
IF sy-subrc EQ 0.

gs_lista-as4user = <gf_req>-as4user.
ENDIF.
UNASSIGN: <gf_reqt>.
READ TABLE gt_reqt
ASSIGNING <gf_reqt>
WITH KEY trkorr = <gf_req_obj>-trkorr
BINARY SEARCH.
IF sy-subrc EQ 0.
gs_lista-as4text = <gf_reqt>-as4text.
ENDIF.
*** Obtendo informaes de transporte para a request referenciada
CLEAR: gt_log_transp.
FREE: gt_log_transp.
CALL FUNCTION 'STRF_READ_COFILE'
EXPORTING
IV_DIRTYPE
= 'T'
IV_TRKORR
= gs_lista-trkorr
TABLES
TT_COFI_LINES = gt_log_transp
EXCEPTIONS
WRONG_CALL
= 1
NO_INFO_FOUND = 2
OTHERS
= 3.
IF sy-subrc EQ 0.
*** Obtendo informao transporte
UNASSIGN: <gf_ambiente>.
LOOP AT gt_ambiente
ASSIGNING <gf_ambiente>.
IF <gf_ambiente>-ordem = 1.
*** Obtendo data de ambiente DEV (ambiente 0)
*** Parmetro de busca
*** E = Criao de verses aps exportao
UNASSIGN: <gf_log_transp>.
READ TABLE gt_log_transp
ASSIGNING <gf_log_transp>
WITH KEY tarsystem = <gf_ambiente>-sysnam
function = gc_e.
***
***
***
***

ELSE.
Obtendo data de ambiente outros ambientes
Parmetro de busca
G = Gerao Abaps e telas
A = Ativao de objetos de data dictionary
UNASSIGN: <gf_log_transp>.
READ TABLE gt_log_transp
ASSIGNING <gf_log_transp>
WITH KEY tarsystem = <gf_ambiente>-sysnam
function = gc_g.
IF sy-subrc NE 0.
UNASSIGN: <gf_log_transp>.
READ TABLE gt_log_transp
ASSIGNING <gf_log_transp>
WITH KEY tarsystem = <gf_ambiente>-sysnam

function = gc_a.
ENDIF.
ENDIF.
IF sy-subrc EQ 0.
MOVE <gf_ambiente>-ordem TO lv_ordem.
CONCATENATE lc_cmp_lst lv_ordem lc_cmp_dt
INTO lv_cmp_dt.
ASSIGN (lv_cmp_dt) TO <lf_cmp_dt>.
CONCATENATE lc_cmp_lst lv_ordem lc_cmp_uz
INTO lv_cmp_uz.
ASSIGN (lv_cmp_uz) TO <lf_cmp_uz>.
<lf_cmp_dt> = <gf_log_transp>-trdate.
<lf_cmp_uz> = <gf_log_transp>-trtime.
ENDIF.
ENDLOOP.
ENDIF.
APPEND gs_lista To gt_lista.
ENDLOOP.
ENDFORM.

"f_criar_saida

*&---------------------------------------------------------------------*
*& Form: f_request_relacionada
*
*& Descrio: Obtem request relacionadas para os objetos da request
*
*&---------------------------------------------------------------------*
FORM f_request_relacionada USING pe_request TYPE e070-trkorr
pe_object TYPE e071-object
pe_program TYPE e071-obj_name.
*** Obtendo outras request para cada objeto de uma request incial
*** Restries de objetos
*** CORR = textos
*** TABU = TVDIR e TDDAT
CLEAR: gt_req_obj_rel.
FREE: gt_req_obj_rel.
SELECT trkorr object obj_name pgmid
INTO TABLE gt_req_obj_rel
FROM e071
WHERE object = pe_object
AND obj_name = pe_program.
*** Restries de objetos
*** CORR = textos
*** TABU = TVDIR e TDDAT
DELETE gt_req_obj_rel WHERE pgmid = gc_corr.
DELETE gt_req_obj_rel WHERE object = gc_tabu.
SORT gt_req_obj_rel ASCENDING BY trkorr obj_name.
IF NOT gt_req_obj_rel[] IS INITIAL.
CLEAR: gt_req_rel.
FREE: gt_req_rel.

SELECT
INTO
FROM
FOR
WHERE
AND

trkorr as4user
TABLE gt_req_rel
e070
ALL ENTRIES IN gt_req_obj_rel
trkorr = gt_req_obj_rel-trkorr
trstatus = gc_status.

SORT gt_req_rel ASCENDING by trkorr.


DELETE ADJACENT DUPLICATES FROM gt_req_rel COMPARING trkorr.
IF NOT gt_req_rel[] IS INITIAL.
CLEAR: gt_reqt_rel.
FREE: gt_reqt_rel.
SELECT trkorr as4text
INTO TABLE gt_reqt_rel
FROM e07t
FOR ALL ENTRIES IN gt_req_rel
WHERE trkorr = gt_req_rel-trkorr.
SORT gt_reqt_rel ASCENDING BY trkorr.
*** Obtendo informaes de transporte para as request
PERFORM f_log_transporte USING pe_request
pe_object
pe_program.
ENDIF.
ENDIF.
ENDFORM.

"f_request_relacionada

*&---------------------------------------------------------------------*
*& Form: f_log_transporte
*
*& Descrio: Obtem logs de transporte
*
*&---------------------------------------------------------------------*
FORM f_log_transporte USING pe_request TYPE e070-trkorr
pe_object TYPE e071-object
pe_program TYPE e071-obj_name.
*** Variveis locais
DATA: lv_cmp_tr TYPE
lv_cmp_dt TYPE
lv_cmp_uz TYPE
lv_ordem TYPE

fieldname,
fieldname,
fieldname,
char1.

FIELD-SYMBOLS: <lf_cmp_dt> TYPE any,


<lf_cmp_uz> TYPE any,
<lf_cmp_tr> TYPE any.
CONSTANTS: lc_cmp_amb TYPE fieldname VALUE '<gf_lista>-amb',
lc_cmp_dt TYPE fieldname VALUE '_dt',
lc_cmp_uz TYPE fieldname VALUE '_uz',
lc_cmp_tr TYPE fieldname VALUE '_tr'.
*** Log para requests iniciais
UNASSIGN: <gf_req_rel>.
LOOP AT gt_req_rel
ASSIGNING <gf_req_rel>.

CLEAR: gt_log_transp.
FREE: gt_log_transp.
CALL FUNCTION 'STRF_READ_COFILE'
EXPORTING
IV_DIRTYPE
= 'T'
IV_TRKORR
= <gf_req_rel>-trkorr
TABLES
TT_COFI_LINES = gt_log_transp
EXCEPTIONS
WRONG_CALL
= 1
NO_INFO_FOUND = 2
OTHERS
= 3.
IF sy-subrc EQ 0.
*** Obtendo informao transporte
UNASSIGN: <gf_ambiente>.
LOOP AT gt_ambiente
ASSIGNING <gf_ambiente>.
IF <gf_ambiente>-ordem = 1.
*** Obtendo data de ambiente DEV (ambiente 0)
*** Parmetro de busca
*** E = Criao de verses aps exportao
UNASSIGN: <gf_log_transp>.
READ TABLE gt_log_transp
ASSIGNING <gf_log_transp>
WITH KEY tarsystem = <gf_ambiente>-sysnam
function = gc_e.
ELSE.
*** Obtendo data de ambiente outros ambientes
*** Parmetro de busca
*** G = Gerao Abaps e telas
*** A = Ativao de objetos de data dictionary
UNASSIGN: <gf_log_transp>.
READ TABLE gt_log_transp
ASSIGNING <gf_log_transp>
WITH KEY tarsystem = <gf_ambiente>-sysnam
function = gc_g.
IF sy-subrc NE 0.
UNASSIGN: <gf_log_transp>.
READ TABLE gt_log_transp
ASSIGNING <gf_log_transp>
WITH KEY tarsystem = <gf_ambiente>-sysnam
function = gc_a.
ENDIF.
ENDIF.
IF sy-subrc EQ 0.
UNASSIGN: <gf_lista>.
READ TABLE gt_lista
ASSIGNING <gf_lista>
WITH KEY trkorr = pe_request
object = pe_object
obj_name = pe_program.
IF sy-subrc EQ 0.
MOVE <gf_ambiente>-ordem TO lv_ordem.

CONCATENATE lc_cmp_amb lv_ordem lc_cmp_dt


INTO lv_cmp_dt.
ASSIGN (lv_cmp_dt) TO <lf_cmp_dt>.
CONCATENATE lc_cmp_amb lv_ordem lc_cmp_uz
INTO lv_cmp_uz.
ASSIGN (lv_cmp_uz) TO <lf_cmp_uz>.
CONCATENATE lc_cmp_amb lv_ordem lc_cmp_tr
INTO lv_cmp_tr.
ASSIGN (lv_cmp_tr) TO <lf_cmp_tr>.
IF ( <gf_log_transp>-trdate > <lf_cmp_dt> ) OR
( ( <gf_log_transp>-trdate = <lf_cmp_dt> ) AND
( <gf_log_transp>-trtime > <lf_cmp_uz> ) ).
<lf_cmp_dt> = <gf_log_transp>-trdate.
<lf_cmp_uz> = <gf_log_transp>-trtime.
<lf_cmp_tr> = <gf_req_rel>-trkorr.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
ENDFORM.

"f_log_transporte

*&---------------------------------------------------------------------*
*& Form: f_log_transporte
*
*& Descrio: Obtem logs de transporte
*
*&---------------------------------------------------------------------*
FORM f_status_lista.
*** Variveis locais
DATA: lv_cont
TYPE
lv_contp TYPE
lv_cont_c TYPE
lv_contp_c TYPE
lv_cmp_a TYPE
lv_cmp_p TYPE
lv_dif
TYPE

i,
i,
char1,
char1,
fieldname,
fieldname,
i.

DATA: lv_nome TYPE char20,


lv_info TYPE char20,
lv_symbol TYPE icons-text.
FIELD-SYMBOLS: <lf_cmp_a> TYPE any,
<lf_cmp_p> TYPE any.
CONSTANTS: lc_cmp_amb TYPE fieldname VALUE '<gf_lista>-amb',
lc_cmp_tr TYPE fieldname VALUE '_tr',
lc_cmp_ini TYPE fieldname VALUE '<gf_lista>-trkorr'.
*** Verificando status
UNASSIGN: <gf_lista>.
LOOP AT gt_lista
ASSIGNING <gf_lista>.
lv_cont = 1.
lv_contp = lv_cont + 1.

WHILE lv_cont <= gv_max_amb.


CLEAR: lv_dif.
MOVE lv_cont TO lv_cont_c.
MOVE lv_contp TO lv_contp_c.
CONCATENATE lc_cmp_amb lv_cont_c lc_cmp_tr
INTO lv_cmp_a.
ASSIGN (lv_cmp_a) TO <lf_cmp_a>.
ASSIGN (lc_cmp_ini) TO <lf_cmp_p>.
IF ( NOT <lf_cmp_a> IS INITIAL ) AND ( NOT <lf_cmp_p> IS INITIAL ).
IF <lf_cmp_a> <> <lf_cmp_p>.
lv_dif = 1.
EXIT.
ENDIF.
ENDIF.
lv_cont = lv_cont + 1.
lv_contp = lv_cont + 1.
ENDWHILE.
IF lv_dif
lv_nome
lv_info
ELSE.
lv_nome
lv_info
ENDIF.

= 0.
= 'ICON_OKAY'.
= 'Request igual'.
= 'ICON_CANCEL'.
= 'Request diferente'.

*** cone de retorno


CALL FUNCTION 'ICON_CREATE'
EXPORTING
NAME
=
TEXT
=
INFO
=
ADD_STDINF
=
IMPORTING
RESULT
=
EXCEPTIONS
ICON_NOT_FOUND
=
OUTPUTFIELD_TOO_SHORT =
OTHERS
=

lv_nome
' '
lv_info
'X'
lv_symbol
1
2
3.

IF sy-subrc EQ 0.
WRITE lv_symbol TO <gf_lista>-status.
ENDIF.
ENDLOOP.
ENDFORM.

"f_status_lista

*&---------------------------------------------------------------------*
*& Form: f_gerar_alv
*
*& Descrio: Gerao do ALV com os resultados
*
*&---------------------------------------------------------------------*
FORM f_gerar_alv.
*** Definio de layout
PERFORM f_definir_layout_alv.

*** Montar campos para ALV


PERFORM f_montar_campos.
*** Executando relatrio
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program
= sy-repid
is_layout
= gs_layout
i_callback_top_of_page = 'TOP_OF_PAGE'
it_fieldcat
= gt_fieldcat[]
it_sort
= gt_sort[]
i_default
= 'X'
TABLES
t_outtab
= gt_lista
EXCEPTIONS
program_error
= 1
OTHERS
= 2.
ENDFORM.

" gerar_alv

*&---------------------------------------------------------------------*
*& Form: f_definir_layout_alv
*
*& Descrio: Define o layout para gerao de ALV
*
*&---------------------------------------------------------------------*
FORM f_definir_layout_alv.
*** Definio
CLEAR: gs_layout.
gs_layout-group_change_edit
gs_layout-box_tabname
gs_layout-zebra
gs_layout-colwidth_optimize
ENDFORM.

=
=
=
=

'X'.
'GT_LISTA'.
'X'.
'X'.

" definir_layout_alv

*&---------------------------------------------------------------------*
*& Form: f_montar_campos
*
*& Descrio: Monta os campos que sero exibidos
*
*&---------------------------------------------------------------------*
FORM f_montar_campos.
*** Variveis locais
DATA: lv_cont
TYPE
lv_cont_c TYPE
lv_cmp_tr TYPE
lv_cmp_dt TYPE
lv_cmp_uz TYPE
lv_nome_tr TYPE
lv_nome_dt TYPE
lv_nome_uz TYPE
CONSTANTS: lc_cmp_amb
lc_cmp_trs
lc_cmp_dt
lc_cmp_uz
lc_cmp_tr
lc_nome_tr
lc_nome_dt
lc_nome_uz

i,
char1,
fieldname,
fieldname,
fieldname,
dd03p-reptext,
dd03p-reptext,
dd03p-reptext.
TYPE
TYPE
TYPE
TYPE
TYPE
TYPE
TYPE
TYPE

fieldname VALUE 'AMB',


fieldname VALUE 'TRS',
fieldname VALUE '_DT',
fieldname VALUE '_UZ',
fieldname VALUE '_TR',
dd03p-reptext VALUE 'Request',
dd03p-reptext VALUE 'Data',
dd03p-reptext VALUE 'Hora'.

*** Montar quebra


PERFORM f_montar_quebra.
*** Montando campos
CLEAR: gt_fieldcat.
FREE: gt_fieldcat.
PERFORM: f_incluir_campo USING 'GT_LISTA' 'TRKORR'
0',
f_incluir_campo USING 'GT_LISTA' 'AS4TEXT'
f_incluir_campo USING 'GT_LISTA' 'AS4USER'
.

'Request'

'C' 'C31

'Descrio'
'Usurio'

'C' 'C310',
'C' 'C310'

*** Montando campos baseado na quantidade de ambientes


lv_cont = 1.
WHILE lv_cont <= gv_max_amb.
MOVE lv_cont TO lv_cont_c.
CONCATENATE lc_cmp_trs lv_cont_c lc_cmp_dt
INTO lv_cmp_dt.
CONCATENATE lc_cmp_trs lv_cont_c lc_cmp_uz
INTO lv_cmp_uz.
UNASSIGN: <gf_ambiente>.
READ TABLE gt_ambiente
ASSIGNING <gf_ambiente>
WITH KEY ordem = lv_cont.
IF sy-subrc EQ 0.
CONCATENATE lc_nome_dt <gf_ambiente>-sysnam
INTO lv_nome_dt
SEPARATED BY space.
CONCATENATE lc_nome_uz <gf_ambiente>-sysnam
INTO lv_nome_uz
SEPARATED BY space.
ENDIF.
PERFORM: f_incluir_campo USING 'GT_LISTA' lv_cmp_dt lv_nome_dt 'D' 'C510
',
f_incluir_campo USING 'GT_LISTA' lv_cmp_uz lv_nome_uz 'D' 'C510
'.
lv_cont = lv_cont + 1.
ENDWHILE.
*** Demais campos
PERFORM: f_incluir_campo USING 'GT_LISTA' 'OBJECT'
'Objeto'
'C' 'C81
0',
f_incluir_campo USING 'GT_LISTA' 'OBJ_NAME' 'Nome'
'C' 'C81
0',
f_incluir_campo USING 'GT_LISTA' 'STATUS'
'Comparao' 'C' 'C810'.
*** Montando campos baseado na quantidade de ambientes
lv_cont = 1.
WHILE lv_cont <= gv_max_amb.

MOVE lv_cont TO lv_cont_c.


CONCATENATE lc_cmp_amb lv_cont_c lc_cmp_tr
INTO lv_cmp_tr.
CONCATENATE lc_cmp_amb lv_cont_c lc_cmp_dt
INTO lv_cmp_dt.
CONCATENATE lc_cmp_amb lv_cont_c lc_cmp_uz
INTO lv_cmp_uz.
UNASSIGN: <gf_ambiente>.
READ TABLE gt_ambiente
ASSIGNING <gf_ambiente>
WITH KEY ordem = lv_cont.
IF sy-subrc EQ 0.
CONCATENATE lc_nome_tr <gf_ambiente>-sysnam
INTO lv_nome_tr
SEPARATED BY space.
CONCATENATE lc_nome_dt <gf_ambiente>-sysnam
INTO lv_nome_dt
SEPARATED BY space.
CONCATENATE lc_nome_uz <gf_ambiente>-sysnam
INTO lv_nome_uz
SEPARATED BY space.
ENDIF.
PERFORM: f_incluir_campo USING 'GT_LISTA' lv_cmp_tr lv_nome_tr 'C' 'C810
',
f_incluir_campo USING 'GT_LISTA' lv_cmp_dt lv_nome_dt 'D' 'C810
',
f_incluir_campo USING 'GT_LISTA' lv_cmp_uz lv_nome_uz 'D' 'C810
'.
lv_cont = lv_cont + 1.
ENDWHILE.
ENDFORM.

"f_montar_campos

*&---------------------------------------------------------------------*
*& Form: f_montar_quebra
*
*& Descrio: Monta as quebras e agrupamentos
*
*&---------------------------------------------------------------------*
FORM f_montar_quebra.
*** Variveis locais
DATA: lv_cont
TYPE
lv_cont_c TYPE
lv_cmp_dt TYPE
lv_cmp_uz TYPE

i,
char1,
fieldname,
fieldname.

CONSTANTS: lc_cmp_trs TYPE fieldname VALUE 'TRS',


lc_cmp_dt TYPE fieldname VALUE '_DT',
lc_cmp_uz TYPE fieldname VALUE '_UZ'.

*** Criando agrupamento


CLEAR: gt_sort, gs_sort.
FREE: gt_sort.
gs_sort-fieldname = 'TRKORR'.
gs_sort-group
= 'X'.
APPEND gs_sort TO gt_sort.
CLEAR: gs_sort.
gs_sort-fieldname = 'AS4TEXT'.
gs_sort-group
= 'X'.
APPEND gs_sort TO gt_sort.
CLEAR: gs_sort.
gs_sort-fieldname = 'AS4USER'.
gs_sort-group
= 'X'.
APPEND gs_sort TO gt_sort.
*** Agrupamento de informao da request
lv_cont = 1.
WHILE lv_cont <= gv_max_amb.
MOVE lv_cont TO lv_cont_c.
CONCATENATE lc_cmp_trs lv_cont_c lc_cmp_dt
INTO lv_cmp_dt.
CONCATENATE lc_cmp_trs lv_cont_c lc_cmp_uz
INTO lv_cmp_uz.
CLEAR: gs_sort.
gs_sort-fieldname = lv_cmp_dt.
gs_sort-group
= 'X'.
APPEND gs_sort TO gt_sort.
CLEAR: gs_sort.
gs_sort-fieldname = lv_cmp_uz.
gs_sort-group
= 'X'.
APPEND gs_sort TO gt_sort.
lv_cont = lv_cont + 1.
ENDWHILE.
ENDFORM.

"f_montar_quebra

*&---------------------------------------------------------------------*
*& Form: f_incluir_campo
*
*& Descrio: Incluir os campos para criao de estrutura ALV
*
*&---------------------------------------------------------------------*
FORM f_incluir_campo USING pe_tabela TYPE slis_fieldcat_alv-tabname
pe_campo TYPE slis_fieldcat_alv-fieldname
pe_titcol TYPE slis_fieldcat_alv-reptext_ddic
pe_tipo TYPE slis_fieldcat_alv-inttype
pe_color TYPE slis_fieldcat_alv-emphasize.
*** Catlogo
CLEAR: gt_fieldcat.
gt_fieldcat-fieldname
= pe_campo.
gt_fieldcat-tabname
= pe_tabela.
gt_fieldcat-reptext_ddic = pe_titcol.

gt_fieldcat-inttype
gt_fieldcat-emphasize
APPEND gt_fieldcat.
ENDFORM.

= pe_tipo.
= pe_color.
" incluir_campo

*&---------------------------------------------------------------------*
*& Form: top_of_page
*
*& Descrio: Ttulos e informaes de cabealho para ALV
*
*&---------------------------------------------------------------------*
FORM top_of_page.
*** Variveis
DATA: vl_dia(10),
vl_hora(10),
vl_data_low(10),
vl_data_high(10),
vl_temp(10)
TYPE c.
*** Ttulo do relatrio
CLEAR: gt_header, gs_header.
FREE: gt_header.
gs_header-typ = 'H'.
gs_header-info = 'Comparao de verso de programas por request'.
APPEND gs_header TO gt_header.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = gt_header.
ENDFORM.

"top_of_page