Programa para Editar Tabelas (Z e Y)
Autor: JNilson | Publicado: 2015-07-15T21:55:00-03:00




Edita tabela





*&amp;---------------------------------------------------------------------*

*&amp;  REPORT&nbsp; ZNI_EDITA_TABELA2.

*&amp;

*&amp;---------------------------------------------------------------------*

*&amp;

*&amp;

*&amp;---------------------------------------------------------------------*



REPORT&nbsp; ZNI_EDITA_TABELA2.

*  Hoje vou mostrar como criar um alv orientado a Objeto sem precisar

*  criar nada na tela, o segredo disso tá na classe cl_gui_docking_container

*  que irei mostrar abaixo. Vamos lá.



*  Estruturas e tabelas internas

*&amp;---------------------------------------------------------------------*

DATA  :

&nbsp; t_out&nbsp;&nbsp;&nbsp;&nbsp;  TYPE TABLE OF sflight,

&nbsp; t_fcat&nbsp;&nbsp;&nbsp;  TYPE TABLE OF lvc_s_fcat,

&nbsp; wa_fcat&nbsp;&nbsp;  TYPE lvc_s_fcat,

&nbsp; st_layout TYPE lvc_s_layo.





*  Objetos

*&amp;---------------------------------------------------------------------*

DATA  :

&nbsp; o_docking&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TYPE REF TO cl_gui_docking_container,

&nbsp; o_alv&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TYPE REF TO cl_gui_alv_grid.



data:

&nbsp; oref_doc&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TYPE REF TO cl_dd_document,

&nbsp; oref_html&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TYPE REF TO cl_gui_html_viewer.



data:  ok_code&nbsp;&nbsp;&nbsp;&nbsp; type syucomm.





**  Tabelas ALV

DATA:  it_fieldcat&nbsp;&nbsp;&nbsp;&nbsp; TYPE lvc_t_fcat.

DATA:  it_fieldcat_aux TYPE lvc_t_fcat.



DATA:  wa_fieldcat&nbsp;&nbsp;&nbsp;&nbsp; TYPE lvc_s_fcat.

DATA:  wa_fieldcat_aux TYPE lvc_s_fcat.



DATA:  it_interface&nbsp;&nbsp;&nbsp;&nbsp; TYPE REF TO data,

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; it_interface_aux TYPE REF TO data.



DATA:  it_bkp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TYPE REF TO data,

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; it_bkp_aux&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TYPE REF TO data.



DATA:  it_del&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TYPE REF TO data,

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; it_del_aux&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TYPE REF TO data.



*  &lt;fs_data&gt; p/ser a tabela dinâmica

FIELD-SYMBOLS:  &lt;fs_data&gt; TYPE STANDARD TABLE,

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;fs_bkp&gt;&nbsp; TYPE STANDARD TABLE,

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;fs_del&gt;&nbsp; TYPE STANDARD TABLE,

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;fs_data_aux&gt; TYPE  STANDARD TABLE,

*work-área  p/ trabalhar os dados antes de inclui &lt;fs_data&gt;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;wa_reg&gt;&nbsp; TYPE ANY,

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;wa_bkp&gt;&nbsp; TYPE ANY,

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;wa_del&gt;&nbsp; TYPE ANY,

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;wa_interface&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TYPE any,

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;wa_interface_aux&gt;&nbsp; TYPE any,

*campo  que recebera dados e apontara p/ os campos dinâmicos da wa.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;fs_campo&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TYPE any.



data:  v_campo&nbsp;&nbsp;&nbsp; type c LENGTH 50 ,

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v_del&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  type c,

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v_erro&nbsp;&nbsp;&nbsp;&nbsp;  type c,

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v_idx&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  type i,

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v_tit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  type sytitle,

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v_titbkp&nbsp;&nbsp;  type sytitle.





*  Campos chaves

types:  begin of ty_chaves,

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; campo&nbsp;&nbsp;&nbsp;&nbsp; type c LENGTH 30,

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end of ty_chaves.



data:  t_chaves&nbsp;&nbsp;&nbsp; type table of ty_chaves,

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wa_chaves&nbsp;&nbsp; type ty_chaves.









**  Tela de seleção



*  Dados necessários

SELECTION-SCREEN  BEGIN OF BLOCK a1 WITH FRAME TITLE t_qdr1.



*  Nome da tabela

&nbsp; SELECTION-SCREEN BEGIN OF LINE.

&nbsp;&nbsp;&nbsp; SELECTION-SCREEN POSITION 3.

&nbsp;&nbsp;&nbsp; SELECTION-SCREEN COMMENT 3(40) t_tab.

&nbsp;&nbsp;&nbsp; PARAMETERS: p_tab&nbsp; TYPE DD02L-TABNAME MEMORY ID AA2

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OBLIGATORY.

&nbsp; SELECTION-SCREEN END OF LINE.



*  apenas visualização

&nbsp; SELECTION-SCREEN BEGIN OF LINE.

&nbsp;&nbsp;&nbsp; SELECTION-SCREEN POSITION 3.

&nbsp;&nbsp;&nbsp; PARAMETERS: p_ver&nbsp; TYPE c as CHECKBOX DEFAULT 'X'.

&nbsp;&nbsp;&nbsp; SELECTION-SCREEN COMMENT 5(40) t_ver.

&nbsp; SELECTION-SCREEN END OF LINE.



SELECTION-SCREEN  END OF BLOCK a1.







*  Inicialização

INITIALIZATION.

&nbsp; t_qdr1&nbsp;&nbsp;&nbsp;  = 'Dados necessários'.

&nbsp; t_tab&nbsp;&nbsp;&nbsp;&nbsp;  = 'Nome da tabela'.

&nbsp; t_ver&nbsp;&nbsp;&nbsp;&nbsp;  = 'Apenas visualização'.







*  Inicio do processo

*&amp;---------------------------------------------------------------------*

START-OF-SELECTION.



&nbsp; v_titbkp = sy-title.

&nbsp; v_tit&nbsp;&nbsp;&nbsp;  = sy-title.



&nbsp; check p_tab(1) = 'Z'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; or

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p_tab(1) = 'Y'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; or

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p_tab(6) = '/FNTY/' .



*  Captura a estrutura da tabela

&nbsp; PERFORM f_busca_fieldcat USING p_tab.



*  Cria uma tabela interna com a estrutura da tabela informada

&nbsp; PERFORM f_cria_tab_dinamica.



*  Busca dados da tabela

&nbsp; perform f_busca_dados.





*  Chamada da tela que irá mostrar o ALV

&nbsp; CALL SCREEN 9999.











*&amp;---------------------------------------------------------------------*

*&amp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Form&nbsp;  F_FCAT_OO

*&amp;---------------------------------------------------------------------*

FORM  f_fcat_oo .



&nbsp; DATA :

&nbsp;&nbsp;&nbsp; lt_fcat TYPE TABLE OF slis_fieldcat_alv.



*  Criação do catalogo de campo para o modo Estruturado.

&nbsp; CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

&nbsp;&nbsp;&nbsp; EXPORTING

&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;i_program_name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = sy-repid

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i_structure_name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = p_tab

&nbsp;&nbsp;&nbsp; CHANGING

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ct_fieldcat&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = lt_fcat

&nbsp;&nbsp;&nbsp; EXCEPTIONS

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; inconsistent_interface = 1

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; program_error&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 2

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OTHERS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 3.



&nbsp; IF sy-subrc IS INITIAL.



*  Conversão Estruturado x OO

&nbsp;&nbsp;&nbsp; CALL FUNCTION 'LVC_TRANSFER_FROM_SLIS'

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EXPORTING

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; it_fieldcat_alv = lt_fcat

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IMPORTING

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; et_fieldcat_lvc = t_fcat

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TABLES

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; it_data&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = &lt;fs_data&gt;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EXCEPTIONS

&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;it_data_missing = 1

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OTHERS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 2.



&nbsp; ENDIF.





*  Edita os campos que não são chaves

&nbsp; if p_ver = ''.

&nbsp;&nbsp;&nbsp; perform f_edita_campos.

&nbsp; endif.



*  Identifica os campso chave

&nbsp; perform f_campos_chave.



ENDFORM.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " F_FCAT_OO



*&amp;---------------------------------------------------------------------*

*&amp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Form&nbsp;  F_LAYOUT

*&amp;---------------------------------------------------------------------*

FORM  f_layout .



&nbsp; concatenate 'Tabela -' p_tab

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; into st_layout-grid_title

&nbsp;&nbsp;&nbsp; separated by space.

&nbsp; st_layout-zebra&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 'X'.

&nbsp; st_layout-cwidth_opt = 'X'.



ENDFORM.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " F_LAYOUT



*&amp;---------------------------------------------------------------------*

*&amp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Module&nbsp;  STATUS_9999&nbsp; OUTPUT

*&amp;---------------------------------------------------------------------*

MODULE  status_9999 OUTPUT.



&nbsp; SET PF-STATUS 'PF_9999'.

&nbsp; SET TITLEBAR&nbsp;  '999'.





ENDMODULE.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " STATUS_9999&nbsp; OUTPUT



*&amp;---------------------------------------------------------------------*

*&amp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Module&nbsp;  INITIAL_9999&nbsp; OUTPUT

*&amp;---------------------------------------------------------------------*

MODULE  initial_9999 OUTPUT.





&nbsp; IF o_docking IS NOT BOUND.



*  Aqui que encontramos a parte mais importante desse post, esse objeto

*  docking que será criado terá a tela chamada(9999) como referencia,

* o  parametro 'extension' será o tamanho do uso da tela.

&nbsp;&nbsp;&nbsp; CREATE OBJECT o_docking

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EXPORTING

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; repid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = sy-repid

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dynnr&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = sy-dynnr

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; extension&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 2000 " Tela Full rs  " Extension

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EXCEPTIONS

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cntl_error&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 1

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cntl_system_error&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 2

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; create_error&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 3

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lifetime_error&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 4

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lifetime_dynpro_dynpro_link = 5

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OTHERS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 6.



&nbsp; ENDIF.



&nbsp; IF o_alv IS NOT BOUND.

*&nbsp;&nbsp; Criação da catalogo de campos

&nbsp;&nbsp;&nbsp; PERFORM f_fcat_oo.



*&nbsp;&nbsp; Alimentação dos parametros do Layout do alv

&nbsp;&nbsp;&nbsp; PERFORM f_layout.



*&nbsp;&nbsp; Criação do alv com referencia no Objeto  Docking criado anteriormente

&nbsp;&nbsp;&nbsp; CREATE OBJECT o_alv

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EXPORTING

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i_parent&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = o_docking&nbsp;&nbsp;&nbsp; " Parent Container

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EXCEPTIONS

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; error_cntl_create = 1

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; error_cntl_init&nbsp;&nbsp; = 2

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; error_cntl_link&nbsp;&nbsp; = 3

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; error_dp_create&nbsp;&nbsp; = 4

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OTHERS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 5.



*  Exibição do alv

&nbsp;&nbsp;&nbsp; o_alv-&gt;set_table_for_first_display(

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EXPORTING

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i_save&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 'A'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " Save Layout

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i_default&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 'X'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " Default Display Variant

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; is_layout&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = st_layout&nbsp; " Layout

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CHANGING

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; it_outtab&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =&nbsp; &lt;fs_data&gt; " Output Table

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; it_fieldcatalog&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =&nbsp; t_fcat&nbsp;&nbsp;&nbsp;  " Field Catalog

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EXCEPTIONS

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; invalid_parameter_combination = 1

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; program_error&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 2

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; too_many_lines&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 3

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OTHERS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 4

&nbsp;&nbsp;&nbsp; ).



*  Caso o alv já tenha sido criado

&nbsp; ELSE.



*&nbsp;&nbsp; Atualização do alv.

&nbsp;&nbsp;&nbsp; o_alv-&gt;refresh_table_display(

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EXCEPTIONS

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; finished&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 1

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OTHERS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 2

&nbsp;&nbsp;&nbsp; ).

&nbsp; ENDIF.

ENDMODULE.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " INITIAL_9999&nbsp; OUTPUT



*&amp;---------------------------------------------------------------------*

*&amp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Module&nbsp;  EXIT_COMMAND_9999&nbsp; INPUT

*&amp;---------------------------------------------------------------------*

MODULE  exit_command_9999 INPUT.

&nbsp; CASE sy-ucomm.

&nbsp;&nbsp;&nbsp; WHEN 'BACK'.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LEAVE TO SCREEN 0.

&nbsp;&nbsp;&nbsp; WHEN 'EXIT' OR 'CANCEL'.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LEAVE TO SCREEN 0.

&nbsp;&nbsp;&nbsp; WHEN OTHERS.

&nbsp; ENDCASE.



ENDMODULE.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " EXIT_COMMAND_9999&nbsp; INPUT



*&amp;---------------------------------------------------------------------*

*&amp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Form&nbsp;  F_BUSCA_FIELDCAT

*&amp;---------------------------------------------------------------------*

FORM  f_busca_fieldcat USING u_structure_name TYPE dd02l-tabname.



&nbsp; free: it_fieldcat, it_fieldcat_aux.



&nbsp; check u_structure_name(1) = 'Z'&nbsp;&nbsp;&nbsp;&nbsp; or

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; u_structure_name(1) = 'Y'&nbsp;&nbsp;&nbsp;&nbsp; or

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; u_structure_name(6) = '/FNTY/'.



&nbsp; CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

&nbsp;&nbsp;&nbsp; EXPORTING

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i_structure_name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = u_structure_name

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i_client_never_display = 'X'

&nbsp;&nbsp;&nbsp; CHANGING

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ct_fieldcat&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = it_fieldcat[]

&nbsp;&nbsp;&nbsp; EXCEPTIONS

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; inconsistent_interface = 1

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; program_error&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 2

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OTHERS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 3.





*  Cria tabela auxiliar SEM mandante.

&nbsp; it_fieldcat_aux[] = it_fieldcat[].

&nbsp; delete it_fieldcat_aux where FIELDNAME =  'MANDT'.





ENDFORM.  " F_BUSCA_FIELDCAT







*&amp;---------------------------------------------------------------------*

*&amp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Form&nbsp;  F_CRIA_TAB_DINAMICA

*&amp;---------------------------------------------------------------------*

FORM  f_cria_tab_dinamica .



&nbsp; DATA: lt_alvdata TYPE REF TO data.

&nbsp; DATA: lt_alvdata_aux TYPE REF TO data.



&nbsp; DATA: lt_alvbkp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TYPE REF TO data.

&nbsp; DATA: lt_alvbkp_aux&nbsp;&nbsp; TYPE REF TO data.



&nbsp; DATA: lt_alvdel&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TYPE REF TO data.

&nbsp; DATA: lt_alvdel_aux&nbsp;&nbsp; TYPE REF TO data.



*  Monta tabela dinâmica

&nbsp; CALL METHOD  cl_alv_table_create=&gt;create_dynamic_table

&nbsp;&nbsp;&nbsp; EXPORTING

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i_style_table&nbsp;&nbsp; = ' '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" tab com as  informações de campo

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; it_fieldcatalog = it_fieldcat

&nbsp;&nbsp;&nbsp; IMPORTING&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " retorna tab  dinâmica com campos informados

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ep_table&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = it_interface.



&nbsp; CALL METHOD  cl_alv_table_create=&gt;create_dynamic_table

&nbsp;&nbsp;&nbsp; EXPORTING

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i_style_table&nbsp;&nbsp; = ' '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " tab com as informações de  campo

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; it_fieldcatalog = it_fieldcat

&nbsp;&nbsp;&nbsp; IMPORTING&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " retorna tab  dinâmica com campos informados

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ep_table&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = it_bkp.





&nbsp; CALL METHOD  cl_alv_table_create=&gt;create_dynamic_table

&nbsp;&nbsp;&nbsp; EXPORTING

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i_style_table&nbsp;&nbsp; = ' '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " tab com as informações de  campo

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; it_fieldcatalog = it_fieldcat

&nbsp;&nbsp;&nbsp; IMPORTING&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " retorna tab  dinâmica com campos informados

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ep_table&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = it_del.





*  Carrega &lt;fs_data&gt; com a estrutura dos campos passados para o metodo

&nbsp; ASSIGN it_interface-&gt;* TO &lt;fs_data&gt;.

&nbsp; CREATE DATA lt_alvdata LIKE LINE OF  &lt;fs_data&gt;.

&nbsp; ASSIGN lt_alvdata-&gt;* TO  &lt;wa_interface&gt;.





*  Carrega &lt;fs_bkp&gt; com a estrutura dos campos passados para o metodo

&nbsp; ASSIGN it_bkp-&gt;* TO &lt;fs_bkp&gt;.

&nbsp; CREATE DATA lt_alvbkp LIKE LINE OF  &lt;fs_bkp&gt;.

&nbsp; ASSIGN lt_alvbkp-&gt;* TO &lt;wa_bkp&gt;.



*  Carrega &lt;fs_del&gt; com a estrutura dos campos passados para o metodo

&nbsp; ASSIGN it_del-&gt;* TO &lt;fs_del&gt;.

&nbsp; CREATE DATA lt_alvdel LIKE LINE OF  &lt;fs_del&gt;.

&nbsp; ASSIGN lt_alvdel-&gt;* TO &lt;wa_del&gt;.





*  Monta tabela dinâmica auxiliar (sem MANDT)

&nbsp; CALL METHOD  cl_alv_table_create=&gt;create_dynamic_table

&nbsp;&nbsp;&nbsp; EXPORTING

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i_style_table&nbsp;&nbsp; = ' '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " tab com as informações de  campo

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; it_fieldcatalog = it_fieldcat_aux

&nbsp;&nbsp;&nbsp; IMPORTING&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " retorna tab  dinâmica com campos informados

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ep_table&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = it_interface_aux.



*  Carrega &lt;fs_data&gt; com a estrutura dos campos passados para o metodo

&nbsp; ASSIGN it_interface_aux-&gt;* TO  &lt;fs_data_aux&gt;.

&nbsp; CREATE DATA lt_alvdata_aux LIKE LINE OF  &lt;fs_data_aux&gt;.

&nbsp; ASSIGN lt_alvdata_aux-&gt;* TO  &lt;wa_interface_aux&gt;.





ENDFORM.  " F_CRIA_TAB_DINAMICA







*&amp;---------------------------------------------------------------------*

*&amp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Form&nbsp;  F_BUSCA_DADOS

*&amp;---------------------------------------------------------------------*

*  Busca dados da tabela

*----------------------------------------------------------------------*

FORM  F_BUSCA_DADOS .



&nbsp; select *

&nbsp;&nbsp;&nbsp; from (p_tab)

&nbsp;&nbsp;&nbsp; into table &lt;fs_data&gt;.



&nbsp; if sy-subrc &lt;&gt; 0 .



&nbsp; endif.



&nbsp; &lt;fs_bkp&gt; = &lt;fs_data&gt;.

&nbsp; clear &lt;fs_del&gt;.



ENDFORM.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " F_BUSCA_DADOS





*&amp;---------------------------------------------------------------------*

*&amp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Form&nbsp;  F_EDITA_CAMPOS

*&amp;---------------------------------------------------------------------*

*&nbsp; edita campos

*----------------------------------------------------------------------*

FORM  F_EDITA_CAMPOS .





&nbsp; LOOP AT t_fcat into wa_fcat.

*&nbsp;&nbsp; if wa_fcat-key &lt;&gt; 'X'.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wa_fcat-edit&nbsp; = 'X'.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; modify t_fcat from wa_fcat.

*&nbsp;&nbsp; endif.

&nbsp; ENDLOOP.



&nbsp; CLEAR: ok_code.



ENDFORM.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " F_EDITA_CAMPOS





*&amp;---------------------------------------------------------------------*

*&amp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Module&nbsp;  USER_COMMAND_9999&nbsp; INPUT

*&amp;---------------------------------------------------------------------*

*  ações do usuário

*----------------------------------------------------------------------*

MODULE  USER_COMMAND_9999 INPUT.



&nbsp; data: it_index_rows type lvc_t_row.

&nbsp; data: it_row_no&nbsp;&nbsp;&nbsp;&nbsp; TYPE LVC_T_ROID.





*  Verifica se houve alteração na tabela

&nbsp; o_alv-&gt;check_changed_data( ).



*&nbsp; CALL METHOD O_ALV-&gt;GET_SELECTED_ROWS

*&nbsp;&nbsp;&nbsp; IMPORTING

*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ET_INDEX_ROWS = IT_INDEX_ROWS

*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ET_ROW_NO&nbsp;&nbsp;&nbsp;&nbsp; = IT_ROW_NO&nbsp; .

*

*&nbsp; IF SY-SUBRC &lt;&gt; 0.

**&nbsp;&nbsp; MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER  SY-MSGNO

**&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WITH SY-MSGV1 SY-MSGV2 SY-MSGV3  SY-MSGV4.

*&nbsp; ENDIF.



&nbsp; CASE ok_code.

&nbsp;&nbsp;&nbsp; WHEN 'BACK'.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LEAVE TO SCREEN 0.



&nbsp;&nbsp;&nbsp; WHEN 'EXIT' OR 'CANCEL'.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LEAVE TO SCREEN 0.



&nbsp;&nbsp;&nbsp; WHEN 'SAVE'.



&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BREAK-POINT.



*&nbsp;&nbsp;&nbsp;&nbsp; identifica os registros excluídos

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LOOP AT &lt;FS_BKP&gt; ASSIGNING  &lt;WA_BKP&gt;.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v_del = 'X'.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LOOP AT &lt;FS_DATA&gt; ASSIGNING  &lt;WA_REG&gt;.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if &lt;wa_bkp&gt; = &lt;wa_reg&gt;.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v_del = ''.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; endif.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ENDLOOP.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if v_del = 'X'.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; append &lt;wa_bkp&gt; to  &lt;fs_del&gt;.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; endif.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ENDLOOP.



*&nbsp;&nbsp;&nbsp;&nbsp; exclui os registros

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if  &lt;fs_del&gt; is not initial.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delete (p_tab) from table  &lt;fs_del&gt;.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; endif.





*&nbsp;&nbsp;&nbsp;&nbsp; Os regisros adicionados e alterados serão  atualizados

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LOOP AT &lt;fs_data&gt; ASSIGNING  &lt;WA_REG&gt;.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v_idx&nbsp;  = sy-tabix.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v_erro = ' '.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LOOP AT t_chaves into wa_chaves.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UNASSIGN &lt;fs_campo&gt;.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; concatenate '&lt;WA_REG&gt;' '-'  wa_chaves-campo into v_campo.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ASSIGN (v_campo) to &lt;fs_campo&gt;.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if &lt;fs_campo&gt; is ASSIGNED.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if &lt;fs_campo&gt; is initial.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if wa_chaves-campo = 'MANDT'.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;fs_campo&gt; = sy-mandt.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v_erro = 'X'.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; endif.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; endif.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; endif.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ENDLOOP.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if v_erro = ''.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; modify (p_tab) from &lt;wa_reg&gt;.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; message i398(00) with 'Falta dados no  registro'

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v_idx '' ''.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; endif.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ENDLOOP.





&nbsp;&nbsp;&nbsp; WHEN OTHERS.



&nbsp; ENDCASE.



&nbsp; CLEAR: ok_code.



ENDMODULE.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " USER_COMMAND_9999&nbsp; INPUT





*&amp;---------------------------------------------------------------------*

*&amp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Form&nbsp;  F_CAMPOS_CHAVE

*&amp;---------------------------------------------------------------------*

*  identifica os campos chave

*----------------------------------------------------------------------*

FORM  F_CAMPOS_CHAVE .



&nbsp; free: t_chaves.

&nbsp; LOOP AT t_fcat into wa_fcat.

&nbsp;&nbsp;&nbsp; if wa_fcat-key = 'X'.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wa_chaves-campo = wa_fcat-fieldname.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; append wa_chaves to t_chaves.

&nbsp;&nbsp;&nbsp; endif.

&nbsp; ENDLOOP.



&nbsp; CLEAR: ok_code.



ENDFORM.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " F_CAMPOS_CHAVE


      



Tela de Seleção









Tela de Resultado

&nbsp;









--

JNilson Oliveira