This article explains about how to achieve flat file processing in webmethods.io integration.
For this exercise create a simple flatfile which has below structure. (copy the below contents in notepad and save the file as ‘flatfile’)
3. Create Flat file application
In webmethods.io there are two ways to create the flat file application i.e. create manually or create from a sample file.
3.1 Define schema manually
Login to webmethods.io and navigate to webmethods.io flow editor.
Click on Default project and select applications.
Under the applications select Flat file Applications -> Add New Application
Under define, application provide name and description and select the creation mode as ‘Create manually’ and click Next
Under the Flat file, definition define the record parser as ‘Delimiter’, record as \n and field or composite as ,-comma
Select the Record Identifier Nth field as ‘0’ , then click Next.
In the next screen, you need to define the flat file structure i.e. integer,1,2,3,4
Click on schema definition and click + button -> it will appear as record definition.
You need to name the record as integer since in this exercise our flat-file data has integer as an identifier.
also since we have more data we need to set Max to repeat as ‘unlimited’.
Next, we need to define the field definition click on + button again and select field definition from the dropdown and name the field as f1.
Extractor type: Nth Field
Repeat the above steps for three more field definitions and select the Extractor as 2,3,4
For example for second field , repeat the same for third and fourth field also.
Name : f2
Extractor type : Nth Field
Extractor : 2
Finally your flat file structure should look like below, upon completion click Finish.
Once the application is created you will get two operations listed below.
Run the convertFlatFileToDocument by passing the flatfile in ffDataString.
Click on convertFlatFileToDocument and click Test , provide the ffDataString and say Run.
You should see document list is getting created with the record identifier i.e. integer.
Similarly, you can convert a document to Flatfile by running the convertDocumentToFlatFile .
In the input section expand ffschema_dt, click on + button next to integer document.
Provide the field definition values as below -> Run.
Service execution should be successful and you should get the flat file as below.
3.2 Define FlatFile Application from a Sample file
Click on Flat file application and say new application, in this case, select ‘Create from a sample file’ then click browse.
Browse the file you created in the pre-requisite section, in preview it will display the contents as below.
In the next page, it will automatically set the record as \n and you can define the field or composite to , (comma) to split the data.
After specifying the field as , (comma) , you can see the preview changes based on your data.
Click on next and in this case, it will automatically define FlatFile structure for you.
Once you have done the above steps and say Finish this will be the same as you manually created section 3.1. (you can run the operations as explained in section 3.1)