Step by step Flat file parsing in webMethods 8.2
Aug 13, 2013 13:01 7 Comments Development wMDevloper


Normal 0 false false false DE X-NONE X-NONE


For the Parsing a Flat File we need to know about below concepts of Flat File i.e.

-> Flat File Dictionary

-> Flat File Schema

-> Flat File Document

-> Flow service for parsing Flat File


Normal 0 false false false DE X-NONE X-NONE

Introductions of Flat File:

  • Flat file is a complex hierarchical data in a record–based storage format.
  • The metadata of a flat file is separated from the data and contained in a flat file schema.
  • A single record of application data is externalized as a set of records without any structural information.
  • The application receiving the flat file must have information about the structure of the flat file, for this we are creating flat file schema, to read the flat file.
  • All Flat File have a list of records which containing fields and composites.



Normal 0 false false false DE X-NONE X-NONE

Types of Flat Files which Support by webMethods


The WmFlatFile package can communicate all types of flat files but can process only some types of flat files. The WmFlatFile package can process flat files in which:


· The records in the flat file are defined using one of the following methods:

· Delimiters- all record in the flat file is define by a delimiter.

· Fixed length- all record is a fixed number of bytes.

· Variable length- all record is define by two bytes that indicate the length of the record.

· Each distinct record structure has a record identifier, or if no record identifier is any, then record must be parsed using a default record definition.

· If the flat file contains record identifiers, the record identifiers must be located in the same location in all records in the file.

· The WmFlatFile package then can identify fields in these records based on :

· Delimiters- all field is separated by a delimiter, and the Nth delimited field is identified in the record.

· Byte position- all field is defined by one is the number of bytes from the beginning of the record and second is the field length.



Normal 0 false false false DE X-NONE X-NONE

Flat File Schema:


To communicate using flat files, we have to create a flat file schema that contains a particular flat file’s structural information, including how to identify records and separate those records into fields.

Flat File Constraints:

Flat file Schemas contain information about the document, record, and field levels of flat files. A flat file schema can define three types of constraints:

Structural Constraints: its describes the sequence of records, composites, and fields in a flat file.

For example, a flat file schema might describe Employee Details:

Content type constraints : its describe the possible values or minimum/maximum values for elements in a flat file.

For example, if there is a mobile number field might have a content constraint specifying that its value must be exactly ten digits.

Conditional constraints describe the valid combinations of fields and subfields allowed in records and composites.

For example, you can use the Required (R) conditional validator.

Flat File Schema Used to Parse Records in different type:

The WmFlatFile package provides the pub.flatFile:convertToValues service, which uses a flatfile schema to parse flat files inbound to the Integration Server. Record Parsers: The convertToValues service uses a record parser (Delimited, Fixed Length, or Variable Length) to parse the records in a flat file.A record parser breaks a flat file into individual records. In the WmFlatFile package, we can choose from one of its four record parsers:

•    Delimited Record Parser. This parser expects a specific delimiter to indicate the end of a
Record. For a record delimiter, you can specify A character, Hexadecimal value, Octal value,    Unicode characters. The occurrence of the record delimiter signals the end of one record and the beginning of the next record.

Example- No length describe for field, only record, field ,sub filed delimiter define like
Here record delimiter is ‘new line’ and field delimit is ‘*’


Normal 0 false false false DE X-NONE X-NONE




Normal 0 false false false DE X-NONE X-NONE

·Fixed Length Record Parser. This parser splits a file into records of the same pre-specified length. We can define parser measures records as in terms of lengths or position.


Example-In this field length is fixed like:

Field one have length 0 to10
second field have length 11 to 25
third field have 26 to 29

and record size is 30


name      address       age

After 30 character its take next record.



·Variable Length Record Parser. This parser expects each record to be preceded by two bytes that indicate the length of the record. We can describe record may be a different length.


·EDI Document Type Record Parser. This parser is used only for EDI flat files and provides additional functionality needed to properly parse EDI documents.



Record Identifiers: After each record in a flat file has been parsed, each record must be identified. This is done using the record identifier. Identifying the record provides the definition of that record, as defined in the flat file schema using the Flat File Schema Editor.

We can choose from one of two methods of record identification:

·Starts at position record identifiers compare the value that occurs in the record, at the specified offset, to all the record names defined in the flat file schema.

·Nth Field record identifiers use the value of the specified field as the record identifier. These identifiers count from zero (0). For example, if 1 is specified, the second field is used as the record identifier.




Extractors: Extractors take data out of a parsed record and place it in the output of the pub.flatFile:convertToValues service. If extractors are not defined in the flat file schema, the Parser returns a series of records that contain no fields or composites. Fields and composites are extracted from a record based on the position of the field delimiter. Fields also can be extracted from a record based on a sub-string of the original record starting at a particular byte count and ending at a particular byte count.




Normal 0 false false false DE X-NONE X-NONE

Undefined Data: In some cases, the data resulting from the pub.flatFile:convertToValues service might contain records that were not recognized, known as undefined data. This could be a result of the complexity of the flat file, or of the lack of detail in the flat file schema.



Default Records:

If the pub.flatFile:convertToValues service cannot recognize a record ,the record will be treated as undefined data unless you specify a default record definition to be used to parse all unrecognized records of a particular type. In fact, if you’re flat file schema does not contain any record identifiers, You must specify a default record. A default record can only be defined in a flat file Dictionary.



Finally, the parsed record is placed in the output data based on the structure defined in the flat file schema. This process is repeated until all records in the flat file have been Parsed.


Flat File Dictionary

A flat file dictionary is simply a repository for elements that you reference from flat file schemas. This allows you to create record definitions in a dictionary that can be used across multiple flat file schemas. Reusing record definitions reduces the amount of memory consumed by a flat file schema.

Prev Next
About the Author
Topic Replies (7)
  1. 1
    idnkx user


    Excellent, this resolves all my doubts on Flat files. wMDeveloper you are amazing i am learning wM following your blogs. Thanks much for uploading the step by step scenarios for beginners. Ansari.

    idnkx user


    Hi ...... I gone your documentary presentation. Its very nice .... I need a small favor from your end, how do you create flat file schema DT. Just share that screen shots separately to my mail ID ::: The schema I know with record,segment and loop id (and) recordswithnoID. You done additional activity also, In [b]SchemaFlatFileDT[/b] i want to create like that as per my requirement.

    idnkx user


    Can you post with variable length flat file example?

    idnkx user


    ok,i will post variable length flat file example.

    idnkx user


    Hi, We have a specific requirement. Get all the flat files from a file server and send the batch size of 200 records to another ESB . Where can I get information for Batch File processing? or some documentation to understand Batch File processing. Thanks for your information !

    idnkx user


    Hello, Regarding your sample with Large files, you do a getFile outside of the loop in Bytes. Won't that read the complete document and beat the purpose of the iteration? Thanks

Leave a Reply
Guest User

You might also like

Not sure what course is right for you?

Choose the right course for you.
Get the help of our experts and find a course that best suits your needs.

Let`s Connect