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

How to read Archive data??

Former Member
0 Likes
1,218

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_bsak

Anyone 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_bsak

Anyone helps??

Thanks in advance!!!

Hoo

Message was edited by:

Hoo lala

5 REPLIES 5
Read only

Former Member
0 Likes
877

Anyone helps??

Thanks!!

Read only

0 Likes
877

... ....

any ideas?

thanks

Read only

0 Likes
877

Hello Hoo,

What is the error message that you are getting?

-Aditya

Read only

0 Likes
877

Hi Aditya,

The error msg is 'Incorrect access to an archive.'

Thanks.

Hoo.

Read only

0 Likes
877

Anyone helps??

Thanks!!