‎2009 May 07 6:15 AM
Hi All,
Can any one provide sample code for write / delete and read programs for data archiving for Z objects.
Thanks,
AMAL
‎2009 May 07 6:17 AM
Check this code
data: handle like sy-tabix,
buffer type arc_buffer,
sbook_wa like sbook,
number_of_records_read type i.
* open existing archive files
call function 'ARCHIVE_OPEN_FOR_READ'
exporting
object = 'BC_SBOOK01'
importing
archive_handle = handle
exceptions
others = 1.
if sy-subrc 0.
write: / 'No file can be accessed'(001).
stop.
endif.
clear number_of_records_read.
* loop to get the next data object from the archive file(s)
do.
call function 'ARCHIVE_GET_NEXT_OBJECT'
exporting
archive_handle = handle
exceptions
end_of_file = 1
others = 2.
if sy-subrc 0.
exit.
endif.
* get data records from the data container
do.
call function 'ARCHIVE_GET_NEXT_RECORD'
exporting
archive_handle = handle
importing
record = buffer-segment
record_structure = buffer-rname
exceptions
end_of_object = 1
others = 2.
if sy-subrc 0.
exit.
endif.
add 1 to number_of_records_read.
enddo.
enddo.
write: / 'Total number of records read: '(002), number_of_records_read.
skip.
write / 'Last record read: '(003).
skip.
case buffer-rname.
when 'SBOOK'.
sbook_wa = buffer-segment.
write: / 'CARRID :', sbook_wa-carrid,
/ 'BOOKID :', sbook_wa-bookid,
/ 'CONNID :', sbook_wa-connid,
/ 'FLDATE :', sbook_wa-fldate,
/ 'CUSTOMID :', sbook_wa-customid,
/ 'ORDER_DATE:', sbook_wa-order_date,
/ '...'.
* when ...
* If the archive object contained more than one table
* (different buffer-rname), more cases would be needed.
endcase.
* close the archive session
call function 'ARCHIVE_CLOSE_FILE'
exporting
archive_handle = handle.
and also chk this link
Edited by: Gayathri G on May 7, 2009 7:18 AM
‎2009 May 07 6:24 AM
Hi,
I pick the sample code sbooka .
whrn i ttry to execute Delete operation in SARA transaction, its thrwoing one message 'No data for Selection'.
where i want to check for correcting this...
Thanks,
AMAL.
‎2009 May 08 5:05 AM
Hi Amal,
inorder for you to delete / archive any data from any object, the following steps needs to be carefully undrtaken :
1. Configure the Object ( technical settings ) Application specific settings ( if any )
2.Configure the archive/ storage server
3.in SARA, press the WRITE button and input the variant values and save them.
4. then run the write program.
5. run the delete/store program based on ur settings.
in this way, u may be able to archive / delete the sap data as per the specs..
Regards..
‎2009 May 13 10:46 AM
Anyone who can help with the above question, please help. I am also will be doing the same thing for my custom tables.