Program for AS/400

Hello Experts.

I need to develop a program for uploading files from a Windows server to a AS/400 machine. I need to check the integrity of the file once it has been uploaded to the AS/400, to see it has not changed. I have to give a proposal of what to use in the AS400 side, for example a FTP server, a custom program, a web service, or whatever I think is the best solution. In the windows end I know everything I need but I have no idea what to use or develop in the AS400 side. Any advice will be welcome, I know well how to program in C or java or can have another person to program what is needed. I would use an already done FTP server but not sure if it comes with AS/400 nor how to install it. As you can guess I almost know nothing about AS/400.

Who is Participating?
Gary PattersonConnect With a Mentor VP Technology / Senior Consultant Commented:
What kind of file are you talking about uploading?  Are you uploading a PC stream file to the AS/400 IFS (stream-file to stream-file)?  Are you uploading a MS SQL Server table to a similarly-formatted AS/400 DB2 table?  Are you uploading a PC CSV file to an AS/400 DB2 table?

Assuming that this is just a simple stream file t- stream file transfer, then FTP is fine.  FTP client and server support are built into the the AS/400 operating system in all modern releases, as Steve indicates.  You may need to configure your FTP server and start it if it has never been set up:

As far as verification goes, you have lots of options.

1) Generate MD5 checksums for the source and target files, and compare the checksums.  Lots of Windows or Java tools out there that will do this for you.  To make things easy on you, you can use the AS/400 NetServer to map a Windows-compatible share to the AS/400 IFS file, which will enable you to use Windows-based tools for the file compare task.


2) Zip the file before uploading it, and use the AS/400 Qshell JAR command to unzip it.  Zipping the file causes a CRC to be generated, and unzipping using JAR will fail if the file was altered in transit.  As an alternative, you could again use Netserver to map a Windows share and then just use whatever Windows too you used to zip the file to unzip it.  You can also install and use this freeware AS/400 ZIP/UNZIP utility:

You can run simple commands directly from an FTP session using the RCMD directive:


To run QSHELL commands, you have to wrap them in the QSH command:

> QUOTE RCMD QSH 'JAR xxxxxxxxx'

3) Use Netserver to map a drive to the AS/400, and use the Windows file comparison tool of your choice to compare the two files.

4) Use Netserver to map a drive to the AS/400, and use a Windows file transfer utility that performs verification to perform the transfer.

5) My favorite: Use SFTP (SSH File Transfer Protocol), not to be confused with FTPS (FTP over SSL) or any other protocol).  SFTP is widely used in ecommerce because it is secure, encrypted, and reliable (reliable in the technical sense that it verifies that what is transmitted matches what is received).  This will require a little configuration, but is well worth it, in my opinion:

- Gary Patterson

It has been years (15+) since I worked with an AS/400 and OS/400.  But here are a few generic possibilities:

You could use PKZip.  Zip the file on Windows, ftp to AS/400, then unzip.  I'm fairly sure that OS/400 does not come with PKZip, so you would need to get it.  PKZip has its own check for file integrity.

Using an more secure FTP, either sftp or FTPS.  I don't know if they are avaibale for OS/400.

Using MD5 check sum.  And again, I don't know if OS/400 come with the MD5 check sum program by default.
Is the 400 local?  is the file huge?

if the 400 is local then you may be able to skip any security issues.
if the transfer is fast enough you could PUT the file then GET the same file back.   then compare the files on the windows side.

i have not seen a 400 in the past 15 years that did not have FTP installed.

Steve Bowdoin
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

You might also have a SQL table defined to receive the data on the AS/400. Then, ODBC/JDBC becomes reasonable. Many rules can be configured in DB2 to provide much of the validation. Or a stored procedure might be used to perform validation before applying uploaded rows to a target table.

As Gary points out, the type of file will make a lot of difference. A streamfile (e.g., non-database, as in an image file or even a text file) can be handled differently than a database transfer. Also, the AS/400 operating system version/release might be important unless you're dealing with a reasonably current release. (There are old ones out there, just as there are the rare Windows 98 PCs still at some business sites.)

arturosmAuthor Commented:
Thanks Experts for your comments so far.

I will be uploading files of about 2 MB in size each, and there will be about 10-15 files per day. The files are ASCII text files, the idea is to put them in the AS/400 so that other already existing programs or jobs (I don´t know what they have running there) process  them. I just need to asure they get to the AS/400 without change. The windows machine and the AS/400 are in the same building and LAN. My project is mainly a windows programming task but have to upload the output files to the AS/400 after the end of the windows processing. I don´t know yet the features of the 400 machine (SO version, utility software installed, hardware resources, etc).

I will wait for your comments now that you have this info.

Thank you very much.
Well, before we can make any comments you really need to find out what capabilities the AS/400 has.

We can't help you knowing only 1/2 of the picture.

So you really need to find out what level of OS/400 is installed.  If it has PKZip or not, but as Gary has stated (and I forgot) you could use the JAR command to unzip a file.  Although most people don't know it Java application files (JAR, RAR, WAR, EAR, and so on) are nothing but zip files with file suffixes other than ".zip".
Gary PattersonVP Technology / Senior Consultant Commented:
Assuming that you want to upload these ASCII stream files to the AS/400's IFS (as opposed to importing them into a DB2 table), then based on your volumes and validation requirements, then I suggest using the SSH File Transfer Protocol (SFTP) approach that I outlined above, since that will resolve both your needs for a file transfer mechanism and your validation needs, since SFTP is a reliable protocol.

- Gary Patterson
stevebowdoinConnect With a Mentor OwnerCommented:
My fellow experts are all correct.  Here is a simple solution. Bandwidth is not a problem.  Transfer speed is not a problem.

From the 400 command line execute these commands, one at a time.  CRTPF creates physical files.  The RCDLEN is the maximum record length you think you will need.  The SIZE is the initial number of records you may need.  Go ahead and guess big on the SIZE but don’t do *NOMAX


From the windows side create files named like “FILE01”.  Don’t use an extension.  Put them in a directory off the root named “pcsourcedir”.  Create a directory off the root called “pctargetdir”.

Put this command in a bat file named FTPBAT.BAT:
ftp -s:ftp.scr  where is the 400s IP address

put this into a file named FTP.SCR:
cd upload
lcd /pcsourcedir
mput *.*
lcd /pctargetdir
mget *.*

Execute the FTPBAT.BAT.
This will…
1      sign you on to the FTP server
2      prohibit prompting
3      change your current directory on the 400 to the UPLOAD libarary
4      change your current directory on the pc to pcsourcedir
5      put all file in pcsourcedir to UPLOAD
6      change your current directory on the pc to pctargetdir
7      get all files from UPLOAD
8      end ftp session

You can then run whatever windows program you need to insure that /pcsourcedir/file01 and /pctargetdir/file01 are the same.  Then check the rest of your files.

Steve Bowdoin
arturosmAuthor Commented:
Thank you.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.