report z_verifica_user_exit line-size 140 no standard page heading.
*======================================================================*
* PROGRAMA...: Z_VERIFICA_USER_EXIT
*----------------------------------------------------------------------*
* OBJETIVO...: REVISA USER-EXITS EN UNA DETERMINADA TRANSACCION O
* PROGRAMA. *
*----------------------------------------------------------------------*
* PARAMETROS.: P_PROG = NOMBRE DE PROGRAMA A SER REVISADO
* P_TCODE = NOMBRE DE TRANSACCION A SER REVISADA
* OBS.: UM DOS DOIS PARÂMETROS ACIMA DEVE SER ESPECIFICADO
*
* P_INCL = DETERMINA SI LA REVISION DEBE TENER EN
* CONSIDERACION LOS INCLUDES.
* P_FUNC = DETERMINA SI LA REVISION DEBE TENER EN
* CONSIDERACION LAS FUNCIONES.
* P_SUBMIT= DETERMINA SI LA REVISION DEBE TENER EN
* CONSIDERACION LOS DEMAS PROGRAMAS LLAMADOS
* POR SUBMIT.
*
* P_NIVEL = DETERMINA EL NIVEL DE LA REVISION HECHA DENTRO
* DE LOS INCLUDES, FUNCIONES Y DEMAS PROGRAMAS.
* EN EL NIVEL 1 SOLAMENTE SERA TOMADOS EN
* CONSIDERACION EN EL PROGRAMA RAIZ. EN EL NIVEL
* 2 SE REVISARAN LOS INCLUDES, FUNCIONES DENTRO
* LOS INCLUDES, FUNCIONES DEL NIVEL 1 Y ASI
* SUCESIVAMENTE.
*
* OBS.: EN EL PARAMETRO P_NIVEL INFORMAR VALORES BAJOS,
* YA QUE A MAYOR NUMERO, MAYOR CANTIDAD DE CODIGO
* SERA ANALIZADO
*----------------------------------------------------------------------*
*
*======================================================================*
*----------------------------------------------------------------------*
* CONSTANTS
*----------------------------------------------------------------------*
constants: c_user_exit(22) type c value 'USEREXIT',
c_enhance(22) type c value 'CALL CUSTOMER-FUNCTION',
c_funcao_1(13) type c value 'CALLFUNCTION''',
c_funcao_2(13) type c value 'CALL FUNCTION',
c_include(07) type c value 'INCLUDE',
c_submit(06) type c value 'SUBMIT',
c_comentario type c value '*',
c_ponto type c value '.',
c_aspa type c value '''',
c_x type c value 'X'.
*----------------------------------------------------------------------*
* TABLAS INTERNAS
*----------------------------------------------------------------------*
data: begin of ti_programa occurs 0,
codigo_fonte like rssource-line,
end of ti_programa.
data: begin of ti_includes occurs 0,
nome like sy-repid,
nivel(2) type n,
end of ti_includes.
data: begin of ti_user_exit occurs 0,
programa like sy-repid,
linha(10) type n,
codigo_fonte like rssource-line,
nivel(2) type n,
end of ti_user_exit.
*----------------------------------------------------------------------*
* VARIABLE GLOBALES
*----------------------------------------------------------------------*
data: vg_caracter type c,
vg_palavra(50) type c,
vg_inicial like sy-index,
vg_conta_aspa type n,
vg_pname like tfdir-pname,
vg_texto(50) type c,
vg_contador like sy-tfill,
vg_nivel(2) type n,
vg_ini_contagem type c," INDICA QUE DEVE SER INICIADA A CONTADOR
vg_conta_espaco type n." TOTAL DE ESPACIOS ( MÁXIMO 2 )
*----------------------------------------------------------------------*
* PARAMETROS
*----------------------------------------------------------------------*
*- DATOS OBLIGATORIOS.
selection-screen begin of block bl01 with frame title text-001 .
parameters: p_prog like sy-repid,
p_tcode like sy-tcode.
selection-screen end of block bl01.
*- DATOS OPCIONALES.
selection-screen begin of block bl02 with frame title text-002.
parameters: p_incl as checkbox,
p_func as checkbox,
p_submit as checkbox,
p_nivel(2) type n.
selection-screen end of block bl02.
*----------------------------------------------------------------------*
* INICIO
*----------------------------------------------------------------------*
start-of-selection.
'
'
*- CONSISTÊNCIAS DOS PARÂMETROS.
perform consisti_parametros.
*- INICIALIZA TABELA.
perform inicializa_tabela.
*- VERIFICA SE NO PROGRAMA EXISTE ALGUM INCLUDE,FUNÇÃO OU SUBMIT.
perform verifica_include_funcao_submit.
*- ANALISA OS INCLUDES E PROCURA POR USER EXIT.
perform procura_user_exit.
*- ANALISA OS INCLUDES E PROCURA POR USER EXIT.
perform procura_enhancements.
*- EXIBE TODAS USER EXIT ENCONTRADAS.
perform exibe_user_exit.
*----------------------------------------------------------------------*
* FIM
*----------------------------------------------------------------------*
end-of-selection.
'
*&---------------------------------------------------------------------*
*& Form PROCURA_USER_EXIT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form procura_user_exit.
'
*- VERIFICA SE NOS INCLUDES SELECIONADOS EXISTEM USER EXITS.
loop at ti_includes.
*- ESVAZIA TABELA INTERNA.
refresh ti_programa.
*- REALIZA LEITURA DO INCLUDE ARMAZENANDO-O EM TABELA INTERNA
read report ti_includes-nome into ti_programa.
loop at ti_programa.
*- VERIFICA SE NA LINHA DO PROGRAMA EXISTE ALGUM INCLUDE.
search ti_programa-codigo_fonte for c_user_exit.
*- SE ENCONTROU INCLUDE E SE A LINHA NÃO ESTÁ COMENTADA...
if sy-subrc eq 0
and ti_programa-codigo_fonte+0(1) ne c_comentario.
clear ti_user_exit.
*- REMOVE ESPAÇOS NO INÍCIO DA STRING.
shift ti_programa-codigo_fonte left deleting leading space.
move: ti_includes-nome to ti_user_exit-programa,
sy-tabix to ti_user_exit-linha,
ti_programa-codigo_fonte to ti_user_exit-codigo_fonte,
ti_includes-nivel to ti_user_exit-nivel.
append ti_user_exit.
endif.
endloop.
endloop.
endform." PROCURA_USER_EXIT
'
*&---------------------------------------------------------------------*
*& Form PROCURA_ENHANCEMENTS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form procura_enhancements.
'
*- VERIFICA SE NOS INCLUDES SELECIONADOS EXISTEM USER EXITS.
loop at ti_includes.
*- ESVAZIA TABELA INTERNA.
refresh ti_programa.
*- REALIZA LEITURA DO INCLUDE ARMAZENANDO-O EM TABELA INTERNA
read report ti_includes-nome into ti_programa.
loop at ti_programa.
*- VERIFICA SE NA LINHA DO PROGRAMA EXISTE ALGUM INCLUDE.
search ti_programa-codigo_fonte for c_enhance.
*- SE ENCONTROU INCLUDE E SE A LINHA NÃO ESTÁ COMENTADA...
if sy-subrc eq 0
and ti_programa-codigo_fonte+0(1) ne c_comentario.
clear ti_user_exit.
*- REMOVE ESPAÇOS NO INÍCIO DA STRING.
shift ti_programa-codigo_fonte left deleting leading space.
move: ti_includes-nome to ti_user_exit-programa,
sy-tabix to ti_user_exit-linha,
ti_programa-codigo_fonte to ti_user_exit-codigo_fonte,
ti_includes-nivel to ti_user_exit-nivel.
append ti_user_exit.
endif.
endloop.
endloop.
endform." PROCURA_ENHANCEMENTS
'
*&---------------------------------------------------------------------*
*& Form EXIBE_USER_EXIT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form exibe_user_exit.
perform cabecalho.
perform user_exit_nao_encontrada.
perform lista_user_exit_encontrada.
perform rodape.
endform." EXIBE_USER_EXIT
'
*&---------------------------------------------------------------------*
*& Form PROCURA_INCLUDE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form procura_include.
'
clear vg_palavra.
*- VERIFICA SE NA LINHA DO PROGRAMA EXISTE ALGUM INCLUDE.
search ti_programa-codigo_fonte for c_include.
*- SE ENCONTROU INCLUDE E SE A LINHA NÃO ESTÁ COMENTADA...
if sy-subrc eq 0
and ti_programa-codigo_fonte+0(1) ne c_comentario.
*- VERIFICA TODOS OS 72 CARACTERES DA LINHA PARA MONTAR NOME DO INCLUDE
do 72 times.
vg_inicial = sy-index - 1.
move ti_programa-codigo_fonte+vg_inicial(1) to vg_caracter.
if not vg_caracter is initial.
*- VERIFICA SE NÃO É FIM DO COMANDO.
if vg_caracter eq c_ponto.
exit.
endif.
*- MONTA PALAVRA.
concatenate vg_palavra vg_caracter into vg_palavra.
*- CONVERTE PARA MAÍUSCULA PARA FUTURA COMPARAÇÃO.
translate vg_palavra to upper case.
*- SE ENCONTROU ALGUM INCLUDE
if vg_palavra eq c_include.
clear vg_palavra.
endif.
endif.
enddo.
*- SALVA NOME DO INCLUDE PARA FUTURA PESQUISA POR USER EXIT.
read table ti_includes with key nome = vg_palavra.
if not sy-subrc is initial.
if vg_nivel le p_nivel.
move: vg_palavra to ti_includes-nome,
vg_nivel to ti_includes-nivel.
append ti_includes.
endif.
endif.
endif.
endform." PROCURA_INCLUDE
'
*&---------------------------------------------------------------------*
*& Form PROCURA_FUNCAO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form procura_funcao.
'
clear: vg_conta_aspa,
vg_palavra.
*- VERIFICA SE NA LINHA DO PROGRAMA EXISTE ALGUM INCLUDE.
search ti_programa-codigo_fonte for c_funcao_2.
*- SE ENCONTROU INCLUDE E SE A LINHA NÃO ESTÁ COMENTADA...
if sy-subrc eq 0
and ti_programa-codigo_fonte+0(1) ne c_comentario.
*- VERIFICA TODOS OS 72 CARACTERES DA LINHA PARA MONTAR NOME DO INCLUDE
do 72 times.
vg_inicial = sy-index - 1.
move ti_programa-codigo_fonte+vg_inicial(1) to vg_caracter.
if not vg_caracter is initial.
*- VERIFICA SE NÃO É FIM DO COMANDO.
if vg_caracter eq c_aspa.
add 1 to vg_conta_aspa.
if vg_conta_aspa eq 2.
exit.
endif.
endif.
*- MONTA PALAVRA.
concatenate vg_palavra vg_caracter into vg_palavra.
*- CONVERTE PARA MAÍUSCULA PARA FUTURA COMPARAÇÃO.
translate vg_palavra to upper case.
*- SE ENCONTROU ALGUM INCLUDE
if vg_palavra eq c_funcao_1.
clear vg_palavra.
endif.
endif.
enddo.
*- PESQUISA NOME DA FUNÇÃO PARA FUTURA PESQUISA POR USER EXIT.
clear vg_pname.
select single pname
into vg_pname
from tfdir
where funcname eq vg_palavra.
if sy-subrc eq 0.
read table ti_includes with key nome = vg_pname.
if not sy-subrc is initial.
if vg_nivel le p_nivel.
move: vg_pname to ti_includes-nome,
vg_nivel to ti_includes-nivel.
append ti_includes.
endif.
endif.
endif.
endif.
endform." PROCURA_FUNCAO
'
*&---------------------------------------------------------------------*
*& Form VERIFICA_INCLUDE_FUNCAO_SUBMIT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form verifica_include_funcao_submit.
'
loop at ti_includes.
add 1 to vg_contador.
describe table ti_includes.
perform evitar_time_out using sy-tfill.
move ti_includes-nivel to vg_nivel.
add 1 to vg_nivel.
*- ESVAZIA TABELA INTERNA.
refresh ti_programa.
*- REALIZA LEITURA DO INCLUDE/FUNÇÃO ARMAZENANDO EM TABELA INTERNA
read report ti_includes-nome into ti_programa.
loop at ti_programa.
*- PROCURA POR INCLUDES.
if p_incl eq c_x.
perform procura_include.
endif.
*- PROCURA POR FUNÇÃO.
if p_func eq c_x.
perform procura_funcao.
endif.
*- PROCURA POR SUBMIT.
if p_submit eq c_x.
perform procura_submit.
endif.
endloop.
endloop.
endform." VERIFICA_INCLUDE_FUNCAO_SUBMIT
'
*&---------------------------------------------------------------------*
*& Form EVITAR_TIME_OUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_SY_TFILL text
* -->P_SY_SUBRC text
*----------------------------------------------------------------------*
form evitar_time_out using p_sy_tfill.
'
data: vl_total(10) type n,
vl_atual(10) type n.
move: p_sy_tfill to vl_total,
vg_contador to vl_atual.
concatenate 'Total:' vl_total '-' 'Atual:' vl_atual
into vg_texto
separated by space.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
text = vg_texto.
endform." EVITAR_TIME_OUT
'
*&---------------------------------------------------------------------*
*& Form PROCURA_SUBMIT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form procura_submit.
'
clear: vg_conta_espaco, vg_palavra, vg_ini_contagem.
*- VERIFICA SE NA LINHA DO PROGRAMA EXISTE ALGUM INCLUDE.
search ti_programa-codigo_fonte for c_submit.
*- SE ENCONTROU INCLUDE E SE A LINHA NÃO ESTÁ COMENTADA...
if sy-subrc eq 0
and ti_programa-codigo_fonte+0(1) ne c_comentario.
*- VERIFICA TODOS OS 72 CARACTERES DA LINHA PARA MONTAR NOME DO INCLUDE
do 72 times.
vg_inicial = sy-index - 1.
move ti_programa-codigo_fonte+vg_inicial(1) to vg_caracter.
if vg_ini_contagem eq c_x and vg_caracter is initial.
add 1 to vg_conta_espaco.
endif.
if not vg_caracter is initial.
move c_x to vg_ini_contagem.
if vg_caracter eq c_ponto.
exit.
endif.
*- MONTA PALAVRA.
if vg_conta_espaco lt 2.
concatenate vg_palavra vg_caracter into vg_palavra.
*- CONVERTE PARA MAÍUSCULA PARA FUTURA COMPARAÇÃO.
translate vg_palavra to upper case.
*- SE ENCONTROU ALGUM INCLUDE
if vg_palavra eq c_submit.
clear vg_palavra.
endif.
else.
exit.
endif.
endif.
enddo.
*- PESQUISA NOME DA FUNÇÃO PARA FUTURA PESQUISA POR USER EXIT.
read table ti_includes with key nome = vg_palavra.
if not sy-subrc is initial.
if vg_nivel le p_nivel.
move: vg_palavra to ti_includes-nome,
vg_nivel to ti_includes-nivel.
append ti_includes.
endif.
endif.
endif.
endform." PROCURA_SUBMIT
'
*&---------------------------------------------------------------------*
*& Form CONSISTI_PARAMETROS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form consisti_parametros.
'
if p_nivel is initial.
move 1 to p_nivel.
endif.
if p_prog is initial and p_tcode is initial.
*- NOME DO PROGRAMA E NOME DA TRANSAÇÃO NÃO PODEM SER NULOS. UM DELES
*- DEVE SER INFORMADO.
message id 'ZF' type 'I' number '000' with text-003.
stop.
endif.
if not p_prog is initial and not p_tcode is initial.
*- SOLICITA AO USUÁRIO PARA INFORMAR O NOME DO PROGRAMA OU DA TRANSAÇÃO.
message id 'ZF' type 'I' number '000' with text-004.
stop.
endif.
endform." CONSISTI_PARAMETROS
'
*&---------------------------------------------------------------------*
*& Form INICIALIZA_TABELA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form inicializa_tabela.
data vl_pgmna like tstc-pgmna.
refresh ti_includes.
if not p_prog is initial.
move: p_prog to ti_includes-nome,
'0' to ti_includes-nivel.
append ti_includes.
elseif not p_tcode is initial.
select single pgmna
from tstc
into vl_pgmna
where tcode eq p_tcode.
if sy-subrc eq 0.
move: vl_pgmna to ti_includes-nome,
'0' to ti_includes-nivel.
append ti_includes.
endif.
endif.
endform." INICIALIZA_TABELA
'
*&---------------------------------------------------------------------*
*& Form CABECALHO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form cabecalho.
'
data vl_complemento(50) type c.
if p_tcode is initial.
concatenate 'NO PROGRAMA' p_prog
into vl_complemento
separated by space.
else.
concatenate 'EN LA TRANSACCION' p_tcode
into vl_complemento
separated by space.
endif.
format color col_key.
write: /001 sy-uline,
/001 sy-vline,
040 'RELACION DE USER-EXITS ENCONTRADAS', vl_complemento,
140 sy-vline,
/001 sy-uline.
write: /001 sy-vline,
003 'NOMBRE DEL PROGRAMA',
044 sy-vline,
046 'NIVEL',
052 sy-vline,
054 'LINEA',
065 sy-vline,
067 'TEXTO',
140 sy-vline,
/001 sy-uline.
endform." CABECALHO
'
*&---------------------------------------------------------------------*
*& Form USER_EXIT_NAO_ENCONTRADA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form user_exit_nao_encontrada.
describe table ti_user_exit.
check sy-tfill is initial.
format color col_normal intensified on.
write: /003 'NINGUNA USER-EXIT FUE LOCALIZADA!',
139 ' '.
format reset.
endform." USER_EXIT_NAO_ENCONTRADA
'
*&---------------------------------------------------------------------*
*& Form LISTA_USER_EXIT_ENCONTRADA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form lista_user_exit_encontrada.
'
data vl_cor type c.
loop at ti_user_exit.
if vl_cor eq c_x.
clear vl_cor.
else.
move c_x to vl_cor.
endif.
*- AJUSTA COR NA TELA.
if vl_cor eq c_x.
format color col_normal intensified on.
else.
format color col_normal intensified off.
endif.
*- INÍCIO DA IMPRESSÃO.
write: /003 ti_user_exit-programa,
046 ti_user_exit-nivel,
054 ti_user_exit-linha,
067 ti_user_exit-codigo_fonte,
139 ' '.
endloop.
endform." LISTA_USER_EXIT_ENCONTRADA
'
*&---------------------------------------------------------------------*
*& Form RODAPE
*&---------------------------------------------------------------------*
form rodape.
describe table ti_includes.
format color col_total.
write: /001 sy-uline,
/001 sy-vline,
003 'TOTAL DE PROGRAMAS ANALIZADOS:', sy-tfill,
' - NIVEL:', p_nivel,
140 sy-vline,
/001 sy-uline.
endform." RODAPE
Fuente
http://aprendeabap.com/documentos_ABAP/Z_VERIFICA_USER_EXIT.txt
Comentarios
Publicar un comentario