I would guess that you are ftping in binary and it's converting the numbers to number representations, you could try forcing it to ftp in ascii.
Main Topics
Browse All TopicsI am trying to upload some data into a file on my AS400 through the following command
RetVal = Shell("FTP -s:" & """" & ThisWorkbook.Path & "\" & "ftpPUTMPS.txt" & """", vbNormalFocus)
The ftpPUTMPS.txt file contains the login info and the Put command with the "from" and "destination" file names. When I use a text file for the "from" file the alphanumeric fields go just fine but the numeric and currency fields come in as "++++++." So then I thought I would use a CSV file so that I could format the numeric and currency fields according to how they will need to formatted in the destination file. But when I do that I get a bunch of commas everywhere that through everything off. Please let me know what I am missing.
Thanks,
jordan
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi luftmensch777,
An other option is to FTP a CSV file to a temporary file in the AS/400 and run the "Copy From Import File (CPYFRMIMPF)" command.
The only things you have to take care of is:
- The number and types of the fields in the CSF file must fit the AS/400 File layout.
- Define *ADD and not *REPLACE in this command (unless you intent to do so), otherwise the existing data will be removed
Regards,
Murph
First, thank you all for your quick responses. There were a lot of them but unfortunately I still dont have the answer I need. I will try to handle all of these responses one at a time.
1) Is it possible to get a text file to match the format for a numeric field?
2) I guess I dont know what you mean by ftp a copy of the database to my PC. I did use the get function to do this, but it doesnt really help other than that it did make me aware of something. When I pulled the data back into a text file I noticed that all the data is there, its just that it appears through a query as ++++
3) I started to look into rtopcb.exe and ADODB but those are completely new to me so its going to take me some time to figure those out. Is there somewhere that quickly explains how to upload a file to the AS400 using either of those options?
4) I am forcing ascii
5) I have no idea if the AS400 database numerics are defined as packe fields. Again, using client access transfer to ADODB would be fine if there is a quick way for to learn how to upload a single file to the AS400.
6) Id really rather not go the route of FTP
Thanks,
jordan
1) Is it possible to get a text file to match the format for a numeric field?
>> Yes as long as the field in the file is not packed or binary (**
2) I guess I don't know what you mean by ftp a copy of the database to my PC. I did use the get function to do this, but it doesn't really help other than that it did make me aware of something. When I pulled the data back into a text file I noticed that all the data is there, it's just that it appears through a query as ++++
>> That are the packed or Binary fields
3) I started to look into rtopcb.exe and ADODB but those are completely new to me so it's going to take me some time to figure those out. Is there somewhere that quickly explains how to upload a file to the AS400 using either of those options?
>> rtopcb is better because it will handle yor numeric fields as expected (if it's done well)
4) I am forcing ascii
>> No Never force ascii if you transfer fron the AS/400 filesystem to a PC.
>> The AS/400 knows how to translate
5) I have no idea if the AS400 database numerics are defined as packe fields. Again, using client access transfer to ADODB would be fine if there is a quick way for to learn how to upload a single file to the AS400.
>> transfer the file FROM the as/400 to the PC and use the definition file to upload (extention .FDF)
>> this will map the fields the right way
6) I'd really rather not go the route of FTP
>> You are right, rtopcb, is much saver to use...
>> An other option is the Client Access addin for Excel, (a rtopcb like solution) this allow you to upload directly from excel, but again, the format and columns have to match the layout of the as/400 file.
Pached and binary, are diferent way's to store numeric data in a field... a kind of 'compression'
Regards,
Murph
jordan:
FTP is "line oriented." It has no concept of 'database record formats.' It transfers strings of characters with essentially no knowledge of 'fields' or 'columns' that make up 'records.' A 'record' to FTP is usually just whatever string of characters that is found between record delimiters.
Trying to FTP into a DB2 externally-described database file requires having strings of characters that are (1) laid out to match the receiving record format and (2) either are already converted to the proper CCSID and transferred as BINARY, or are ASCII characters that would result in conversions to all the right characters and transferred as ASCII.
Regardless of which alternative is chosen for "(2)", the handling of record format positions that would match up with packed-decimal or other non-character type fields would be very tricky.
That's where a somewhat 'standard' file format such as .CSV comes in.
However, you don't transfer the .CSV file directly over the top of the DB2 file. Instead, you transfer the .CSV file into a simple directory on your AS/400 and then use it as the source for a DB2 import function. On your AS/400, the import function is most often the CPYFRMIMPF command.
The import takes the .CSV file and handles all of the mappings for field positions and data types.
As such, the sequence becomes (1) FTP the .CSV file to the AS/400, and (2) run CPYFRMIMPF on the AS/400.
Note that the format of the .CSV file makes a difference. You need to ensure proper CCSID settings, proper quoting where necessary, proper record separators, etc. Make sure that you generate a .CSV that can be converted to the record format of the eventual target database file. Lots of possible details, but _far_ easier than trying to construct a matching DB2 record format on a different platform.
Tom
Hi luftmensch777,
The most basic knowledge we forget to tell the standard way of the AS/400 to store data, is fixed field length and that is leading to also fixed record lenght.
so ther are 2 main options to upload data to the as/400 files.
1, comma seperated
2. fixed length.
for the first option you need a program (somewhere) that map it for you, this could be an AS?400 import function or rtopcb... but never FTP, because then you get comma's in data fields etc.
For the fixed length option you dont need a program but can directly upload to the file, as long as there are no packed or binary fields in the file. If the file contains packed or binary numeric data, you can't use FTP to upload directly to the file.
If you prefer to FTP the data, you definitly needs a workfile.
If you like to use a file with seperation characters, then you need some mapping and a tool to map it for you.
Regards,
Murph
Business Accounts
Answer for Membership
by: daveslaterPosted on 2008-12-02 at 07:39:24ID: 23077774
Hi
If you are using FTP the text file must match the format of the AS/400 database.
An easy way to do this is to FTP a copy of the database to your PC.
In VB you can them replicate the format in the text file and all should work OK.
You have 2 other options, use the Client access file transfer facility (rtopcb.exe) or in VB you can also use ADODB to populate the database using activex record sets.
Dave