Archiving IDocs in SAP (Write & Delete): A Step-by-Step Guide for First-Time Implementation

Estimated read time 7 min read

Introduction

In every SAP system, managing IDocs effectively is crucial—not only for performance but also for long-term data governance. Recently, I worked on IDoc Archival (write & delete only) for a client doing this for the first time.  Here’s the complete, detailed process I followed—including handling issues like undeleted IDocs, restricted statuses, and tips on using SARA .

Whether you’re a consultant, admin, or BASIS team member, this guide is designed to help you implement IDoc archival without missing critical steps.

What Is IDoc Archiving?

IDoc (Intermediate Document) archival is the process of transferring IDocs from the SAP database to an archive file and then deleting them from the system to improve performance and reduce storage costs. Archiving ensures compliance with data retention policies while keeping historical data accessible if needed.

Writing eligible IDocs into archive files: Identifies and extracts data that meets archiving criteria, then stores it in archive files for long-term retention.

Deleting those IDocs from the database: After successful archiving, the original data is safely deleted from the database, improving system performance.

This improves DB performance, frees up space, and helps meet compliance rules.

 

Key Notes Before Starting

IDoc archiving is not just about deletion. You must first archive (write) before you can delete.You must define a path for archive files ( FILE or AL11 ).Get authorization for SARA, WE47, WE09.

 

Writing the Archive (SARA ➝ Write)

Go to SARA, enter Object: IDOC.

Click Write.

Create/maintain a variant with selection criteria:

Give a new name for Variant, then click Edit.Select For All Selection Screen & Press Continue on the popup dialog box.Configure the selection criteria: Date Range: Give the date range as required , as given below.

Scroll Down & give Processing option as Production Mode.

For saving a variant: click Attributes > give variant description & save the variant.
Define spool parameters and start time.Execute (immediate or background).Monitor via SM37—Job Name, e.g., ARV_IDOC_WRITE_…Confirm archive files are created (check in AL11).

Outcome: IDocs are now stored in the archive but still exist in the SAP database.

Note: The program behind this Write step is RSEXARCA.

 

Deleting Archived IDocs (SARA ➝ Delete)

Back in SARA, click Delete.

Select the archive files created in the Write step.

Schedule or execute a deletion job.

Monitor job ARV_IDOC_DELETE_.. in SM37.

Done! IDocs are now deleted from the database.

Problem: IDocs Still Exist After Deletion?

If SE16N shows entries still in EDIDC after deletion, it’s usually due to status restrictions in WE47.

Fix: Handling Restricted IDoc Statuses via WE47

Certain statuses (e.g., error status) are not eligible for deletion unless explicitly allowed.

Check out my post for a detailed explanation of  Controlling IDoc Deletion Using WE47: How to Restrict and Unrestrict IDoc Statuses for Archiving 

Follow these steps:

Use SE16N to find undeleted IDocs in EDIDC and note their STATUS.
Go to transaction WE47.
Locate the status code (e.g., 64, 51).
Open and adjust the status restriction to allow deletion .
Save your changes.
Re-run both the Write and Delete processes in SARA.

This should now remove those unwanted IDocs.

Check out my post for a detailed explanation of  Controlling IDoc Deletion Using WE47: How to Restrict and Unrestrict IDoc Statuses for Archiving 

 

Additional Utilities (Standard Report Programs)

Sometimes you may want more control via report programs:

 Report Program  Purpose RSEXARCAArchive IDocsRSEXARCDDelete archived IDocsRSEXARCRRead archive fileRSEXARCLReload IDocs from archive

 

Conclusion

IDoc archiving is a crucial piece of keeping your SAP system lean and efficient. This guide should help any consultant or admin confidently implement it, even on the first try. If you found this useful or have questions about specific issues, feel free to drop a comment below!

I hope this helps! Let me know your thoughts or if you have any questions.
Thanks,

Akshay Anil 
Technical Consultant, SAP ABAP | BTP | Fiori | Ui5

 

​ IntroductionIn every SAP system, managing IDocs effectively is crucial—not only for performance but also for long-term data governance. Recently, I worked on IDoc Archival (write & delete only) for a client doing this for the first time.  Here’s the complete, detailed process I followed—including handling issues like undeleted IDocs, restricted statuses, and tips on using SARA .Whether you’re a consultant, admin, or BASIS team member, this guide is designed to help you implement IDoc archival without missing critical steps.What Is IDoc Archiving?IDoc (Intermediate Document) archival is the process of transferring IDocs from the SAP database to an archive file and then deleting them from the system to improve performance and reduce storage costs. Archiving ensures compliance with data retention policies while keeping historical data accessible if needed.Writing eligible IDocs into archive files: Identifies and extracts data that meets archiving criteria, then stores it in archive files for long-term retention.Deleting those IDocs from the database: After successful archiving, the original data is safely deleted from the database, improving system performance.This improves DB performance, frees up space, and helps meet compliance rules. Key Notes Before StartingIDoc archiving is not just about deletion. You must first archive (write) before you can delete.You must define a path for archive files ( FILE or AL11 ).Get authorization for SARA, WE47, WE09. Writing the Archive (SARA ➝ Write)Go to SARA, enter Object: IDOC.Click Write.Create/maintain a variant with selection criteria:Give a new name for Variant, then click Edit.Select For All Selection Screen & Press Continue on the popup dialog box.Configure the selection criteria: Date Range: Give the date range as required , as given below.Scroll Down & give Processing option as Production Mode.For saving a variant: click Attributes > give variant description & save the variant.Define spool parameters and start time.Execute (immediate or background).Monitor via SM37—Job Name, e.g., ARV_IDOC_WRITE_…Confirm archive files are created (check in AL11).Outcome: IDocs are now stored in the archive but still exist in the SAP database.Note: The program behind this Write step is RSEXARCA. Deleting Archived IDocs (SARA ➝ Delete)Back in SARA, click Delete.Select the archive files created in the Write step.Schedule or execute a deletion job.Monitor job ARV_IDOC_DELETE_.. in SM37.Done! IDocs are now deleted from the database.Problem: IDocs Still Exist After Deletion?If SE16N shows entries still in EDIDC after deletion, it’s usually due to status restrictions in WE47.Fix: Handling Restricted IDoc Statuses via WE47Certain statuses (e.g., error status) are not eligible for deletion unless explicitly allowed.Check out my post for a detailed explanation of  Controlling IDoc Deletion Using WE47: How to Restrict and Unrestrict IDoc Statuses for Archiving Follow these steps:Use SE16N to find undeleted IDocs in EDIDC and note their STATUS.Go to transaction WE47.Locate the status code (e.g., 64, 51).Open and adjust the status restriction to allow deletion .Save your changes.Re-run both the Write and Delete processes in SARA.This should now remove those unwanted IDocs.Check out my post for a detailed explanation of  Controlling IDoc Deletion Using WE47: How to Restrict and Unrestrict IDoc Statuses for Archiving  Additional Utilities (Standard Report Programs)Sometimes you may want more control via report programs: Report Program  Purpose RSEXARCAArchive IDocsRSEXARCDDelete archived IDocsRSEXARCRRead archive fileRSEXARCLReload IDocs from archive ConclusionIDoc archiving is a crucial piece of keeping your SAP system lean and efficient. This guide should help any consultant or admin confidently implement it, even on the first try. If you found this useful or have questions about specific issues, feel free to drop a comment below!I hope this helps! Let me know your thoughts or if you have any questions.Thanks,Akshay Anil Technical Consultant, SAP ABAP | BTP | Fiori | Ui5   Read More Technology Blog Posts by Members articles 

#SAP

#SAPTechnologyblog

You May Also Like

More From Author