Вы находитесь на странице: 1из 10

*======================================================================*

* Lojas Americanas S.A.


*
* Programa : ZFINTESOR004
*
* Funo : Tabela de Contas do Ita - Modelo de SM30.
*
* Analista : Klber Souza
*
* Autor
: Bruno Santos
*
* Data
: 17.02.2014
*
*======================================================================*
* Log de Modificaes:
*
*======================================================================*
* Data
|Descrio
|Autor
*
*
|
|
*
*======================================================================*
REPORT zfintesor004 MESSAGE-ID z1
NO STANDARD PAGE HEADING
LINE-SIZE 120
LINE-COUNT 65.
*======================================================================*
* TABELAS TRANSPARENTES
*======================================================================*
TABLES: zfin_ccitau.
*======================================================================*
* INCLUDES
*======================================================================*
INCLUDE <icon>.
*======================================================================*
* ESTRUTURAS
*======================================================================*
TYPES:
BEGIN OF y_alteracoes,
row_id
TYPE int4,
fieldname TYPE lvc_fname,
value
TYPE char128,
END OF y_alteracoes.
*======================================================================*
* TABELAS INTERNAS
*======================================================================*
DATA: t_fieldcat
TYPE lvc_t_fcat,
t_sort
TYPE lvc_t_sort,
t_saida
TYPE TABLE OF zfin_ccitau,
t_crit
TYPE TABLE OF zfin_ccitau,
t_alteracoes TYPE TABLE OF y_alteracoes.
*======================================================================*
* WORK AREAS
*======================================================================*
DATA: wa_layout
TYPE lvc_s_layo,
wa_sort
TYPE lvc_s_sort,
wa_fieldcat TYPE lvc_s_fcat,
wa_saida
TYPE zfin_ccitau,
wa_crit
TYPE zfin_ccitau,
wa_alteracoes TYPE y_alteracoes.
*======================================================================*
* CONSTANTES

*======================================================================*
*======================================================================*
* VARIVEIS GLOBAIS
*======================================================================*
DATA: vl_edit,
vl_save,
vg_alv_top.
*======================================================================*
* RANGES
*======================================================================*
*======================================================================*
* OBJETOS
*======================================================================*
DATA: vg_variant
TYPE disvariant,
og_splitter
TYPE REF TO cl_gui_docking_container ,
dockingtop
TYPE REF TO cl_gui_docking_container,
alv_bottom
TYPE REF TO cl_gui_alv_grid,
alv_top
TYPE REF TO cl_gui_alv_grid,
alv_top2
TYPE REF TO cl_gui_alv_grid,
og_document
TYPE REF TO cl_dd_document,
og_doctable
TYPE REF TO cl_dd_table_element,
og_column
TYPE REF TO cl_dd_area.
*======================================================================*
* CLASSES
*======================================================================*
CLASS cl_gui_resources DEFINITION LOAD. "Class definition
*---------------------------------------------------------------------*
*
CLASS lcl_event_receiver DEFINITION
*---------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_data_changed FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed
e_onf4
e_onf4_before
e_onf4_after
e_ucomm
sender.
ENDCLASS.
"lcl_event_receiver DEFINITION
*---------------------------------------------------------------------*
*
CLASS lcl_event_receiver IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_data_changed.
PERFORM handle_data_changed USING er_data_changed
e_onf4
e_onf4_before
e_onf4_after
e_ucomm
sender.

ENDMETHOD.
ENDCLASS.

"handle_user command
"lcl_event_receiver IMPLEMENTATION

DATA: og_event
TYPE REF TO lcl_event_receiver,
og_event_aux TYPE REF TO lcl_event_receiver.
*======================================================================*
* TELA DE SELEO
*======================================================================*
*======================================================================*
* INICIALIZAO
*======================================================================*
INITIALIZATION.
*======================================================================*
* INCIO DO PROCESSAMENTO
*======================================================================*
START-OF-SELECTION.
"Seleciona a Tabela de Contas do ITAU
PERFORM seleciona_itau.
"Exibe os dados encontrados
PERFORM exibe_dados_consulta.
*======================================================================*
* FORMS
*======================================================================*
*&---------------------------------------------------------------------*
*&
Form SELECIONA_ITAU
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM seleciona_itau.
"Seleciona os Critrios Ativos
SELECT *
FROM zfin_ccitau
INTO TABLE t_saida.
SORT t_saida BY hkont ztxtcc.
"Limpa a varivel de controle de execuo do grid
CLEAR vg_alv_top.
ENDFORM.
" SELECIONA_ITAU
*&---------------------------------------------------------------------*
*&
Form EXIBE_DADOS_CONSULTA
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*

FORM exibe_dados_consulta .
"Mostra a barra de progresso
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
text = 'Montando o ALV Grid de Exibio.'.
"Monta a estrutura da fieldcat (ALV)
PERFORM monta_fieldcat_alv.
"Exibe o ALV Grid
PERFORM exibe_alv_grid.
ENDFORM.
" EXIBE_OPCAO_GRAFICA
*&---------------------------------------------------------------------*
*&
Form
MONTA_FIELDCAT_ALV
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM monta_fieldcat_alv.
"Monta a fieldcat
PERFORM preencher_fieldcat
USING:
"Conta Bancria
'HKONT'
'T_SAIDA' text-051 space space space space '15',
"Texto Ident. da Conta Ita
'ZTXTCC '
'T_SAIDA' text-060 space space space space '50'.
ENDFORM.
" MONTA_FIELDCAT_ALV
*&---------------------------------------------------------------------*
*&
Form PREENCHER_FIELDCAT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM preencher_fieldcat USING value(p_fieldname)
value(p_tabname)
value(p_text)
value(p_hot)
value(p_sum)
value(p_edit)
value(p_check)
value(p_outputlen).
STATICS vl_pos TYPE i.
vl_pos = vl_pos + 1.
wa_fieldcat-fieldname
wa_fieldcat-tabname
wa_fieldcat-scrtext_l
wa_fieldcat-hotspot
wa_fieldcat-col_pos
wa_fieldcat-do_sum
wa_fieldcat-edit
wa_fieldcat-checkbox

=
=
=
=
=
=
=
=

p_fieldname
p_tabname
p_text
p_hot
vl_pos
p_sum
p_edit
p_check

.
.
.
.
.
.
.
.

wa_fieldcat-outputlen = p_outputlen .
APPEND wa_fieldcat TO t_fieldcat.
CLEAR wa_fieldcat.
ENDFORM.
" PREENCHER_FIELDCAT
*&---------------------------------------------------------------------*
*&
Form EXIBE_ALV_GRID
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM exibe_alv_grid .
CALL SCREEN 2001.
ENDFORM.
" EXIBE_ALV_GRID
*&---------------------------------------------------------------------*
*&
Form GERA_ALV
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM gera_alv.
"Estruturas locais
DATA : t_exclude

TYPE ui_functions.

"Excluir barra de ferramentos do ALV Grid (Standard)


PERFORM exclui_barra_ferramentas CHANGING t_exclude.
"Layouts do ALV Grid
"A - todas as linhas, C - sem linha, B - uma linha
wa_layout-sel_mode = 'A'.
* wa_layout-cwidth_opt = 'X'.
wa_layout-zebra
= 'X'.
"Variantes do ALV grid
vg_variant-report = sy-repid.
"Cria o objeto ALV GRID
CREATE OBJECT alv_top
EXPORTING
i_parent = dockingtop.
"Eventos
SET HANDLER og_event->handle_data_changed FOR alv_top ACTIVATION 'X'.
"Registra os eventos ao clicar ENTER
alv_top->register_edit_event( EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter ).
"Registra o evento CHANGE quando so feitas mudanas nos campos
alv_top->register_edit_event( EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified ).

"Gera alv grid


alv_top->set_table_for_first_display(
EXPORTING is_layout
is_variant
i_save
it_toolbar_excluding
i_default
CHANGING
it_outtab
it_fieldcatalog
it_sort

=
=
=
=
=

wa_layout
vg_variant
'A'
t_exclude
'X'

= t_saida
= t_fieldcat
= t_sort
).

"Desabilita o ALV Grid para edio


alv_top->set_ready_for_input( EXPORTING i_ready_for_input = 0 ).
ENDFORM.
" GERA_ALV
*&---------------------------------------------------------------------*
*&
Form EXCLUI_BARRA_FERRAMENTAS
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM exclui_barra_ferramentas CHANGING t_exclude TYPE ui_functions.
"Excluir barra de ferramentas do ALV Grid
APPEND cl_gui_alv_grid=>mc_fc_info
APPEND cl_gui_alv_grid=>mc_fc_check
APPEND cl_gui_alv_grid=>mc_fc_loc_append_row
APPEND cl_gui_alv_grid=>mc_fc_loc_copy
APPEND cl_gui_alv_grid=>mc_fc_loc_copy_row
APPEND cl_gui_alv_grid=>mc_fc_loc_cut
APPEND cl_gui_alv_grid=>mc_fc_loc_delete_row
APPEND cl_gui_alv_grid=>mc_fc_loc_insert_row
APPEND cl_gui_alv_grid=>mc_fc_loc_move_row
APPEND cl_gui_alv_grid=>mc_fc_loc_paste
APPEND cl_gui_alv_grid=>mc_fc_loc_paste_new_row
APPEND cl_gui_alv_grid=>mc_fc_loc_undo
APPEND cl_gui_alv_grid=>mc_fc_print_prev
APPEND cl_gui_alv_grid=>mc_mb_export
APPEND cl_gui_alv_grid=>mc_fc_view_excel
APPEND cl_gui_alv_grid=>mc_fc_view_lotus
APPEND cl_gui_alv_grid=>mc_fc_view_crystal
APPEND cl_gui_alv_grid=>mc_fc_print
APPEND cl_gui_alv_grid=>mc_fc_detail
APPEND cl_gui_alv_grid=>mc_fc_graph
ENDFORM.

TO
TO
TO
TO
TO
TO
TO
TO
TO
TO
TO
TO
TO
TO
TO
TO
TO
TO
TO
TO

t_exclude.
t_exclude.
t_exclude.
t_exclude.
t_exclude.
t_exclude.
t_exclude.
t_exclude.
t_exclude.
t_exclude.
t_exclude.
t_exclude.
t_exclude.
t_exclude.
t_exclude.
t_exclude.
t_exclude.
t_exclude.
t_exclude.
t_exclude.

" EXCLUI_BARRA_FERRAMENTAS

*======================================================================*
* MODULES
*======================================================================*
*
*&---------------------------------------------------------------------*
*&
Module STATUS_2001 OUTPUT
*&---------------------------------------------------------------------*
*
text

*----------------------------------------------------------------------*
MODULE status_2001 OUTPUT.
SET PF-STATUS 'STATUS_GUI_2001'.
SET TITLEBAR 'TITLE_GUI_2001'.
ENDMODULE.
" STATUS_2001 OUTPUT
*&---------------------------------------------------------------------*
*&
Module SHOW_ALV_2001 OUTPUT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
MODULE show_alv_2001 OUTPUT.
PERFORM gera_alv.
ENDMODULE.
" SHOW_ALV_2001 OUTPUT
*&---------------------------------------------------------------------*
*&
Module EXIT_COMMAND_2001 INPUT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
MODULE exit_command_2001 INPUT.
"Ao do clicar nos botes da barra
CASE sy-ucomm.
WHEN 'VOLTAR'.
"Volta para a tela anterior
LEAVE TO TRANSACTION 'ZFI261'.
WHEN 'ENCERRAR'.
"Sai do programa
LEAVE PROGRAM.
WHEN 'SAIR'.
"Sai do programa
LEAVE PROGRAM.
WHEN 'INSE'.
CALL SCREEN 2002 STARTING AT 40 3.
ENDCASE.
ENDMODULE.
" EXIT_COMMAND_2001 INPUT
*&---------------------------------------------------------------------*
*&
Form HANDLE_DATA_CHANGED
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->P_ER_DATA_CHANGED text
*
-->P_E_ONF4 text
*
-->P_E_UCOMM text
*
-->P_SENDER text
*----------------------------------------------------------------------*
FORM handle_data_changed
USING
er_data_changed TYPE REF TO cl_alv_changed_data_protocol
e_onf4
e_onf4_before
e_onf4_after
e_ucomm
sender.
* "Variveis locais
* DATA: vl_tabix
TYPE sy-tabix,
*
vl_tabix2
TYPE sy-tabix,

*
ls_good
TYPE lvc_s_modi,
*
t_saida_padrao
TYPE TABLE OF zfin_pclas_crit,
*
t_saida_aux
TYPE TABLE OF zfin_pclas_crit,
*
wa_saida_padrao
TYPE zfin_pclas_crit,
*
vl_len
TYPE numc3,
*
vl_flag.
*
* "Verifica se houve mudana em alguma clula do ALV Grid
* IF er_data_changed->mt_good_cells[] IS NOT INITIAL.
*
*
vl_save = 'X'.
*
*
"Busca as clulas alteradas
*
LOOP AT er_data_changed->mt_good_cells INTO ls_good.
*
*
vl_tabix = sy-tabix.
*
*
wa_alteracoes-row_id
= ls_good-row_id.
*
wa_alteracoes-fieldname = ls_good-fieldname.
*
wa_alteracoes-value
= ls_good-value.
*
*
APPEND wa_alteracoes TO t_alteracoes.
*
*
ENDLOOP.
*
* ENDIF.
ENDFORM.
" HANDLE_DATA_CHANGED
*&---------------------------------------------------------------------*
*&
Module STATUS_2002 OUTPUT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
MODULE status_2002 OUTPUT.
SET PF-STATUS 'STATUS_GUI_2002'.
SET TITLEBAR 'TITLE_GUI_2002'.
ENDMODULE.
" STATUS_2002 OUTPUT
*&---------------------------------------------------------------------*
*&
Module SHOW_ALV_2002 OUTPUT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
MODULE show_alv_2002 OUTPUT.
ENDMODULE.
" SHOW_ALV_2002 OUTPUT
*&---------------------------------------------------------------------*
*&
Module EXIT_COMMAND_2002 INPUT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
MODULE exit_command_2002 INPUT.
"Ao do clicar nos botes da barra
CASE sy-ucomm.
WHEN 'CANCELAR'.
CLEAR zfin_ccitau.
"Volta para a tela anterior
LEAVE TO SCREEN 0.

WHEN 'GRAVAR'.
PERFORM salva_registro.
WHEN 'SAIR'.
CLEAR zfin_ccitau.
"Volta para a tela anterior
LEAVE TO TRANSACTION 'ZFI264'.
ENDCASE.
ENDMODULE.
" EXIT_COMMAND_2002 INPUT
*&---------------------------------------------------------------------*
*&
Form SALVA_REGISTRO
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM salva_registro .
"Se for a primeira validao do grid
IF vg_alv_top IS INITIAL.
"Salva o contedo inicial
alv_top2 = alv_top.
"Flega a varivel de controle de execuo do grid
vg_alv_top = 'X'.
ELSE.
"Limpa o grid
CLEAR alv_top.
"O grid recebe a configurao inicial
alv_top = alv_top2.
ENDIF.
IF zfin_ccitau IS NOT INITIAL.
"Salva na Tabela Interna
APPEND zfin_ccitau TO t_saida.
"Grava na Tabela fsica
MODIFY zfin_ccitau FROM TABLE t_saida.
COMMIT WORK AND WAIT.
"Limpa a Estrutura
CLEAR zfin_ccitau.
"Atualiza o ALV Grid em tempo de execuo
alv_top->refresh_table_display( ).
"Chama a tela original
LEAVE TO TRANSACTION 'ZFI264'.
ENDIF.
ENDFORM.
" SALVA_REGISTRO
*&---------------------------------------------------------------------*

*&
Form SALVA_DADOS
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM salva_dados .
ENDFORM.

" SALVA_DADOS