Sap Idoc Flat File Format

Posted by admin

Overview:Sap adapter module IDOCFlatToXmlConvertor can be used to convert messages from IDoc flat file to XML format. Normally it’s added in the sender adapter so that the message gets converted to XML format.In this blog, I’ll describe the approach of the journey of migrating from a custom solution to the standard bean IDOCFlatToXmlConvertor.Existing Solution:Existing solution to convert flat files to IDocs was created in SAP PI 7.0 system.

  1. How To Use User Module For Conversion Of Idoc Messages Between Flat And Xml Formats
  2. Sap Idoc Flat File Format Form

As there was no standard bean to convert flat files to IDocs, we built a custom bean to do the flat file to IDoc conversion.The solution relied on SAP IDoc metadata to be present on the ABAP stack on SAP PI system.Our files can have some extra fields in the beginning 10 characters.Some files can have segment type, others will have segment definitions.The file can have data for multiple IDocs.Files can be in ALE format ( i.e. Control and data record is a single continuous string)e.g. ALE file formatNon ALE format with segment type and leading DATA and CONTROL recordsNon ALE-format with segment definitionAbove are three examples files but the data could be in any combination of formats and segment type/segment definition information.The drawback of the solution:. Not future ready with SAP’s integration strategy of SAP PO ( Java only system). The metadata is being read from SAP PI ABAP stack.

The IDoc metadata needed to be manually refreshed if there was an IDoc change.However, the solution was pretty robust and was being used by thousands of adapters ( 2000+ ).Starting Getting Ready for FutureWhile doing migration from PI 7.0 system to PI 7.4 system, we had to code the adapter module again as the underlying Java APIs have modified. We decided not to try to switch to the standard bean as the standard bean doesn’t do the following:. Our files can have some characters at the beginning which needs to be removed. The data can be segment type or segment definition. Originally the standard bean worked only with segment definitions.

This was enhanced by allowing segment type processing. (See note 2267985 ). However, we can’t identify in mass if an adapter will process segment type or segment definition.

Some files are in ALE format.

How To Use User Module For Conversion Of Idoc Messages Between Flat And Xml Formats

If you want to download iDocs as files, there are several standard SAP options. But, if you want to convert an iDoc in your SAP system as an, capabilities and limited. You may need to download an iDoc created in the system in XML format for multiple reasons. You may want to communicate iDoc samples in XML format with third party systems for requirement analysis purposes. Especially in integration scenarios with external third party systems before setting up the actual interface, you may be required to share sample iDocs in XML formats with the third party system owners.

The ABAP program I have created to convert a sample iDoc to a local XML file will be helpful in such scenarios.In this article we will discuss:. Custom ABAP Z Program Logic to Download or Convert iDocs to XML files. Alternative Methods to Download iDocs as XMLs.

How to download iDoc data to other different file formats such as HTML, Spreadsheet, text etc.SAP Versions used in the illustration:. SAP S4 HANA Fashion 17091. Custom Z ABAP Program to Download/Convert iDocs to XML files. Selection screen:Basic selection screen with two parameters to enter the iDoc number and the local directory path XML file would be saved. File name will be defaulted to idoc.xml. More on can be found in my. Selection screen of ABAP program to download iDoc to XML file.Output:iDoc xml will be downloaded to given location in file path.

Sap Idoc Flat File Format Form

Download iDoc XML to local driveiDoc data downloaded in XML formatABAP Code to download iDoc as XML:The program was developed in SAP S4 HANA client, and it is compatible with newer SAP HANA versions. Copy the program code to a new executable Z ABAP program in transaction se38 to start using it.&-.& Report ZIDOCTOXML.&-.&.&-.REPORT zidoctoxml.Global tablesDATA: gtdyfields LIKE dynpread OCCURS 0 WITH HEADER LINE, 'screen fieldsgtdatatab TYPE TABLE OF string WITH HEADER LINE. 'download data tab.Global variablesDATA: gvfilename TYPE string VALUE 'idoc', 'file namegvpath TYPE string, 'file pathgvresult TYPE i,gvxmlstr TYPE string. 'XML stringDATA: idoc TYPE REF TO clidocxml1. 'iDoc class instance.Selection ScreenSELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE TEXT-002.PARAMETERS: pdocnum LIKE edidc-docnum OBLIGATORY.

'iDoc numberPARAMETERS: ppath TYPE string LOWER CASE OBLIGATORY. ENDIF.2. Alternative method to download iDocs as XML.If you do not want to create a new Z program in your system or you are not an ABAPer, you can configure a test partner profile using transaction we20 and configure an outbound profile with the desired message type/iDoc basic type. Assign a file port to the outbound partner profile configuration and reprocess the iDoc using transaction we19 or any other test tool. IDoc XML will be generated at SAP server location (al11) configured in file port.iDoc XML downloaded to al11 location can be extracted to a local machine using transaction cg3z. Download iDoc as Spreadsheet, HTML, text, etc.If you want to download iDocs to other file formats such as Excel or html, there are several standard SAP options available. Download iDoc using Transaction IDOC.Using transaction iDoc and using option ‘Analyze iDoc Field values’ you can download iDoc data to multiple different formats. Analyze iDoc field valuesBut I was not able to convert the iDoc data to the external XML format.

Download iDoc to different file formats. Save iDoc as File using Transaction we02.Using we02 you can also download iDoc to a local file.

Sap Idoc Flat File Format

Use we02 to download iDocs. View XML format using Function Module IDOCXMLTRANSFORM.Go to transaction se37 and execute the FM IDOCXMLTRANSFORM with iDoc number as input. You will be able to and data segments. View iDoc XML format using Function Module IDOCXMLTRANSFORMiDoc XML view using Function Module IDOCXMLTRANSFORMCheck out my other posts on and please leave a comment if you have questions. About Author Isuru FernandoHi, I am Isuru Fernando, Senior SAP Integration Consultant with 10 years of SAP full-cycle implementation and support project experience.From the early days, I had a passion for coding, software development, and everything tech-related. I started my carrier as an ABAP developer and soon found my love for system integration when I learned SAP XI 3.0 in 2008.