Skip to Content
Technical Articles
Author's profile photo Philippe Addor

How to Create and Read Flat IDocs from Files in SAP

I have recently come  across the need to “manually” move an IDoc for testing purposes form one SAP system to another. The two systems were in two different environments and not planned to be connected network wise. So we needed a way to export and import an IDoc.

The idea was to export the IDoc on system A to a file and then import it in system B from that file. It seemed an easy task, but turned out to be quite tricky. I haven’t found much help from searching online or in SAP docs but enough to put something together that worked at the end. I’d like to share this here in a step-by-step guide.

Please note that this is only for manual testing purposes for single cases and not intended to serve as any kind of IDoc interface.

We firsts export an existing IDoc from source system, download the file to the local computer and then upload it to another system:



1 How to export a flat IDoc file in SAP ERP:


SAP GUI, Transaction Code: WE19

  1. Load an existing Idoc (see we02) via idoc number.
  2. Click on “inbound file” (note: this is actually confusing. You’re going to write a file to the file system, but the function is called inbound file. But it’s all right and you can go ahead.)
  3. Uncheck the checkbox “start inbound processing of file now”.
  4. Enter a path on the server (use transaction AL11 to find a suitable path) and a filename. The file name can be chosen freely. Execute the function.


  1. Download the exported file to your local machine using Transaction Code: CG3Y (or FM ARCHIVFILE_SERVER_TO_CLIENT as per a reader’s comment).
    You can also use AL11 which displays a list of all available files. Select the file and then click the button marked below (“Download File as Text”):
  2. Target is a path on your local machine.
  3. Choose ASC for ASCII mode.
  4. Execute the download.
  5. You can now edit the file on your PC if needed, or further process/distribute it. Or you can now upload it e.g. to another SAP system and edit it there before processing (see next chapter).



2 Upload and Inbound Process a Flat IDoc File

  1. Upload the file using transaction code CG3Z (or FM ARCHIVFILE_CLIENT_TO_SERVER as per a reader’s comment) e.g. to a temp directory.
  2. Use t.code WE19 and select “File as Template”.
  3. Enter the path where you’ve uploaded the file and the filename.
  4. The test tool displays your IDoc, you can also change it here.
  5. You also need to create the control record (I don’t go into details of this here as this is required knowledge about the standard IDoc processing and can be found elsewhere). To create the control record, click on the first line in the editor and enter the data as needed (of course, change the name to your IDoc’s message type. Here it’s a business partner IDoc) :
  6. When you’re ready, click “Standard Inbound”. If a partner profile (WE20) exists, it will be processed after executing the function (or collected for later processing). See the status of the new IDoc in WE02.


Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Good post, I've seen request for this before, only for newer installed systems these up/download transactions are not present, but there are functon modules that have similar functionality:




      Author's profile photo Philippe Addor
      Philippe Addor
      Blog Post Author

      Thank for posting the FM names!

      I was working on a S4/HANA system that was relatively newly installed but customized to some extend already, and the transactions were present.

      Author's profile photo Michelle Crapo
      Michelle Crapo

      Nice!   Anything that can get me from a production system to my development one is a great post!  IDOCs always are a bit of a challenge with the deep structures.

      Author's profile photo Philippe Addor
      Philippe Addor
      Blog Post Author

      Exactly! Glad it's helpful for others too.

      Author's profile photo Mohammed Shoeb Inamdar
      Mohammed Shoeb Inamdar

      Thanks for the post!

      Can we anyway read the file from local desktop in WE19? for me it seems to be working only if i read it from server.

      Author's profile photo Philippe Addor
      Philippe Addor
      Blog Post Author

      As far as I know, it has to be uploaded to the server. As written in the blog, you need to use report CG3Z or the mentioned FM to do so. But I believe I have recently seen on a newer release of S/4 that WE19 now also provides a file upload functionality. On older systems, one definitely needs to upload it to the server (and needs permission for this).