Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Write/Read /Delete Programs-Data Archiving

Former Member
0 Likes
1,235

Hi All,

Can any one provide sample code for write / delete and read programs for data archiving for Z objects.

Thanks,

AMAL

4 REPLIES 4
Read only

Former Member
0 Likes
736

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

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/70be5c63-b9ea-2b10-8dad-b071fcbe...

Edited by: Gayathri G on May 7, 2009 7:18 AM

Read only

0 Likes
736

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.

Read only

0 Likes
736

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..

Read only

Former Member
0 Likes
736

Anyone who can help with the above question, please help. I am also will be doing the same thing for my custom tables.