Professional Documents
Culture Documents
PRG Que Faz Download e Upload de Dados Diretamente Na Tabela
PRG Que Faz Download e Upload de Dados Diretamente Na Tabela
*----------------------------------------------------------------------*
* data....: 23.05.2007 *
* objetivo: download/upload conte�do de tabelas *
*----------------------------------------------------------------------*
* tabelas sap
tables: dd02l.
* tabelas internas
data: begin of t_dd02l occurs 100,
tabname like dd02l-tabname,
end of t_dd02l.
* macros
define _apps.
clear t_prog.
concatenate &1 &2 &3 &4 into t_prog separated by space.
append t_prog.
end-of-definition.
define _app.
clear t_prog.
concatenate &1 &2 &3 &4 into t_prog.
append t_prog.
end-of-definition.
* par�metros de sele��o
selection-screen begin of block b1 with frame.
select-options: s_table for dd02l-tabname obligatory.
*parameters: p_dir like rlgrap-filename obligatory default 'c:\'.
parameters: p_dir type string.
parameters: p_dwn radiobutton group b1,
p_upd radiobutton group b1 default 'x',
p_field type char50.
select-options s_range for v_range.
selection-screen skip.
parameters: p_char as checkbox.
selection-screen end of block b1.
* initialization
initialization.
* at selection-screen.
at selection-screen on value-request for p_dir.
perform filemane_get.
*----------------------------------------------------------------------*
* start-of-selection *
*----------------------------------------------------------------------*
start-of-selection.
if not p_dwn is initial. " p_field is initial and s_range is initial
if ( p_field is initial and s_range is not initial ) or ( p_field is
not initial and s_range is initial ).
message i000(zcbr) with '� obrigat�rio o preenchimento dos campos'.
stop.
endif.
endif.
* efetuar o download/upload
perform processamento.
*----------------------------------------------------------------------*
* form : f_get_table *
* descri��o : se a op��o selecionada for 'download' monta arquivo de *
* sa�da *
* entrada : n�o h�. *
* sa�da : n�o h�. *
*----------------------------------------------------------------------*
form f_get_table.
select tabname
from dd02l
into table t_dd02l
where as4local = 'a'
and tabname in s_table.
r_tabname-low = 'z*'.
append r_tabname.
r_tabname-low = 'y*'.
append r_tabname.
**********range*****************
if ( p_field is not initial and s_range is not initial ).
concatenate t_prog 'ranges: r_' p_field into t_prog.
concatenate t_prog 'for' t_dd02l-tabname into t_prog separated
by space.
concatenate t_prog '-' p_field '.' into t_prog.
append t_prog.
clear t_prog.
endif.
loop at t_dd02l.
perform f_get_table.
endloop.
append t_prog.
clear t_prog.
clear w_length.
loop at t_campos.
case t_campos-datatype.
when 'dec'.
w_length = t_campos-leng + 1 + t_campos-decimals.
when 'curr'.
w_length = t_campos-leng + 1 + t_campos-decimals.
when others.
w_length = t_campos-leng.
endcase.
**************************************************************************
* teste range
**************************************************************************
if ( p_field is not initial and s_range is not initial ).
clear t_prog.
concatenate 'filename' '=' into t_prog separated by space.
concatenate t_prog ' ''' p_dir t_dd02l-tabname '.tab'''
into t_prog.
condense t_prog.
append t_prog.
**************************************************************************
* teste range
**************************************************************************
if ( p_field is not initial and s_range is not initial ).
concatenate t_prog 'r_' p_field '-low' into t_prog.
concatenate t_prog '=' into t_prog separated by space.
concatenate t_prog '''' s_range-low '''.' into t_prog.
append t_prog.
clear t_prog.
else.
clear t_prog.
concatenate 'filename' '=' into t_prog separated by space.
concatenate t_prog ' ''' p_dir t_dd02l-tabname '.tab'''
into t_prog.
condense t_prog.
append t_prog.
append t_prog.
clear t_prog.
clear w_length.
loop at t_campos.
case t_campos-datatype.
when 'dec'.
w_length = t_campos-leng + 1 + t_campos-decimals.
when 'curr'.
w_length = t_campos-leng + 1 + t_campos-decimals.
when others.
w_length = t_campos-leng.
endcase.
clear t_prog.
concatenate 'filename' '=' into t_prog separated by space.
case t_campos-datatype.
when 'dec'.
concatenate w_aux '-' t_campos-fieldname into w_aux.
concatenate w_aux1 '-' t_campos-fieldname into w_aux1.
_apps w_aux1 '=' w_aux '.'.
when 'curr'.
concatenate w_aux '-' t_campos-fieldname into w_aux.
concatenate w_aux1 '-' t_campos-fieldname into w_aux1.
_apps w_aux1 '=' w_aux '.'.
when others.
concatenate w_aux '-' t_campos-fieldname into w_aux.
concatenate w_aux1 '-' t_campos-fieldname '.' into
w_aux1.
_apps 'move' w_aux 'to' w_aux1.
endcase.
endloop.
append t_prog.
clear t_prog.
clear t_prog.
concatenate 'filename' '=' into t_prog separated by space.
concatenate t_prog ' ''' p_dir t_dd02l-tabname '.tab'''
into t_prog.
append t_prog.