‎2007 Aug 24 11:31 AM
Hi
I had two tables ZCUST (100 records) and ZCUST_ARCH. I want to acrhive data from ZCUST to ZCUST_ARCH or to flat file.
‎2007 Aug 24 11:35 AM
write one simple program like this
select * from into table itab1.
loop at itab1.
modify zztable from itab1.
commit work.
endloop.
‎2007 Aug 24 11:37 AM
hi
<b> copy this code and execute. in the output write ur program name ZCUST and it will automatically archive ur program to flat file.
infact with this code u can archive any flat file.See the beautity of the code as it also separates all includes in the program</b>
*&---------------------------------------------------------------------*
*& Report Z71754_RAVISH
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
report z71754_ravish.
tables: trdir, tadir.
types: type_levels like slevel occurs 0.
types: t_srclin type abaptxt255.
types: t_srccod type standard table of t_srclin.
data: i_replist type table of program,
wa_replist like line of i_replist.
data :include_name type string.
data: buffer type t_srccod.
data: itab like buffer occurs 0,
wa_itab like buffer.
data: i_stmnt type standard table of sstmnt,
i_incl type standard table of program,
i_token type standard table of stokes,
levels type type_levels with header line,
wa_token like line of i_token,
wa_stmnt like line of i_stmnt.
data : inum type i value 0.
data: wa_itoken type stokes.
select-options : so_name for trdir-name.
parameters : pathname(40) . "LIKE rlgrap-filename.
start-of-selection.
select name
from trdir
into table i_replist
where
name in so_name.
loop at i_replist into wa_replist.
read report wa_replist into buffer.
scan abap-source buffer
statements into i_stmnt
tokens into i_token
levels into levels
with includes.
perform download_prog
* TABLES
* buffer
using
wa_replist.
loop at levels where type eq 'P'.
clear buffer[].
read report levels-name into buffer.
perform download_prog
* TABLES
* buffer
using
levels-name.
clear levels.
endloop.
endloop.
*&---------------------------------------------------------------------*
*& Form download_prog
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PI_SRCCODE text
* -->P_PROG text
*----------------------------------------------------------------------*
form download_prog "TABLES buffer TYPE STANDARD TABLE
using p_fname.
data: l_file type string.
concatenate pathname p_fname '.TXT' into l_file.
condense l_file no-gaps.
call method cl_gui_frontend_services=>gui_download
exporting
* BIN_FILESIZE =
filename = l_file
filetype = 'ASC'
append = space
* WRITE_FIELD_SEPARATOR = SPACE
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = SPACE
* WRITE_LF = 'X'
* COL_SELECT = SPACE
* COL_SELECT_MASK = SPACE
* DAT_MODE = SPACE
* CONFIRM_OVERWRITE = SPACE
* NO_AUTH_CHECK = SPACE
* CODEPAGE = SPACE
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = SPACE
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* IMPORTING
* FILELENGTH =
changing
data_tab = buffer
exceptions
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
not_supported_by_gui = 22
error_no_gui = 23
others = 24
.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform. "download_prog
regards
ravish
<b>plz dont forget to reward points if helpful</b>