para o metodo ASSIGN it_interface->* TO <fs_data>. CREATE DATA lt_alvdata LIKE LINE OF <fs_data>. ASSIGN lt_alvdata->* TO <wa_interface>.* Carrega <fs_bkp> com a estrutura dos campos passados para o metodo ASSIGN it_bkp->* TO <fs_bkp>. CREATE DATA lt_alvbkp LIKE LINE OF <fs_bkp>. ASSIGN lt_alvbkp->* TO <wa_bkp>.* Carrega <fs_del> com a estrutura dos campos passados para o metodo ASSIGN it_del->* TO <fs_del>. CREATE DATA lt_alvdel LIKE LINE OF <fs_del>. ASSIGN lt_alvdel->* TO <wa_del>.* Monta tabela dinamica auxiliar (sem MANDT) CALL METHOD cl_alv_table_create=>create_dynamic_table EXPORTING i_style_table = ' ' " tab com as informacoes de campo it_fieldcatalog = it_fieldcat_aux IMPORTING " retorna tab dinamica com campos informados ep_table = it_interface_aux.* Carrega <fs_data> com a estrutura dos campos passados para o metodo ASSIGN it_interface_aux->* TO <fs_data_aux>. CREATE DATA lt_alvdata_aux LIKE LINE OF <fs_data_aux>. ASSIGN lt_alvdata_aux->* TO <wa_interface_aux>.ENDFORM. " F_CRIA_TAB_DINAMICA*&---------------------------------------------------------------------**& Form F_BUSCA_DADOS*&---------------------------------------------------------------------** Busca dados da tabela*----------------------------------------------------------------------*FORM F_BUSCA_DADOS . select * from (p_tab) into table <fs_data>. if sy-subrc <> 0 . endif. <fs_bkp> = <fs_data>. clear <fs_del>.ENDFORM. " F_BUSCA_DADOS*&---------------------------------------------------------------------**& Form F_EDITA_CAMPOS*&---------------------------------------------------------------------** edita campos*----------------------------------------------------------------------*FORM F_EDITA_CAMPOS . LOOP AT t_fcat into wa_fcat.* if wa_fcat-key <> 'X'. wa_fcat-edit = 'X'. modify t_fcat from wa_fcat.* endif. ENDLOOP. CLEAR: ok_code.ENDFORM. " F_EDITA_CAMPOS*&---------------------------------------------------------------------**& Module USER_COMMAND_9999 INPUT*&---------------------------------------------------------------------** acoes do usuario*----------------------------------------------------------------------*MODULE USER_COMMAND_9999 INPUT. data: it_index_rows type lvc_t_row. data: it_row_no TYPE LVC_T_ROID.* Verifica se houve alteracao na tabela o_alv->check_changed_data( ).* CALL METHOD O_ALV->GET_SELECTED_ROWS* IMPORTING* ET_INDEX_ROWS = IT_INDEX_ROWS* ET_ROW_NO = IT_ROW_NO .** IF SY-SUBRC <> 0.** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.* ENDIF. CASE ok_code. WHEN 'BACK'. LEAVE TO SCREEN 0. WHEN 'EXIT' OR 'CANCEL'. LEAVE TO SCREEN 0. WHEN 'SAVE'. BREAK-POINT.* identifica os registros excluidos LOOP AT <FS_BKP> ASSIGNING <WA_BKP>. v_del = 'X'. LOOP AT <FS_DATA> ASSIGNING <WA_REG>. if <wa_bkp> = <wa_reg>. v_del = ''. exit. endif. ENDLOOP. if v_del = 'X'. append <wa_bkp> to <fs_del>. endif. ENDLOOP.* exclui os registros if <fs_del> is not initial. delete (p_tab) from table <fs_del>. endif.* Os regisros adicionados e alterados serao atualizados LOOP AT <fs_data> ASSIGNING <WA_REG>. v_idx = sy-tabix. v_erro = ' '. LOOP AT t_chaves into wa_chaves. UNASSIGN <fs_campo>. concatenate '<WA_REG>' '-' wa_chaves-campo into v_campo. ASSIGN (v_campo) to <fs_campo>. if <fs_campo> is ASSIGNED. if <fs_campo> is initial. if wa_chaves-campo = 'MANDT'. <fs_campo> = sy-mandt. else. v_erro = 'X'. endif. endif. endif. ENDLOOP. if v_erro = ''. modify (p_tab) from <wa_reg>. else. message i398(00) with 'Falta dados no registro' v_idx '' ''. endif. ENDLOOP. WHEN OTHERS. ENDCASE. CLEAR: ok_code.ENDMODULE. " USER_COMMAND_9999 INPUT*&---------------------------------------------------------------------**& Form F_CAMPOS_CHAVE*&---------------------------------------------------------------------** identifica os campos chave*----------------------------------------------------------------------*FORM F_CAMPOS_CHAVE . free: t_chaves. LOOP AT t_fcat into wa_fcat. if wa_fcat-key = 'X'. wa_chaves-campo = wa_fcat-fieldname. append wa_chaves to t_chaves. endif. ENDLOOP. CLEAR: ok_code.ENDFORM. " F_CAMPOS_CHAVE Tela de SelecaoTela de Resultado --JNilson Oliveira