Description
This article will show how GenRocket can be used to generate the NACHA file format. Multiple steps will need to be performed to create the NACHA file format and track the totals of batches. This includes the basic Project Setup (Domains, Attributes, Generators, Receivers, and Scenarios) for each record.
Additionally, an H2 Database and H2InsertReceiver are used in this example to track the required values and provide totals in the Batch Control Record. Calculations must also be performed to calculate and maintain the required values correctly. More details are provided later in this article.
In This Article
- Workflow Diagram
- How to Generate NACHA File Format
- Sample NACHA File Format Output
- Calculation Information for BatchControlRecord and FileControlRecord
Workflow Diagram
The following diagram can be used to see how a Project can be set up to generate any synthetic data feed, including the NACHA file format:
How to Generate NACHA File Format
- Step 1 - Create the Setup Domain for the H2 Database
- Step 2 - Create a Domain for each Record Type
- Step 3 - Configure Attributes for each Record Type Domain
- Step 4 - Set loopCount for each Domain
- Step 5 - Create a Scenario for each Record Domain
- Step 6 - Add the SegmentDataCreatorReceiver to each Record Domain
- Step 7 - Assign the H2InsertReceiver to the PPDEntryDetailRecord Domain
- Step 8 - Set Relationships between Domains
- Step 9 - Create a Merge Domain
- Step 10 - Create a Scenario for the Merge Domain
- Step 11 - Assign FixedFileSegmentMergeReceiver to the Merge Domain
- Step 12 - Create and Download the Configuration File
- Step 13 - Create a Scenario Chain Containing all Domain Scenarios
- Step 14 - Generate the NACHA File Format
- Sample NACHA File Format Output
- Calculation Information for BatchControlRecord and FileControlRecord
Step 1 - Create the Setup Domain for the H2 Database
For this example, an H2 Database is being used to keep track of the amounts. For each batch, one row is being maintained in the database that keeps track of the following:
- Entry count
- Entry count within the record
- Sum of credit records
- Sum of debit records
A Setup Domain and Scenario can be created to create the H2 database for tracking the above information automatically.
The SQLUpdateReceiver has been assigned to the Setup Domain and has the following configuration:
The following will create the table in the location that has been specified above for the resourceName Parameter:
Create Database
create table if not exists nacha_mapping ( id bigint NOT NULL AUTO_INCREMENT, file_id varchar NOT NULL, batch_id varchar NOT NULL, credit_amount DECIMAL(20, 2) NOT NULL, debit_amount DECIMAL(20, 2) NOT NULL, entry_hash bigint NOT NULL, entry_count bigint NOT NULL, PRIMARY KEY (id), CONSTRAINT keyIndex UNIQUE (file_id, batch_id) )
Step 2 - Create a Domain for each Record Type
To successfully generate data, a Domain will need to be created for each type of record. The Domain generates the data for each record type, which is then merged with the help of a Merge Domain.
To learn how to create and import Domains in the GenRocket web platform, please see How do I import my data model into GenRocket?.
Step 3 - Configure Attributes for each Record Type Domain
An Attribute will represent a field in the record. For example, the File Header Record contains 13 fields, and each field is represented as an Attribute within a FileHeaderRecord Domain.
Step 4 - Set loopCount for each Domain
The loopCount of the Domain determines the number of records. In this example, the loopCount would be set to the following:
- FileHeaderRecord - 1
- BatchHeaderRecord - 12 (12 batch records)
- PPDEntryDetailRecord - #{org.nacha.entryLoopCount}
- TELEntryDetailRecord - #{org.nacha.entryLoopCount}
- WWBEntryDetail Record - #{org.nacha.entryLoopCount}
- CCDEntryDetailRecord - #{org.nacha.entryLoopCount}
- CTXEntryDetailRecord - #{org.nacha.entryLoopCount}
- CCDAddendaRecord - 1
- CTXAddendaRecord - 1
- BatchControlRecord - 1
- FileControlRecord - 1
Below is the loopCount for the BatchHeaderRecord Domain, which determines the number of batches within the generated NACHA file.
Step 5 - Create a Scenario for each Record Domain
A Scenario will need to be created for each of the following Record Domains. To learn more about creating Scenarios, please see:
Step 6 - Add the SegmentDataCreatorReceiver to each Record Domain
The SegmentDataCreatorReceiver will need to be added to each Record Domain. This Receiver generates a segment for each Domain, which will be merged into an output file by a Merge Domain.
Step 7 - Assign the H2InsertReceiver to the PPDEntryDetailRecord Domain
An H2InsertReceiver is being used to insert the values into the H2 Database. For this example, it will need to be added to the PPDEntryDetailRecord Scenario.
Step 8 - Set Relationships between Domains
Parent/Child Relationships will need to be set between the created Domains. This can be done through the Relationship Tab if manually created or through the Domain Wizard when Domains are imported. To learn more, please see one of the following pages:
- How do I set a Parent/Child Relationships between Domains?
- How do I use the Domain Referencing Wizard?
File Header Record Domain
Children: BatchHeaderRecord Domain and FileControlRecord Domain
BatchHeaderRecord Domain
Referential Parent: FileHeaderRecord Domain
Children: PPDEntryDetailRecord, CCDEntryDetailRecord, TELEntryDetailRecord, WEBEntryDetailRecord, CTXEntryDetailRecord, and BatchControlRecord Domains.
CCDEntryDetailRecord Domain
Referential Parent: BatchHeaderRecord Domain
Child: CCDAddendaRecord Domain
CTXEntryDetailRecord Domain
Referential Parent: BatchHeaderRecord Domain
Child: CTXAddendaRecord Domain
Step 9 - Create a Merge Domain
The Merge Domain merges the created segments for each Domain to generate the NACHA file format. The Domain will need to be created with no Attributes. The id Attribute will be created automatically.
Step 10 - Create a Scenario for the Merge Domain
Next, a Scenario will need to be created for the Merge Domain.
Step 11 - Assign FixedFileSegmentMergeReceiver to the Merge Domain
The FixedFileSegmentMergeRecever will be used to merge the segments created by each Domain. It will need to be assigned to the Merge Domain.
The configuration is shown below:
Step 12 - Create and Download the Configuration File
The Configuration File (Config.xml) defines how the segments will be merged. This file is used by the FixedFileSegmentMergeReceiver and will need to be created within the GenRocket web platform. It can be created within the Management Pane in the Project Dashboard by selecting the Configuration Management Tab.
Select the Fixed Format option and click on the Select button.
Configure the following:
Name = config
Config File Name = Config.xml
Output File Name Format = This determines how the output files will be named (e.g., Order-Timestamp-Counter.txt). Order will be concatenated with the current date, hours, and seconds and a counter with ".txt" as the file type.
Next, add definitions to the configuration file. Select a Domain and then select the corresponding Segment.
Complete this step for each Record Type Domain. Click the Add button to add a line for each new Domain/Segment. Note: This does not need to be done for the Setup and Merge Domains.
The completed configuration will appear as shown below. Click Save once finished.
Arrange the Segments based on their parent/child relationships and click Done.
The Config.xml file will need to be downloaded to the user's local machine by clicking on the Cloud icon.
Once downloaded, the user will need to place it within a Config folder within their output directory.
Step 13 - Create a Scenario Chain Containing all Domain Scenarios
A Scenario Chain will need to be created to automatically run all added Scenarios in the displayed order.
Step 14 - Generate the NACHA File Format
After downloading the Config.xml file and the Scenario Chain, the user will need to open a Command Prompt or Terminal window. The user will need to run the Scenario Chain through GenRocket Runtime at the command line using the following command:
genrocket -r <ScenarioChainName.grs>
Sample NACHA File Format Output
Calculation Information for BatchControlRecord and FileControlRecord
BatchControlRecord Scenario Domain Queries
The QueryEachLoopGen is used for the following BatchControlRecord Scenario Domain Attributes to obtain calculation data from the H2 database:
entryOrAddendaCount Attribute
entryHash Attribute
totalDebitEntryDollarAmount Attribute
totalCreditEntryDollarAmount Attribute
FileControlRecord Scenario Domain Queries
The QueryEachLoopGen is used for the following FileControlRecord Scenario Domain Attributes to obtain calculation data from the H2 database:
entryOrAddendaCount Attribute
entryHash Attribute
totalDebitEntryDollarAmount Attribute
totalCreditEntryDollarAmount Attribute
FileControlRecord Scenario Domain - Batch Count Attribute
References the loopCount value for the BatchHeaderRecord Domain (e.g., 12 for this example).
FileControlRecord Scenario Domain - Block Count Attribute
The Block Count is the sum of all records (total lines), including the file header and footer, divided by 10 and rounded to the next highest integer, right-justified and zero-filled.
The blockCount Attribute within the FileControlRecord Scenario Domain will need to have three linked Generators:
QueryEachLoop - Queries the H2 database for the entry_count.
CalcGen - Performs the calculation for the Block Count value.
PadGen - Used to pad and right- justify the block count.