2007 Mar 05 6:27 AM
Hi,
I am developing a program which requires me to retrive the <b>archive</b> data of table BSAK and then fill it into an itam then output the list.
I use T-code 'SARA' to find the object name is 'FI_DOCUMNT'. There u can find that BSAK is contained in it.
And i reference the DEMO programm 'SBOOKR' and coding as belows, but the error message always shows and F1 couldnt help.
[IMG]http://www.designoo.com/files/6678/incorrectInfo.jpg[/IMG]
My code:
* for Read Archive
DATA: handle LIKE sy-tabix,
buffer TYPE arc_buffer,
wa_arc_bsak LIKE bsak,
number_of_records_read TYPE i.
data: LE_DATA(8192) TYPE C,
LE_STRUCTURE LIKE ARC_BUFFER-RNAME.
...
perform read_archive_bsak.
........
FORM read_archive_bsak.
* open existing archive files for BSAK
CALL FUNCTION 'ARCHIVE_OPEN_FOR_READ'
EXPORTING
object = 'FI_DOCUMNT'
IMPORTING
archive_handle = handle
EXCEPTIONS
OTHERS = 1.
* IF sy-subrc <> 0.
* WRITE: / 'No file can be accessed'(001).
* EXIT.
* 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 = LE_DATA
record_structure = LE_STRUCTURE
EXCEPTIONS
end_of_object = 1
OTHERS = 2.
IF sy-subrc <> 0.
EXIT.
ENDIF.
CASE buffer-rname.
WHEN 'BSAK'.
wa_arc_bsak = LE_DATA.
move-corresponding wa_arc_bsak to Tab_ARC_bsak.
APPEND Tab_ARC_bsak.
CLEAR: wa_arc_bsak, LE_DATA, Tab_ARC_bsak.
ENDCASE.
ADD 1 TO number_of_records_read.
ENDDO.
ENDDO.
* close the archive session
CALL FUNCTION 'ARCHIVE_CLOSE_FILE'
EXPORTING
archive_handle = handle.
Move-corresponding tab_arc_bsak to tab_bsak.
append tab_bsak.
clear tab_bsak.
ENDFORM. " read_archive_bsakAnyone helps??
Thanks in advance!!!
Hoo
Message was edited by:
Hoo lala
Hi,
I am developing a program which requires me to retrive the <b>archive</b> data of table BSAK and then fill it into an itam then output the list.
I use T-code 'SARA' to find the object name is 'FI_DOCUMNT'. There u can find that BSAK is contained in it.
And i reference the DEMO programm 'SBOOKR' and coding as belows, but the error message always shows and F1 couldnt help.
[IMG]http://www.designoo.com/files/6678/incorrectInfo.jpg[/IMG]
My code:
* for Read Archive
DATA: handle LIKE sy-tabix,
buffer TYPE arc_buffer,
wa_arc_bsak LIKE bsak,
number_of_records_read TYPE i.
data: LE_DATA(8192) TYPE C,
LE_STRUCTURE LIKE ARC_BUFFER-RNAME.
...
perform read_archive_bsak.
........
FORM read_archive_bsak.
* open existing archive files for BSAK
CALL FUNCTION 'ARCHIVE_OPEN_FOR_READ'
EXPORTING
object = 'FI_DOCUMNT'
IMPORTING
archive_handle = handle
EXCEPTIONS
OTHERS = 1.
* IF sy-subrc <> 0.
* WRITE: / 'No file can be accessed'(001).
* EXIT.
* 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 = LE_DATA
record_structure = LE_STRUCTURE
EXCEPTIONS
end_of_object = 1
OTHERS = 2.
IF sy-subrc <> 0.
EXIT.
ENDIF.
CASE buffer-rname.
WHEN 'BSAK'.
wa_arc_bsak = LE_DATA.
move-corresponding wa_arc_bsak to Tab_ARC_bsak.
APPEND Tab_ARC_bsak.
CLEAR: wa_arc_bsak, LE_DATA, Tab_ARC_bsak.
ENDCASE.
ADD 1 TO number_of_records_read.
ENDDO.
ENDDO.
* close the archive session
CALL FUNCTION 'ARCHIVE_CLOSE_FILE'
EXPORTING
archive_handle = handle.
Move-corresponding tab_arc_bsak to tab_bsak.
append tab_bsak.
clear tab_bsak.
ENDFORM. " read_archive_bsakAnyone helps??
Thanks in advance!!!
Hoo
Message was edited by:
Hoo lala
2007 Mar 05 7:41 AM
2007 Mar 05 8:08 AM
2007 Mar 05 9:05 AM
Hello Hoo,
What is the error message that you are getting?
-Aditya
2007 Mar 05 9:56 AM
Hi Aditya,
The error msg is 'Incorrect access to an archive.'
Thanks.
Hoo.
2007 Mar 05 8:30 PM