In this article we will look into skipping the blank line at the end of output file using etext template.
If you are new to etext template, please check the previous articles on it.
By default the etext template generates a blank line at the end of output file if you have noticed it or not.
In most of the cases you will not face an issue as the blank line won’t be visible and most of the third-party vendors ignore any blank lines.
However, you could face an issue with banks/some third-party vendors as they expect the file to be without blank lines at the end.
We will look at a solution on how to get that done using etext template.
Table of Contents
Logic to skip blank line at end of file
Newline character gets added after each line due to the new line character that will be mentioned at the starting of the etext template.
Now, we will have to make this new record character blank and add the new line character explicitly at the end of each record and skip it for the last record (we will create a sequence to check for the last line). That’s the approach that we are going to follow.
First we will make the new line character as blank in the template section.
Next, we will create a sequence to reset at the root level which is DATA_DS. We will use this sequence to count the number of rows in XML file and skip the explicit newline character while writing the last line to the output file.
Once the sequence is set, we need to store the row count in a variable using the expression
But the caveat is like once we use this as part of an attribute it will also print the value of that count on the output file. To avoid this, we will write an if condition and just add the attribute but not print anything on the output file. The final condition will be like:
If AddToVar(‘G_1_COUNT’, COUNT(G_1)) > 0 then ‘’
Once the variable is initialized, we will explicitly add the chr(13) at the end of each record to get the new line on the output file.
And for the final record we can use the syntax as:
If SEQUENCE_NUMBER(Record_Count)=GetVar(‘G_1_COUNT’) THEN ‘’ ELSE Chr(13)
Here we are checking if the sequence number is equal to the total count of rows on G_1 and if yes, we aren’t sending the new line character to the ouput..
eText template with logic:
Sample XML File:
Sample Output File without blank at the end:
Download Template, XML, and Output:
eText Template – Download Now
XML File – Download Now
Output File – Download Now
Top 10 Popular Posts from our Knowledgebase
- DataFusing FREE Cloud based SQL Developer like tool for Oracle Cloud
- Core HR Entity Relationship Diagram (ERD) for HCM Cloud
- Most Frequently used Document IDs from Oracle Support
- FREE Oracle Training & Accreditation with Oracle Learning Explorer
- How HDL Transformation Formula works with ElementEntry Sample
- FREE Oracle Fusion Demo Instance (VISION) Access
- Top 10 FREE useful tools for Fusion Consultants
- Learning Fusion HCM Technical Skillset
- Sample HCM Data Loader (HDL) files for all Business Objects
- Most frequently used Tables list in Fusion HCM