Link to home
Start Free TrialLog in
Avatar of Errol Farro
Errol FarroFlag for Aruba

asked on

Move Data from Excel Spreadsheet to DB2/400

Dear All,

What is the easiest way to move data from an Excel Spreadsheet to an AS400 Database? I get a file once a month that needs to be uploaded and processed on the AS400. Currently I'm converting the Excel file first to CSV, then upload it using Client Access Transfer to the AS400 but I need a more automated way of doing this.

Thanks,

Errol
ASKER CERTIFIED SOLUTION
Avatar of daveslater
daveslater
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
or
use ODBC and write a bit of VB to poulate the file

or
craete a transfer and use then shell the transfer on a schedue job witth-in windows.

therey are many ways - if you give a few more details we can give the most appropriate solution.

Dave
Dave is correct.  You can use the cwbtfxla to write a script to do the transfer.  If you'd prefer another way, you could simply save the CSV to the iSeries in either QDLS (shared folder) or in an NTFS file share on the iSeries (AS/400).  - Let me know if you need further details about that part.

Once the file has been saved to the iSeries (do this by simply selecting File Save As from Excel and pointing to your iSeries box - for example \\iseries\), you use the one of the following 2 command to convert the spreadsheet to a native DB2/400 file:

In the case of saving the file to a shared folder you use the CPYFRMPCD command (copy from pc document) - note the .xls file name must be only 8 characters plus the ".csv" - 12 characters total.)

In the case of saving the file to an NT share on the iSeries, just use the CPYFRMIMPF command (copy from Import File).  This is by far the easiest method and you're not restricted by the file name lengths, etc.  Here's what the command looks like:

CPYFRMIMPF FROMSTMF('\iSeries directory\test.csv')
           TOFILE(testlib/TESTF)
           RCDDLM(*ALL)

The only deal is that the file has to exist before either command is run, so you'd have to have a fixed file / csv format for it to work.  

Dave's method allows you to create files on the fly - without having to define them first.  If you know the format, and it's always the same, then the method I describe here works great.  The CSV file can then be processed at will and can be generated by other means.

Let me know if you need more info about what I described here.

Good luck.

- Bryant