Tuesday 7 November 2017

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. 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 and ignore the error about the not found port!

SAP ERP, SAP Tutorial, Material and Certification, SAP Guides, SAP Module, SAP Live

4. 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”):

SAP ERP, SAP Tutorial, Material and Certification, SAP Guides, SAP Module, SAP Live

5. Target is a patch on your local machine.

6. Choose ASC for ASCII mode.

7. Execute the download.

8. 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).

SAP ERP, SAP Tutorial, Material and Certification, SAP Guides, SAP Module, SAP Live

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.

SAP ERP, SAP Tutorial, Material and Certification, SAP Guides, SAP Module, SAP Live

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) :

SAP ERP, SAP Tutorial, Material and Certification, SAP Guides, SAP Module, SAP Live

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.
SAP Online Guides, Tutorials, Materials and Certifications.

Related Posts

0 comments:

Post a Comment