Flat File Handling in webMethods.io

Overview :


In this article, we’ll learn how to work with flat files in webMethods.io. We’ll create a flat file connector in a webMethods.io project, use it to parse the flat file, and then consume and transform the data as needed.

Prerequisites:


  • Must have access to the webMethods.io environment.
  • Basic knowledge of Flat files.

Creating Delimitated Flat File Connector :


Parsing a flat file in webMethods.io involves several steps, including creating a project, creating a connector, and making use of it to parse the flat file. Follow the process below to create the connector, and note that we will be using the flat file provided for parsing.

EmployeeID,FirstName,LastName,Department,Position,Salary
1001,John,Doe,IT,Software Engineer,75000
1002,Jane,Smith,HR,Human Resources Manager,80000
1003,Robert,Johnson,Finance,Financial Analyst,70000
1004,Susan,Williams,Marketing,Marketing Specialist,72000
1005,Michael,Anderson,Operations,Operations Coordinator,68000

 

  • Navigate to your webMethods.io environment and create a project and give it a proper name.
  • Navigate to the connector tab of the project, and click on the ‘Flat File’ option. You will observe a button called ‘Add Connector‘, click on it to create a flat file connector.
  • You will be presented with two options: one to create the connector manually and the other to create it from a flat file. We will proceed with creating the connector manually, so please select the ‘Create manually‘ option and click next.
  • Please provide a name for your Flat File connector and a description. Optionally, you can enhance its visibility by uploading an icon. Once done, click ‘Next‘ to proceed.

  • Configure below in the Flat File Definition section and click ‘Next‘.
    • Choose a parser suitable for the flat file schema: Select Delimiter.
    • Record: Set it to ‘\n Line Feed‘.
    • Field or Composite:’,- Comma‘.
    • Record Identifier: Turn it off as our record does not have an identifier.
  • In the Flat File Structure section define fields and their positions as shown in the screenshot, this is similar to the flat file dictionary concept in webmethods on-premise.
    Flat File Structure
  • Once structure creation is completed then save the Flat File connector.

Parse Flat file using the connector in a flow service :


  • Navigate to the Integration tab of your project, you will be able to see the ‘Flow services’ option, click on the plus icon, and create a new flow service.
  • Provide a valid name to your flow service.
  • In the i\o section of the flow service, define a variable using which we will pass the flat file content.
  • In the flow service search with your flat file connector name and select the connector, in the actual scenario, you need to put your code inside the try-catch block and handle errors efficiently.
  • In the Action selection, choose ‘convertFlatFileToDocument‘, which will convert our flat file data into a document. This action is similar to the ‘convertToValues‘ service in webMethods on-premise.
  • In the pipeline, map your input string to ‘ffDataString,’ and set ‘validate‘ to ‘true’ with ‘maxErrors‘ set to ‘-1‘.
  • Save the Flow service and run it with the above CSV content, you will see the result.

Hope you have enjoyed this article, Cheers!

 

Leave a Comment