Developing Reload Programs (Optional)

Use

A reload program is used to reload data from archive files back into the database and must process all the archived data of an archiving session. If not all the data is reloaded into the database, the remaining archived data is written to a new archiving session. Once an archiving session is reloaded, it can no longer be accessed from archive management.

The reload program reads the archive files using the ADK function modules (FM) and then reloads the data into the database. A reload program always only processes one archiving session at a time.

Procedure

Function Module Call Sequence

  1. Open archiving session for reloading – ARCHIVE_OPEN_FOR_MOVE
    This function module creates a new archiving session in production mode and passes two archive handles:
    • ARCHIVE_READ_HANDLE
      This corresponds to the archive handle returned by function module ARCHIVE_OPEN_FOR_READ. You can perform all read operations with it.
    • ARCHIVE_WRITE_HANDLE
      This archive handle enables you to write data objects that are not to be reloaded to the database into a new archiving session. You can therefore only call function module ARCHIVE_SAVE_OBJECT using this archive handle.
  1. Set commit counter to a small fixed value
  1. (Optional): Get structures for initialization data – ARCHIVE_GET_INIT_STRUCTURES

As of SAP Web Application Server 6.10, you use this function module to get the structures of the initialization data you passed in the write program using ARCHIVE_PUT_INIT_DATA.

  1. (Optional) Get initialization data – ARCHIVE_GET_INIT_DATA

As of SAP Web Application Server 6.10, you use this function module to get the initialization data you passed in the write program using ARCHIVE_PUT_INIT_DATA.

Steps 5-9 must be called in a loop for all archived data objects.

  1. Read archived data object from archiving session – ARCHIVE_GET_NEXT_OBJECT
    This function module:
      • Sequentially reads all archived data objects from the opened archiving session into ADK’s data container
      • For archiving class data, passes the data to the archiving class

The parameter OBJECT_ID must syntactically be CHAR.

  1. Get archiving object data – ARCHIVE_GET_NEXT_RECORD (or ARCHIVE_GET_TABLE where it makes sense)

You use this function module to get the archiving object data from ADK’s data container and store the data in an internal table for each structure or table. Call this function module in a loop within the loop started in step 5 until no more records can be read from ADK’s data container.

In the Unicode context, there are two possibilities for calling this function module:

    • Assign typed field symbols to the reference returned using the new parameter RECORD_REF
      (example: SBOOKR)
    • Assign untyped field symbols
      (example: SBOOKR_2)

In the Unicode context, it is no longer possible to use the CHAR record buffer variable for generic reading of records for structures containing non-character-like fields.

Decide whether to reload this data object into the database. If yes, only run steps 7 and 8. If no, only run step 9.

  1. Tell archiving classes to reload their data – ARCHIVE_RELOAD_OBJECT_DATA

This function module must be called after every ARCHIVE_GET_NEXT_OBJECT.

  1. Reload archiving object data into the database – Separate subroutine you develop

After each ARCHIVE_GET_NEXT_OBJECT, increase a counter by one. When the reload program is running in production mode, call your subroutine whenever the counter is equal to the Commit Counter set in step 2. In test mode, do not call this subroutine.

Your subroutine must:

    1. Read the internal tables and reload that data into the database
    2. Call ARCHIVE_GIVE_STATISTICS using the read archive handle to pass the number of records reloaded to ADK; to determine the number of records reloaded, use the parameter SY-DBCNT

      You must call this function module; otherwise the statistics function will not work correctly.

      Do not use the write archive handle to call ARCHIVE_GIVE_STATISTICS.

    3. Call COMMIT WORK and clear the internal tables
    4. Clear the counter
  1. Save data object not reloaded to a new archiving session – ARCHIVE_SAVE_OBJECT

If you do not call ARCHIVE_SAVE_OBJECT, you will no longer be able to access the data not reloaded through archive management.

    • Use the WRITE_HANDLE for this archiving object
    • ADK automatically knows which data object to write to the new archive file

If the Prohibit New Session During Reload indicator is set in AOBJ for the relevant archiving object, calling ARCHIVE_SAVE_OBJECT will have no effect.

End of loop

  1. (Optional) Get statistics from ADK – ARCHIVE_GET_STATISTICS

Only use the read archive handle for this function module.

In reload programs, ARCHIVE_GET_STATISTICS only works in production mode.

You use this function module to get the statistics ADK collected. You can then use these statistics to create your own specialized log.

  1. (Optional) Output standard statistics log – ARCHIVE_WRITE_STATISTICS

In reload programs, ARCHIVE_WRITE_STATISTICS only works in production mode.

You use this function module to output the standard archiving statistics log with the relevant information for the read program. This function module must be called directly before ARCHIVE_CLOSE_FILE.

  1. Close archiving session – ARCHIVE_CLOSE_FILE
    You use this function module to end the reload procedure.

This function module:

    • Closes the archiving session
    • In production mode, updates the archive administration data and sets the status of the archiving session to Replaced. This means the original archiving session is no longer accessible through archive management

If the No New Session During Reload indicator is set in AOBJ for the relevant archiving object, the status of the archiving session is not set to Replaced. This means the archiving session is still accessible in archive management and could be reloaded again into the database. You must ensure that the archiving session cannot be reloaded again or could be read along with the database when searching for a document, for example, which could possibly result in two identical documents being found.

    • Releases the included archiving classes
    • Discards the current archive handle

You only need to pass one of the two archive handles with the call. ADK automatically determines the second archive handle.

Result

When you finish developing your reload program, enter it for your archiving object in transaction AOBJ.

Example

Sample programs SBOOKL and SFLIGHTL (for archiving classes)