Monday, August 27, 2018

Auto reply AS/400 messages

It is possible to configure the machine to work with automatic reply for messages. What you have to do is to add reply entry to the system.

The ADDRPYLE command will add an automatic response to a system message.
The WRKRPYLE command will display all automatic responses set up on your system.

Retrieve IFS folder content

At present if required to obtain a list of files in IFS folder RTVDIRINF command will provide an output as two files in QUSRSYS library. One file contains the folder details and other contains the files. The disadvantage of RTVDIRINF command is the user must have *ALLOBJ special authority to invoke it. Therefore it is not practical to use it in programs.

Therefore to list files in IFS folder, the following method can be adopted.




OVRDBF FILE(STDOUT) TOFILE(QTEMP/DIRLIST) OVRSCOPE(*CALLLVL) LVLCHK(*NO)

CD DIR('/<to required folder>')

QSH CMD('ls *.*')

You need to write a small CLLE code for this. 

Monday, February 27, 2012

Configure email in AS/400

First of all, you have to understand that the AS/400 supported E-mail long before the Internet came around, and SMTP became popular. It used an e-mail system called SNADS that IBM developed specifically for their business machines.

That's why commands like SNDDST seem so complicated. They weren't designed for today's Internet e-mail, they were designed for SNADS and later adapted for SMTP.

Before explaining how to set up e-mail, I'm making the following assumptions:

  • Your system is already configured for TCP/IP.
  • You already have DNS lookups working from your iSeries to Internet domains as well as local domains.
  • You have an Internet Service Provider (ISP) who has given you an outgoing mail server to relay your e-mail. Or you have an internal SMTP server that your company uses for e-mail.


The first thing you'll want to do is configure your iSeries SMTP server. This is used when sending mail as well as receiving it. Type the following command:

CHGSMTPA AUTOSTART(*YES) MAILROUTER('your.isp.smtp.server') FIREWALL(*YES) ALWRLY(*BOTH)


  • AUTOSTART(*YES) tells the system you want this server to start automatically when TCP/IP is started.
  • the MAILROUTER keyword tells where the iSeries should send outgoing e-mail to. This'll be the internal SMTP server that your company uses for mail, or the one that your ISP provided you. (192.168.10.200)
  • The FIREWALL(*YES) keyword tells the iSeries to always send mail though the MAILROUTER, never try to deliver it directly.
  • ALWRLY(*BOTH) is used to configure who is allowed to send mail though this server. Do not set this to *ALL or spammers will be able to use your machine to send spam without your consent. With *BOTH, you'll have to use the ADDSMTPLE command to control which computers can use your SMTP server (more later).


You'll also want to make sure that e-mail messages are not split up, even if they're big. This has always seemed strange to me, but it's controlled by the CHGPOPA (Change POP3 Attributes) command.

CHGPOPA MSGSPLIT(*NOMAX)

As I mentioned above, you'll need to configure which IP addresses are allowed to send mail through your iSeries system. In this example, all the computers who can send mail have IP addresses that begin with 192.168.5, so I run the following command:

ADDSMTPLE TYPE(*ACCEPT) INTNETADR('192.168.5.0') SUBNETMASK('255.255.255.0')

You can run this command more than once if you need to add more than one subnet.

The next thing you'll need to do is set up a gateway that allows SNADS tools like SNDDST to send Internet e-mail. To do that, type the following commands:

ADDDIRE USRID(INTERNET GATEWAY) USRD(‘Internet SMTP gateway’) SYSNAME(INTERNET) PREFADR(NETUSRID *IBM ATCONTXT)


CHGDSTA SMTPRTE(INTERNET GATEWAY)

After running this command, the SNDDST command will use the gateway so that e-mail will be sent to the local SMTP server.


Now that SMTP is configured on your system, so go ahead and start the SMTP server

STRTCPSVR SERVER(*SMTP)

(If it was already running, use ENDTCPSVR to end it. Then use WRKACTJOB SBS(QSYSWRK) to make sure that all of the QTSMTPxxxx jobs end, then use STRTCPSVR to start it up again.)

Each user who needs to send e-mail using SNDDST will need to have a directory entry and SMTP e-mail address configured on the iSeries.

ADDDIRE USRID(BANKDUDE S10262BA) USRD('Bank Dude profile')

WRKNAMSMTP TBLTYPE(*SYSTEM)

  1. Use option 1=Add
  2. Type the same name/address that you used on the ADDDIRE command
  3. Enter the SMTP e-mail address for this user.


Once all of that is done, it should be easy to send off a test e-mail with SNDDST. For example:

SNDDST TYPE(*LMSG) TOINTNET(('bankdude@example.com')) DSTD('Put E-mail Subject Here') LONGMSG('Hi Dude. This is an E-mail message sent from my iSeries system.')

You should also be able to configure tools like Outlook, Firebird, Eudora, etc to send mail using your iSeries SMTP server. For user-written e-mail, that's nicer than using SNDDST. Though, SNDDST is still nice for automatic messages generated by programs.

There are also lots of free e-mail tools on the Web that can use this SMTP server. They provide many more capabilities than SNDDST does. But, alas, this message is getting too long, so I'll stop there.


Wednesday, October 24, 2007

Increase the connection time of FTP connection

By default, FTP automatically disconnects after five minutes of inactivity. The following command increases the time. Once you made a FTP connection type the following command.

Quote time 1000 (This increases idle time to 1000 seconds)

Likewise specify required time.

Thursday, October 18, 2007

Define data areas in ILE RPG programs

As a good programming practice, define data areas in the D spec. First you have to define a data structure or a variable which has equal length to the data area.



Define the data area in D spec



Use the data area in free format

Cl_run = *blanks;
In *lock *dtaara;
Cl_run = Lastrun;

Tuesday, September 4, 2007

Defining a key list in a free format program

Here is an example of defining a key list in a free format program.

The AB20LF logical file created with ABCUS and ABCLC as keys.



Define the file in F spec as follows.



Define the key list as a data structure in D spec.




The free format code as follows

Wednesday, August 1, 2007

Workaround solution for MOVE operation

MOVE operation can be used to convert integer values to character values. But in ILE free format, we have to use %CHAR built in function for that.

Let us define two variables
A char 10
B dec 10 0 Inz(2510)

MOVE B A

The value in A is now '0000002510'

A = %char(B)

The value in A is now ' 2510'

Main difference is leading zeros. Sometimes it is necessary to have leading zeros in variables. Therefore the below mentioned code can be used.

Evalr a = %editc(b:'4':*ASTFILL)
a = %xlate('*':'0':a)

%EDITC built in function converts numeric field into character field and edit the value according to the edit code. *ASTFILL fills the leading spaces with '*'. %XLATE function translate '*' to '0'.