DEV Community

Cover image for Your free IBM i lab in 30 minutes: PUB400 + VS Code + Code for IBM i
Rainierio.dev
Rainierio.dev

Posted on Originally published at rainierio.dev

Your free IBM i lab in 30 minutes: PUB400 + VS Code + Code for IBM i

You do not need to buy hardware to learn IBM i. PUB400 gives you a free account on a real system, and VS Code with the Code for IBM i extension gives you a modern editor. This takes about 30 minutes, mostly waiting for your account.

Rules of PUB400 first

PUB400 is run by volunteers, so respect its terms:

  • Free profile with about 250 MB of storage (verify current limit on the site).
  • No commercial use. Learning and personal projects only. Do not put employer or customer code or data on it.
  • One account per person.
  • Runs IBM i 7.5 as far as I know; check the site.
  • Do not store anything you cannot lose. There are no guarantees.
  1. Sign up: Get a PUB400 profile by email
  2. Install VS Code: Add the Code for IBM i extension
  3. Connect over SSH: Host pub400.com, your profile
  4. Create a library and source file: Your workspace on the system
  5. Write hello world: A short **FREE program
  6. Compile and run: CRTBNDRPG, then CALL

Step 1: Sign up

  1. Go to pub400.com and follow the sign-up link.
  2. Fill in the form with a real email address. The password arrives by email, so check spam.
  3. Your profile name will be uppercase, up to 10 characters.
  4. On first sign-on you will be asked to change the password.

Approval is not always instant. Verify the exact process on the site; it may change.

Step 2: Install VS Code and the extension

  1. Install VS Code from code.visualstudio.com.
  2. Open Extensions (Ctrl+Shift+X), search for Code for IBM i (by Halcyon / Liam Allan and contributors), and install it.
  3. Documentation lives at codefori.github.io/docs.

An "IBM i" icon appears in the left activity bar.

Step 3: Connect over SSH

Code for IBM i uses SSH to the IBM i. In the IBM i panel:

  1. Choose New Connection.
  2. Host: pub400.com. Port: 2222 (PUB400 uses a non-standard SSH port; verify on the site).
  3. Username: your profile. Password: yours.
  4. Connect.

If it works, you will see your connection and the panels for Object Browser, IFS Browser and Library List.

To check SSH outside VS Code:

ssh -p 2222 YOURUSER@pub400.com
Enter fullscreen mode Exit fullscreen mode

Step 4: Create a library and a source file

On the IBM i command line (Code for IBM i has a terminal, or use the 5250 session below):

CRTLIB LIB(MYLIB) TEXT('My learning library')
CRTSRCPF FILE(MYLIB/QRPGLESRC) RCDLEN(112) TEXT('RPG source')
ADDLIBLE LIB(MYLIB)
Enter fullscreen mode Exit fullscreen mode

On PUB400 you may not be allowed to create libraries with arbitrary names, and your home library may already exist. Use your own name-based library if CRTLIB is refused (verify).

Alternatively, work from the IFS (a Linux-like folder tree). /home/YOURUSER is yours, and Code for IBM i can edit source stream files there. For beginners I suggest the IFS; compiled programs still go in a library.

Step 5: Write hello world in **FREE

Create hello.pgm.rpgle in /home/YOURUSER/ (or a member HELLO in MYLIB/QRPGLESRC):

**FREE
ctl-opt dftactgrp(*no) actgrp(*new);

dcl-s who varchar(30) inz('IBM i');

dsply ('Hello from ' + who);
return;
Enter fullscreen mode Exit fullscreen mode

Step 6: Compile and run

In Code for IBM i, use the Compile action on the file (command palette: Run Action then choose a compile action). Or in a terminal, using CRTBNDRPG for a source member:

CRTBNDRPG PGM(MYLIB/HELLO) SRCFILE(MYLIB/QRPGLESRC) SRCMBR(HELLO)
CALL PGM(MYLIB/HELLO)
Enter fullscreen mode Exit fullscreen mode

For an IFS stream file, use CRTBNDRPG PGM(MYLIB/HELLO) SRCSTMF('/home/YOURUSER/hello.pgm.rpgle').

DSPLY writes to the job's message queue; in a 5250 session you see Hello from IBM i on screen. Press Enter to dismiss it.

5250 emulator option

You can use the traditional green screen as well. Two options:

  • A TN5250 client, such as tn5250j or the one in Access Client Solutions (IBM's free tool), pointed at pub400.com. The telnet port and TLS port are on the PUB400 site (verify).
  • PUB400's own web access, if listed on the site.

Learn at least the basics of 5250: WRKACTJOB, WRKSPLF, DSPJOBLOG. You will meet these in every real job. See the roadmap, stage 1.

Troubleshooting

  • Connection refused / timeout: check you used the SSH port from the PUB400 site, not 22. Corporate networks often block outgoing ports; try from home.
  • Login fails: profile names are uppercase; passwords are case-sensitive. Passwords expire; reset via the site if you are locked out.
  • CPF2105 Object not found: the library is not on your library list. Run ADDLIBLE MYLIB.
  • CPF9801 / not authorized: you tried to create or write something outside your own library. Use your own.
  • Compile fails with errors: open the joblog or the Code for IBM i error panel. A common cause is the first line; **FREE must start in column 1 with nothing before it.
  • Extension can't find tools: Code for IBM i needs some open source packages on the server (like git, bash); it normally offers to install them. If that fails, check the extension docs.
  • Source file record length: QRPGLESRC members compile fine at 112; if you copy long lines they truncate. Keep lines short.

Before you go deeper, the roadmap shows where this lab fits, and AS400 vs iSeries vs IBM i explains what you just signed on to. Once hello world compiles, read the library and job mental model, then write something real in your first free-format RPG program.

Try it on PUB400

Make these three small changes and recompile each time:

  1. Change the greeting and the variable.
  2. Add a loop that prints 1 to 5 using dsply.
  3. Introduce a deliberate typo and find the error in the compile output.

That cycle (edit, compile, fix, run) is the daily work. Do it ten times and you are no longer a beginner on tools.

Best resources

Next

Libraries, objects and jobs mental model

Related


Originally published on rainierio.dev. The full Learn IBM i track, with an Indonesian version, is at rainierio.dev/learn.

Top comments (0)