Description

The FixedFileSegmentMergeReceiver merges the data from two or more segmented data files using the SegmentDataCreatorReceiver, into one or more Fixed file formatted output files.


In This Article

When should this Receiver be used? 

  • Any time you want to generate nested fixed file output.


When should this Receiver not be used? 

  • Any time you want to generate another type of nested output.


Are any additional items required to use this Receiver? 

  • SegmentDataCreatorReceiver- Must be assigned to each Domain, except the Merge Domain.
    • Note: The FixedFileSegmentMergeReceiver should only be assigned to the Merge Domain that merges the generated segments.

  • Configuration File - Used to determine the XML output format. This is typically named "config.xml", but can be named differently if needed. 
    • Note: When named differently, the name will also need to be changed for the configName parameter within the Receiver.

  • Template Files - Automatically created for each Domain when the configuration file is downloaded to the user's local machine and referenced within the configuration file to determine the XML output format.


List of Steps to Generate Nested Fixed File Format

  1. Set up a Project with Domains, Parent-Child Relationships, and Scenarios.
  2. For each Domain except the Merge Domain, complete the following: 
  3. Create a Merge Domain with just an id Attribute 
    • Note: This may have already been done if Domains were imported.
  4. Add the FixedFileSegmentMergeReceiver to the Merge Domain and configure it, as discussed in this article. 
  5. Create a Scenario Chain with all Domain Scenarios. Make sure the Merge Scenario is in the last position.
  6. Create a Configuration File as discussed in this article. 
  7. Download the Scenario Chain to your local computer.
  8. Download the Configuration file to your local computer. 
    • Note: This is a zip file containing the configuration and Domain template files. It will need to be unzipped, and all files will need to be placed in the location defined here (see the image below):


Receiver Parameters

The FixedFileSegmentMergeReceiver requires that the following parameters are defined. Items with an asterisk* are required.

  • outputPath* - Defines the location to store the newly generated nested Fixed text file(s).
  • outputSubDirectory* - Defines the prefix name of subdirectories that are auto-created under the outputPath and then appended with a number.
  • configPath *- Defines the location where the configuration file will be stored.
  • configSubDir - Defines the subdirectory under the configPath directory where the configuration file will be stored.
  • configName* - Defines the name of the configuration file.
  • segmentPath* - Defines the path to the Segment directory where all segment subdirectories can be found.
  • segmentSubDirectory* - Defines the subdirectory under the segmentPath where segment files can be found.
  • overrideFileName - Defines the fileName, which will override the fileName provided in the configuration file.
  • filesPerOutputSubDir* - Defines the number of files to be generated per output subdirectory.
  • deleteOutputSubDir - Defines whether to delete the generated or an existing outputSubDirectory or not during the execution of the Scenario.
  • sequenceNumberPlaceholder - Defines the placeholder for the Sequence number, which will be replaced while creating the fixed file. 
  • sequenceNumberLeftPadValue - Defines the pad Value for the sequence number.
  • rowCountLeftPadValue - Defines the pad Value for the row count in the last row. Use GR_ROW_COUNT constant in your Attribute's Generator to be replaced with row count in the generated file with optional Pad value. 
  • deleteSegmentDir - Defines whether to delete the Segments directory. or not after Scenario Execution
  • multipleFileOutput - Determines whether the nested records will be generated in one or multiple output files based on the loop count of the Root Domain. When set to "False," only one file containing all nested records will be generated. When set to "True," one file will be created for each nested record to generate multiple output files.


Receiver Attribute Property Keys

There are no property keys necessary for this Receiver.


File Config Tab

The File Config Tab is used to configure what event will trigger file creation and the naming configuration for generated files. Please click here for more information on how to use the File Config Tab.


The example below will create a new file for every 100 records. The naming for each file will look like Output-1.txt, Output-2.txt, Output-3.txt, and so on.


Directory Config Tab

The Directory Config Tab is used to configure what event will trigger directory creation and the naming configuration for generated directories. Click here for more information on how to use the Directory Config Tab.


In the example below, a subdirectory will be created for every 10 files. Each subdirectory's naming will look like AddressFiles1, AddressFiles2, AddressFiles3, and so on.



Example Transaction Story

In this use case, the user wants to generate five transaction records per day. So, the five transaction records will be generated for each record header which will be followed by a record trailer.


So, the following example is based on the generation of segmented data for three Domains. There are three Domains that represent the following hierarchy in parent-child relationships:

  • FileHeaderDomain is the root Domain
  • TransactionRecordDomain is a child of the FileHeaderDomain
  • FileTrailerDomain is a child of the FileHeaderDomain


Each Domain will use a SegmentCreatorReceiver to generate segmented data output with referential integrity with regard to parent-child relationships. The last Domain, Merge, will also use a FixedFileSegmentMergeReceiver to merge the segmented data generated for each Domain into one or more nested Fixed text output files. 

Four Scenarios will be created, out of which three Scenarios (having SegmentDataCreatorReceiver) will be containing the instruction on how much-segmented data to generate for each Domain, and the last Scenario will merge the segments together to generate the output. Lastly, the Scenarios can be chained together so that they can be run with one command instead of four separate commands.



Configuration File

The FixedFileSegmentMergeReceiver requires a configuration file (e.g., config.xml) to properly merge the generated segments. In most cases, this will need to be manually created within the GenRocket web platform. For some Domain Imports, this configuration file is created automatically for you.


The configuration file defines the following elements of information:

  1. fileNameSegments - contains sub-elements that define how file names are created for each delimiter file generated.

  2. segmentFiles - contains sub-elements that define the file names of the segment data files to merge.

  3. elements - contains nested subelements that define the format of the Fixed text output.


Steps to Create Configuration File

  • Within the Project Dashboard, select the Configuration Management Tab within the Management pane.
  • Click the New Configuration button.



  • Select the Fixed Format radio button and click the Select button.



  • Enter the required parameters to create a configuration file and click the Save button.
    • Name - Defines the unique name for the Fixed File configuration.
    • Config File Name - Defines the name of the configuration file that FixedFileSegmentMergeReceiver will read to create a Fixed File format file.
    • Output File Name Format - Defines the format for the name of the output file.
    • Definitions - Defines the various segment and template files that will be used to build nested XML.


  • Arrange the Segments in a hierarchy with one segment defined as the Root Domain Segment. 
  • This can be done by dragging/dropping the segments. 
  • Once finished, click Done.


    Important: In the example above, FileHeader is the Root Domain Segment. If one is not present in the hierarchy, the user will receive an error during test data generation.


Steps for Downloading Configuration File

Once the configuration file has been created within the GenRocket web platform, the user must download it to their local machine along with any other required files (e.g., Scenario, Scenario Chain, Scenario Chain Set, Test Data Cases).

This can be done by clicking on the Download (Cloud) icon for the configuration file within the Configuration Management Tab.


A zip file will be downloaded to the user's local machine. This is typically the user's downloads folder. This zip file will contain the configuration file and the required template files for generating the nested fixed file format data.



The user must copy these files (config and templates) to a "config" subdirectory located in the path defined for their resource.output.directory Organization Resource.


Note: If the subdirectory value has been changed within the FixedFileSegmentMergeReceiver, the configuration and template files must be placed there.


Example Configuration File 

The created configuration file for this example is defined to allow three-segment files to be merged into one or more Fixed nested output files. The format of the segmented data must produce nested output which meets the following rules:

  • There must be one fileHeader record to be generated in the Fixed-format text file.
  • Each fileHeader must have five transaction records
  • Each fileHeader must have one fileTrailer  


The XML configuration file

The following is a preview of the XML configuration file, which will produce the Fixed file formatted output files based on the settings provided in the configuration file.


<Config>
  <fileNameSegments>
    <fileNameSegment segmentType='Constant' value='FixedFile-' />
    <fileNameSegment segmentType='Counter' value='1' />
    <fileNameSegment segmentType='Constant' value='.txt' />
  </fileNameSegments>
  <segments>
    <segment domainName='FileHeader' templateFile='FileHeaderTemplate.xml' segmentFile='FileHeaderSegment.xml' partitionSegmentSubDir='' ignoreLineSeparator='false' />
    <segment domainName='TransactionRecord' templateFile='TransactionRecordTemplate.xml' segmentFile='TransactionRecordSegment.xml' partitionSegmentSubDir='' ignoreLineSeparator='false' />
    <segment domainName='FileTrailer' templateFile='FileTrailerTemplate.xml' segmentFile='FileTrailerSegment.xml' partitionSegmentSubDir='' ignoreLineSeparator='false' />
  </segments>
  <segmentHierarchy>
    <segment domainName='FileHeader'>
      <segment domainName='TransactionRecord' />
      <segment domainName='FileTrailer' />
    </segment>
  </segmentHierarchy>
</Config>


The example configuration file defines the following information.


FileNameSegments

The subelements will produce a file naming convention that looks like the following:

  • FixedFile-1.txt


TemplateFiles

The following template files will be loaded and used to create the XML output when merged with segment data.

  • FileHeaderTemplate.xml
  • TransactionRecordTemplate.xml
  • FileTrailerTemplate.xml


SegmentFiles

The following segment files will be loaded, and their data used in the merge process.

  • FileHeaderSegment.xml

  • TransactionRecordSegment.xml

  • FileTrailerSegment.xml


Elements

The elements and subelements are configured to produce the following nested Fixed structure.


File Header Record
Detail Entry Record 1
Detail Entry Record 2
Detail Entry Record 3
Detail Entry Record 4
......
File Trailer Record


Template Files 

The Template Files are created automatically when the configuration file is downloaded to the user's local machine.

The three template files created for this example are discussed in this section. Each template file below represents a block of XML elements used for merging with segment data that, combined together, will create a nested Fixed file.


FileHeader Template

This template will be used for data segment merging with <segment name="FileHeader">

<Segment name='FileHeader'>
  <attributes>
    <attribute fieldName='recordType' length='2' />
    <attribute fieldName='fileId' length='6' />
    <attribute fieldName='fileIdSeparator' length='2' />
    <attribute fieldName='fileIdValue' length='12' />
    <attribute fieldName='filler' length='12' />
  </attributes>
</Segment>


TransactionRecord Template

This template will be used for data segment merging with <segment name="TransactionRecord">


<Segment name='TransactionRecord'>
  <attributes>
    <attribute fieldName='recordType' length='2' />
    <attribute fieldName='customerNumber' length='10' />
    <attribute fieldName='customerAccountNumber' length='12' />
    <attribute fieldName='transactionId' length='36' />
    <attribute fieldName='transDate' length='12' />
    <attribute fieldName='cardNumFirst6' length='7' />
    <attribute fieldName='totalTransAmt' length='12' />
  </attributes>
</Segment>


FileTrailer Template

This template will be used for data segment merging with <segment name="FileTrailer">


<Segment name='FileTrailer'>
  <attributes>
    <attribute fieldName='recordType' length='2' />
    <attribute fieldName='institutionName' length='12' />
    <attribute fieldName='institutionID' length='8' />
    <attribute fieldName='filler' length='12' />
  </attributes>
</Segment>


Example of Generated Files

All of the example files below were generated by GenRocket.


Example merged nested Fixed file.

The following is an example of a merged Fixed file for the first fileHeader generated.


HHFILEID||2020-01-15  000000      
DT58915105  2971808990189c020401-ee58-11e7-8759-32f3b4cfdcfe2021-02-27  511000 22887       
DT26453620  8151292560139c020402-ee58-11e7-8791-2d31158ecac92021-06-10  521000 36419       
DT74251185  5750372101049c020403-ee58-11e7-a43d-452e38f253df2021-02-25  531000 89945       
DT96446123  1271129203009c020404-ee58-11e7-a4c2-a1cbe8b9e27e2021-11-12  541000 34513       
DT57987204  6495833593529c020405-ee58-11e7-a8a8-9c534bdd8ad62021-02-01  551000 52712       
TTGenRocket   GNRCKT  000000      


Example Segment Files

The following are three example segmented data files used to generate the merged nested Fixed files. These files are automatically created when the data is generated and stored within a "segment" subdirectory within the user's output path.


 


FileHeaderSegment.xml 

This file will contain one segment having one data element containing the fileHeader attributes, a loopCount equal to one, and no parentId since the fileHeader is the root Domain and does not have a parent Domain.


<segments>
  <segment id="1" setId="1">
    <attribute name="recordType"><![CDATA[HH]]></attribute>
    <attribute name="fileId"><![CDATA[FILEID]]></attribute>
    <attribute name="fileIdSeparator"><![CDATA[||]]></attribute>
    <attribute name="fileIdValue"><![CDATA[2020-01-15]]></attribute>
    <attribute name="filler"><![CDATA[000000]]></attribute>
  </segment>
</segments>


TransactionRecordSegment.xml

This file will contain ten segments, each having seven data elements containing the userRecord attributes, a loopCount equal to five, and a parentId given each set of users referential integrity to a given fileHeader defined within FileHeaderSegment.xml.


<segments>
  <segment id="1" setId="1">
    <attribute name="recordType"><![CDATA[DT]]></attribute>
    <attribute name="customerNumber"><![CDATA[58915105]]></attribute>
    <attribute name="customerAccountNumber"><![CDATA[297180899018]]></attribute>
    <attribute name="transactionId"><![CDATA[9c020401-ee58-11e7-8759-32f3b4cfdcfe]]></attribute>
    <attribute name="transDate"><![CDATA[2021-02-27]]></attribute>
    <attribute name="cardNumFirst6"><![CDATA[511000]]></attribute>
    <attribute name="totalTransAmt"><![CDATA[22887]]></attribute>
    <attribute name="fileHeader"><![CDATA[1]]></attribute>
  </segment>
  <segment id="2" setId="1">
    <attribute name="recordType"><![CDATA[DT]]></attribute>
    <attribute name="customerNumber"><![CDATA[26453620]]></attribute>
    <attribute name="customerAccountNumber"><![CDATA[815129256013]]></attribute>
    <attribute name="transactionId"><![CDATA[9c020402-ee58-11e7-8791-2d31158ecac9]]></attribute>
    <attribute name="transDate"><![CDATA[2021-06-10]]></attribute>
    <attribute name="cardNumFirst6"><![CDATA[521000]]></attribute>
    <attribute name="totalTransAmt"><![CDATA[36419]]></attribute>
    <attribute name="fileHeader"><![CDATA[1]]></attribute>
  </segment>
  <segment id="3" setId="1">
    <attribute name="recordType"><![CDATA[DT]]></attribute>
    <attribute name="customerNumber"><![CDATA[74251185]]></attribute>
    <attribute name="customerAccountNumber"><![CDATA[575037210104]]></attribute>
    <attribute name="transactionId"><![CDATA[9c020403-ee58-11e7-a43d-452e38f253df]]></attribute>
    <attribute name="transDate"><![CDATA[2021-02-25]]></attribute>
    <attribute name="cardNumFirst6"><![CDATA[531000]]></attribute>
    <attribute name="totalTransAmt"><![CDATA[89945]]></attribute>
    <attribute name="fileHeader"><![CDATA[1]]></attribute>
  </segment>
  <segment id="4" setId="1">
    <attribute name="recordType"><![CDATA[DT]]></attribute>
    <attribute name="customerNumber"><![CDATA[96446123]]></attribute>
    <attribute name="customerAccountNumber"><![CDATA[127112920300]]></attribute>
    <attribute name="transactionId"><![CDATA[9c020404-ee58-11e7-a4c2-a1cbe8b9e27e]]></attribute>
    <attribute name="transDate"><![CDATA[2021-11-12]]></attribute>
    <attribute name="cardNumFirst6"><![CDATA[541000]]></attribute>
    <attribute name="totalTransAmt"><![CDATA[34513]]></attribute>
    <attribute name="fileHeader"><![CDATA[1]]></attribute>
  </segment>
  <segment id="5" setId="1">
    <attribute name="recordType"><![CDATA[DT]]></attribute>
    <attribute name="customerNumber"><![CDATA[57987204]]></attribute>
    <attribute name="customerAccountNumber"><![CDATA[649583359352]]></attribute>
    <attribute name="transactionId"><![CDATA[9c020405-ee58-11e7-a8a8-9c534bdd8ad6]]></attribute>
    <attribute name="transDate"><![CDATA[2021-02-01]]></attribute>
    <attribute name="cardNumFirst6"><![CDATA[551000]]></attribute>
    <attribute name="totalTransAmt"><![CDATA[52712]]></attribute>
    <attribute name="fileHeader"><![CDATA[1]]></attribute>
  </segment>
</segments>


FileTrailerSegment.xml

This file will contain one segment having one data element containing fileTrailer attributes, a loopCount equal to one, and a parentId given each fileHeader referential integrity to a given fileHeader defined within FileHeaderSegment.xml.


<segments>
  <segment id="1" setId="1">
    <attribute name="recordType"><![CDATA[TT]]></attribute>
    <attribute name="institutionName"><![CDATA[GenRocket]]></attribute>
    <attribute name="institutionID"><![CDATA[GNRCKT]]></attribute>
    <attribute name="filler"><![CDATA[000000]]></attribute>
    <attribute name="fileTrailer"><![CDATA[1]]></attribute>
  </segment>
</segments>