Question

FTP CSV file to AS400

Asked by: luftmensch777

I 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

  • Good-Info.bmp
    • 1.3 MB

    This is what it should look like

    This is what it should look like
  • Bad-Info.bmp
    • 2.7 MB

    This is what it looks like when I use the txt and csv files

    This is what it looks like when I use the txt and csv files

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2008-12-02 at 07:07:31ID23949837
Tags

ftp

Topics

Bourne Shell (sh)

,

Programming for iSeries / AS400

,

Visual Basic Programming

Participating Experts
4
Points
500
Comments
9

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

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.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

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.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

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.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. as400
    I want to install SMTP MTA on NT so that AS400 terminals can receive mail from Notes. Can this be possible without having an internet/intranet in place? How?
  2. AS400e
    What steps would i have to go through to place an IBM AS400e model 9405-170 on to a Windows NT 4.0 ethernet network. The above box will be used to host a web site
  3. as400?
    I am applying to a job and inthe application they ask about experiance with as400. What exactly is as400 and what does it do or how does it work? Also what types of businesses use as400 daily? Thank you.
  4. Read a file on AS400
    Hello, You'll have to excuse my ignorance, but I've never worked with an AS400 before. I would like to use a ASP.NET program to read a csv file located on an AS400 machine. Any clue on how to do that? How to get a connection out to it? What com object I should use? Examp...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

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.

Join the Community

Answers

 

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

 

by: SRigneyPosted on 2008-12-02 at 07:45:08ID: 23077854

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.

 

by: daveslaterPosted on 2008-12-02 at 08:14:22ID: 23078220

if it was binary Would  the alpha would be un-readable?

 

by: daveslaterPosted on 2008-12-02 at 08:17:01ID: 23078257

if the AS/400 database numerics are defined as packe fields (used dspffd on the 400) then you must use client access transfer, or ADODB or ODBC as the values need to be converted.

 

by: murphey2Posted on 2008-12-02 at 09:52:32ID: 23079110

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

 

by: luftmensch777Posted on 2008-12-02 at 13:03:47ID: 23080776

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

 

by: murphey2Posted on 2008-12-02 at 14:18:02ID: 23081455

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

 

by: tliottaPosted on 2008-12-02 at 15:13:00ID: 23081857

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

 

by: murphey2Posted on 2008-12-02 at 15:46:41ID: 23082067

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




20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...