Solved

Flat Files recognizing Numeric vs Char fields

Posted on 2003-11-03
11
276 Views
Last Modified: 2010-05-01
I am creating an ASCII file, which will be transmitted to an external source via FTP.  In the file, if field lengths are shorter then what the file layout requires, then I need to pad either with trailing spaces or leading zeros depending on the data type.

My question is this, when I have a numeric field, the leading zeros are removed, and in many cases I need them to exist.  So, if I use a string field and force a right justify by padding leading zeros, will there be anyway to tell when the data is extracted by the external source that it was not a numeric field?  
0
Comment
Question by:Able22
  • 3
  • 2
  • 2
  • +3
11 Comments
 
LVL 3

Expert Comment

by:aflat362
Comment Utility
No
0
 

Author Comment

by:Able22
Comment Utility
So this method will work?
0
 
LVL 29

Expert Comment

by:leonstryker
Comment Utility
It really depends on that is used to extract the data.  Some applications make the assessment as they import, others can use a format file, while still others make a guess based on the data in the field.  Do you know what the files are going to be used for and how?

Leon
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
"My question is this, when I have a numeric field, the leading zeros are removed, and in many cases I need them to exist..."
But if you need them to exist, it is not a numeric field....
0
 

Author Comment

by:Able22
Comment Utility
I understand your point Richie_Simonetti, however, here is an example:  The ASCII file layout that is required by the external vendor has a NUMERIC field, Cust_ID.  CUST_ID has a required length of 10.   However, my company's Cust_ID field is only a length of 6.  It is specified in the specs that if my field lengths don't match the ones in the given file layout, then I have to pad accordingly.  Therefore, I'd have to add 4 extra zeros to the beginning of my CUST_ID value to make it equal a length of 110.   So, I was wondering if I changed the CUST_ID to a string and added the zeros and printed it to the file, when the extract the data, will I cause a data-type mismatch.............
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:Able22
Comment Utility
oops,  in the above comment, 10, not 110....
0
 
LVL 29

Expert Comment

by:leonstryker
Comment Utility
The answer is: "Not likely, but posible".  Most software pakages or application will convert it to numeric using some form of "type casting".

Leon
0
 
LVL 15

Accepted Solution

by:
SRigney earned 75 total points
Comment Utility
The external application gets everything as a string.
By you meeting their format they probably already have an application set up to parse the field correctly and put it into their database.

They don't know or care if you store your data as a string or a number, as long as it's in the file in the format that they want.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
Could you replace those leading 0 by spaces?
I am asking you this 'cause i do a regular job on this kind of things (convert excel files to fixed length ascci files for SAP).
0
 
LVL 9

Expert Comment

by:Dang123
Comment Utility
Try writing your numbers using the format command

     Format(intCustID, "0000000000")


This will allow you to output your numbers with zero padding easily. The data will be pulled into the reading program as it expects it. I also work with COBOL, and there a field that contains any non-numeric characters (except for one period) is considered a character string. this method would definitely work to pass a number. The only way to be sure though is to send a test file to the program that needs to read your file.
0
 
LVL 3

Expert Comment

by:aflat362
Comment Utility
In a test enviornment - print it numerically, print it as a string.  Compare the 2 output files.  If you can tell no difference - the application which reads it can't either.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now