IDocs are archived in several tables and to reduce the load on Database without losing any IDocs, you can store them in archives at the operation level. Keep in mind that IDocs with error status can not be archieved. You can archive IDocs with status 3,18,19,21,31,33,38,40,41,53,57,68,70,73. If you are not able to archive IDocs with these status codes you can enable archiving option by using transaction code WE47. You are recommended to archive your IDocs if they are not older than 5 years, for those older than 5 years you may not need them anymore so you can delete them at your own risk.
RSEXARCA and RSEXARCB are archiving programs. RSEXARCB is similar to RSEXARCA except for the selection screen. The selection options for RSEXARCB are designed for periodic scheduling. RSEXARCD deletes archived IDocs from the database while RSEXARCR reads IDocs from an archive. And another program RSEXARCL Retrieves IDocs from the archive into the database
See below a step by step procedure for archiving IDocs.