2016 Jul 18 7:15 AM
Hi experts.
I generating custom program that reads archive files with SARA transaction. The target will show all FI documents archived with the original Purchase Order in one ALV.
I am trying to read archive field with "Archive Read Object" function.
In some examples (Program SBOOKS) this function get two parameters from arch_idx_s but this transparent table was empty.
Then I compare this table with others system where the archiving was doing from some years. But this table is empty.
How can I read this parameters to call function?
I know Input parameter OBJECT = 'SD_VBRK' For example
I read files from admi_files , for example.
But I don´t know how can I get OFFSET parameter.
Would you help me, please?
Thanks and regards David Sánchez.
2016 Jul 18 7:25 AM
Hi David
Are you absolutely sure the data you are searching for is available.
In some archiving solutions the data may not longer reside on your system.
I'd recommend speaking with the people responsible for designing the Archiving Process first. They should be able to indicate what you need to access if it's still available within your system landscape
Regards
Arden
2016 Jul 18 9:12 AM
Thanks for your help Arden.
Installation is Content Server and that installation was performed in other machine (Virtual machine).
For your answer I think that is probably that this data was wrongly archived and they are unavailable. Is it correct?
I try to show how is archived.
- SARA --> FI_DOCUMNT --> Information System --> Archive Explorer -->
I object and structure and find one single FI document.
- SARA --> FI_DOCUMNT --> Information System --> Status
149 08.07.2016 0100000733
Completo SAP_FI_DOC_002 000149-001FI_DOCUMNT Borrado conclui
Completo Z_FI_DOC 000149-001FI_DOCUMNT Borrado conclui
- SARA --> Sist. Archive (click)
--> Recovery files --> Select file
--> 000149 / 000149-001FI_DOCUMNT "Deleted" (green semaphore).
Thanks and best regards.
David Sánchez.
2016 Jul 18 9:51 AM
This parameter OFFSET of ARCHIVE_READ_OBJECT is optional (0 by default), do you need to access specific objects? If no, use 0.
ARCH_IDX_S is generated by program SBOOKI, but it's specific to the flight model, it's just a demo.
I think you should better read the ADK documentation rather than using demo programs.
2016 Aug 01 8:13 AM
Hi Sandra.
Thank you for the help and link to adk doc.
Best regards David Sánchez.
2016 Jul 18 10:30 AM
Hi
You should check the standard program (FBL1N.....) in order to know how reading the arcived document, anyway this is a piece of my program (it generates SL data for archived documents):
DATA: G_F_AFCAT LIKE AIND_STR1-SKEY.
DATA: G_T_AS_KEY TYPE STAB_AS_KEY.
Step 1: Filters creations
DATA: G_T_FRANGE TYPE TY_T_FRANGE.
PERFORM FILL_SEL_OPT USING: BUKRS[] 'BUKRS' G_T_FRANGE,
RBELNR[] 'BELNR' G_T_FRANGE,
RBLART[] 'BLART' G_T_FRANGE,
RBLDAT[] 'BLDAT' G_T_FRANGE,
RBUDAT[] 'BUDAT' G_T_FRANGE,
RCPUDT[] 'CPUDT' G_T_FRANGE,
PERIOD[] 'MONAT' G_T_FRANGE,
GJAHR[] 'GJAHR' G_T_FRANGE.
CALL FUNCTION 'AS_API_READ'
EXPORTING
I_FIELDCAT = G_F_AFCAT
I_SELECTIONS = G_T_FRANGE[]
IMPORTING
E_RESULT = G_T_AS_KEY[]
EXCEPTIONS
PARAMETERS_INVALID = 1
NO_INFOSTRUC_FOUND = 2
OTHERS = 4.
The ranges for selections are generated from selection-screen of the report
Step 2: Read data
*&---------------------------------------------------------------------*
*& Form READ_FROM_ARCH
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_TAB_BKPF text
*----------------------------------------------------------------------*
FORM READ_FROM_ARCH.
DATA : G_S_AS_KEY TYPE STYPE_AS_KEY.
DATA: ARCH_BKPF TYPE STANDARD TABLE OF BKPF.
* ARCH_BSEG TYPE STANDARD TABLE OF BSEG.
REFRESH: YBKPF, YBSEG.
DATA: L_HANDLE LIKE SY-TABIX.
CHECK P_ARCH = 'X'.
PERFORM BUILD_SEL_OPT USING 'X'.
LOOP AT G_T_AS_KEY INTO G_S_AS_KEY.
REFRESH ARCH_BKPF.
* REFRESH ARCH_BSEG.
CALL FUNCTION 'ARCHIVE_READ_OBJECT'
EXPORTING
OBJECT = 'FI_DOCUMNT'
ARCHIVKEY = G_S_AS_KEY-ARCHIVEKEY
OFFSET = G_S_AS_KEY-ARCHIVEOFS
IMPORTING
ARCHIVE_HANDLE = L_HANDLE
EXCEPTIONS
NO_RECORD_FOUND = 1
FILE_IO_ERROR = 2
INTERNAL_ERROR = 3
OPEN_ERROR = 4
CANCELLED_BY_USER = 5
ARCHIVELINK_ERROR = 6
OBJECT_NOT_FOUND = 7
FILENAME_CREATION_FAILURE = 8
FILE_ALREADY_OPEN = 9
NOT_AUTHORIZED = 10
FILE_NOT_FOUND = 11
OTHERS = 12.
IF SY-SUBRC <> 0.
CONTINUE.
ELSE.
CALL FUNCTION 'ARCHIVE_GET_TABLE' "#EC *
EXPORTING
ARCHIVE_HANDLE = L_HANDLE
RECORD_STRUCTURE = 'BKPF'
ALL_RECORDS_OF_OBJECT = 'X'
AUTOMATIC_CONVERSION = 'X'
TABLES
TABLE = ARCH_BKPF
EXCEPTIONS
END_OF_OBJECT = 1
INTERNAL_ERROR = 2
WRONG_ACCESS_TO_ARCHIVE = 3
OTHERS = 4.
* CALL FUNCTION 'ARCHIVE_GET_TABLE' "#EC *
* EXPORTING
* ARCHIVE_HANDLE = L_HANDLE
* RECORD_STRUCTURE = 'BSEG'
* ALL_RECORDS_OF_OBJECT = 'X'
* AUTOMATIC_CONVERSION = 'X'
* TABLES
* TABLE = ARCH_BSEG
* EXCEPTIONS
* END_OF_OBJECT = 1
* INTERNAL_ERROR = 2
* WRONG_ACCESS_TO_ARCHIVE = 3
* OTHERS = 4.
CALL FUNCTION 'ARCHIVE_CLOSE_FILE'
EXPORTING
ARCHIVE_HANDLE = L_HANDLE.
ENDIF.
IF NOT NO_KEY_FIELDS_ONLY IS INITIAL.
LOOP AT ARCH_BKPF INTO BKPF
WHERE BUKRS IN BUKRS AND
BELNR IN RBELNR AND
BLART IN RBLART AND
BLDAT IN RBLDAT AND
BUDAT IN RBUDAT AND
CPUDT IN RCPUDT AND
MONAT IN PERIOD AND
GJAHR IN GJAHR.
INSERT BKPF INTO TABLE YBKPF.
PERFORM SET_TAB_BKPF USING 'X'.
* LOOP AT ARCH_BSEG INTO BSEG.
* APPEND BSEG TO YBSEG.
* ENDLOOP.
ENDLOOP.
ELSE.
LOOP AT ARCH_BKPF INTO BKPF.
INSERT BKPF INTO TABLE YBKPF.
PERFORM SET_TAB_BKPF USING 'X'.
ENDLOOP.
ENDIF.
DELETE G_T_AS_KEY.
ENDLOOP.
ENDFORM. " READ_FROM_ARCH
In this way I've loaded BKPF data, you can do the same with BSEG table
But remember the item table (BSIx and BSAx) shouldn't be archived, so if you need to read data from there you don't need to read the archive
Max
2016 Aug 01 8:15 AM
Hi Max.
Your example is clear. Thank you.
We solved the problem with this example.
Best regards David Sánchez.