RPG III/RPG400,
iSeries, IBM AS400, OS/400,
RPG IV/RPG-ILE
For all AS/400
RPG programmers
|
ILE-RPG AS400 free tutorials, utilities,
iSeries - IBM AS/400 - ILE RPG IV free tutorials, utilities, code,
and tips including an IBM ILE-RPG reference manual with sample code
plus Free Format, Op Codes, Modules, and Sub Procedures (Subprocedures)
and more.
RPG - AS/400 - Utilities, Code, Demos, ...
( click on Topic to view tutorial-code )
| Category |
Topic |
Subject |
| Description
|
| CLP - OS/400
|
CLP intro
|
CLP introductory tutorial
|
| CLP intro tutorial with code - COMMAND LANGUAGE (SYSTEM) programming
|
| code - full programs
|
RPG Sub Files
|
sample subfile program
|
| sample subfile program: ile-rpg, dspf, pf, lf, and a small data set
|
| Miscellaneous
|
QSECOFR notes 1994
|
notes taken while QSECOFR
|
| notes taken while QSECOFR on a network of 3 AS/400\'s on subjects including object authority, job logs, WRKSYSVAL, terminals, inactivity, outq\'s & printers, profiles, routing tables, etc. . .
|
| Miscellaneous
|
QSYS Commands List
|
QSYS (AS/400) Commands List
|
| All the AS/400 QSYS commands, with short descriptions, including PWRDWNSYS etc. which you may not have authority to see or use.
|
| Miscellaneous
|
RPG-ILE ref. code
|
RPG-ILE reference file for code
|
| Reference file for code syntax used seldom enough to be forgotten; array overlays, SORTA, date formats, tables, multi-occur-DS\'s, SDS, plus.
|
| tests & quizes
|
Certification
|
IBM sample RPG Cert. test
|
| IBM had/has an on-line sample sertifiication test for RPG (ILE +) sr. programmer analysts along with a general list of things an RPG - AS/400 programmer should know.
|
| tests & quizes
|
ILE-RPG; RPG-IV (4)
|
39 question quiz of RPG
|
| quiz offered in 2007 to co's and agencies for technical testing of their RPG programmer job applicants and etc.
|
| utility
|
Display File Format
|
Display Format of PF and all LFs
|
| it combines the information of several as400 file description comands and displays it all in a more compact, readable, manner.
|
| utility
|
LDA Local Data Area
|
LDA - Edit your Local Data Area
|
| a simple CLP and DSPF to edit your Local Data Area - you can expand or contract it for how much you need
|
| utility
|
object listing
|
object listing sorted by a date
|
| object listing sorted by last used date and restricted by object size and or a date range
|
| utility
|
printouts to files
|
copy multiple printouts to a file
|
| a CMD, CLP, and RPG for copying multiple printouts to a file with the option of having the printouts deleted (y/n) afterward
|
| utility
|
RPG ILE indented
|
indented source code listing
|
| source code utility to print indented columnized RPG (III and ILE) source
|
As almost everywhere, it is hard to find
free RPG utilities, code, tips, and tutorials.
Most everything comes with a price tag - and RPG info.
is more expensive than most others.
I have found a few free sources and have shared the best
of them here.
A reality in the computer business is that things have been changing
faster than in almost any other market -- and it is unfortunate that when
IBM realized they would have to make the AS/400 communicate
easily with the internet (or continue to loose business at an even more
alarming rate) their infamous response to all the RPG programmers out
there was a double page ad suggesting that
RPG programmers could get jobs flipping burgers.
The AS/400 was then and now being sold as "a Java Machine".
|
By, or soon after, the year 2000, jobs for RPG programmers had
virtually disappeared in the US. (ex: about 2 RPG jobs vs. 80 to
100 java jobs here in south Florida)
For those still working in RPG it becomes ever more dificult to
find information. What I have and can find, I offer to you freely
here (see links below). If you can learn Java on the AS/400 that
should help. If you have, and have any experiences and or Java
code to share, please share it here also.
Alternately, get a domain name, and pay the $10 a month for a web
site you can build and experiment with yourself. ( see my hints on
domain names and on web site design. Also,
www.web-page-hosting-review.com and www.web-hosting-reviews.org and
www.100best-domain-names.com are good sources for comparisons and
recomendations. )
(All links will open in their own window)
|
Link
|
Description
|
RPG - iSeries AS/400 Links
|
|
www.theRPGsource.com
|
free examples of rpg-free (format) source code |
|
www.as400pro.com/servlet/sql.viewCats?Type=T
|
AS/400 PRO web site lots of free information on all areas of as400 and os400 programming: CLP, ile-RPG, Visual-Age, java, operations, Apache, PHP, and more |
|
lab400.com/RI_pages.asp?idno=4139
|
free AS400 info on subProcedures, service programs, web design, WebFacing without WebSphere, html, javaScript, and more.
You have to sign up with them first but ... |
|
www.iseriestools.com/
|
Free AS/400 utiities |
|
www.code400.com
|
Code samples and forum for the AS400, Iseries, I5 whatever they call it today. |
|
64.233.179.104/search?q=cache: sxbRnWQaHsIJ:as400bks.rochester.ibm.com/ html/as400/v4r5/ic2924/info/ java/rzaid/java400.pdf&hl=en
|
intro to AS/400 JAVA including info on installing the java licensed pgm in case it is not already; qshell; mapping a network drive; creating a directory; compiling; & other resources |
|
www.itjungle.com/fhg/fhg021104-story01.html
|
a good description and discussion of activation groups (*new, *caller, named). |
|
groups.google.com/groups? hl=en& group=comp.sys.ibm.as400.misc
|
Google has an extensive Q&A - over 116,000 (searchable) AS/400 postings. |
|
www.texas400.com/tutas400toc.html
|
introductory AS/400 tutorial -- on Commands; lib.lists; PDM; queries; PF's and LF's; SDA; RLU; Debugging RPG ILE with STRDBG; a complete maint. pgm. in ILE & RPG3 |
|
www.texas400.com/basicas400tips.html
|
about 28 basic as/400 tips from programming to administration. Also see
FAVORITE Tips and Techniques; Basic AS/400 Skills; their favorite AS/400 Links; some RPG Source Code; and an introductory AS/400 Tutorial |
|
www.itjungle.com/fhg/fhgindex.html
|
all the back-issue articles from the
Midrange Programmer, OS/400 Edition and Midrange Guru, OS/400 Edition magazines |
|
www.freeas400software.com/
|
links to AS/400 software - tools, Utilities, - even a few games |
|
www.taatool.com/document/category.htm
|
TAATOOLS free AS/400 utilities IBM made available to all RPG programmers - written by IBM'ers |
|
www-922.ibm.com/boatcgi/start
|
developing web aps on the AS400 with RPG behind the html(s) - from "a non-profit site" but you have to register. |
RPG ILE BOOKS
I have seen pdf formatted IBM (RPG-ILE) manuals where you could
only see (or download) one item at a time. here is IBM's reference
manuals source where you can see and download the whole book in
either html or pdf format; (#3. below is the best)
One drawback, in the html book (#1), the "internal" links to the
topics in the table of contents (and elsewhere) pointed to another
copy of the book on IBM's web site instead of internally as it
should. I have stopped that and the chapters now point to their
respective locations. The worst of it is that virtually all the
code is based on goto's - RPGII programming! Worthess. The ILE-RPG
Sample-1 SUBF-Program below it is greatly enhanced over the
original and is structured.
(7 meg)
1. WebSphere Development Studio
ILE RPG Reference V5R3 . (pdf)
( this includes sample code written in RPG-Free format )
( The RPG compiler for Windows ) (5.4 meg)
2. VisualAge RPG Language Reference V5R3 (pdf)
(includes built in functions,
a lot of sample code, some in /free-format)
( unfortunately, a number of examples still use rt-hand indicators and
spagetti spinning infinite loops, goto's, leave's, etc. )
a Redbook
4. Neat features discovered about the D spec!
5. An old RPG III (RPG400) Users Guide, V5R3
For more downloadable IBM books, see
IBM Public Library, Boulder, Colorado
look under: Site Map, Programming, Languages, RPG.
Thanks to a friend, Ken Killian,
for items 3. and 4. and the 1st 2 code images below.
|
|
THE 3 BASIC PROGRAMMING CONSTRUCTS
|
1. SEQUENCE
|
consecutive |
2. BRANCH
|
if - else |
3. LOOP
|
do while |
The basics of structured programming:
All code stays within the 3 constructs, therefore
1. there are no goto's, jumps, exits, iterates, etc.
2. all loops terminate at the bottom.
(the condition may be expressed at the top)
3. there are no infinite loops.
|
|
just 1 affirmation, from a David Michael Zokaites:
"The most basic practice, for those programming in procedural languages,
is to avoid the infamous goto statement; well structured and designed
programs simply have little need for it. "Spaghetti code," riddled with
gotos, is notoriously difficult to decipher."
|
The following program receives a customer number as an input
parameter and returns the name and address as output parameters.
F*
FARMstF1 UF E Disk Rename(ARMST:RARMST)
D*----- =-- --- --- = ---------------------------
D pCusNo S 6p 0
D pName S 30a
D pAddr1 S 30a
D pAddr2 S 30a
D pCity S 25a
D pState S 2a
D pZip S 10a
D*----- =-- --- --- = ---------------------------
C* -==------------- ========= ------------- ============== ---- :++--== *
C *entry plist
C parm pCusNo
C parm pName
C parm pAddr1
C parm pAddr2
C parm pCity
C parm pState
C parm pZip
C pCusNo chain ARMstF1
C if %found
C eval pName = ARNm01
C eval pAddr1 = ARAd01
C eval pAddr2 = ARAd02
C eval pCity = ARCy01
C eval pState = ARSt01
C eval pZip = ARZp15
C endif
C eval *InLR = *On
C* -==------------- ========= ------------- ============== ---- :++--== *
The same program using free calculations:
F*-------- := - - --- - ------- ---------------------------
FARMstF1 UF E Disk Rename(ARMST:RARMST)
/copy cust_pr
D** D E F I N I T I O N S
D* The PI "procedure interface" describes the *ENTRY parameters
* only the pCusNo comes in, it and the
* rest are passed on to the next pgm.
D getCustInf PI
D pCusNo 6p 0 const
D pName 30a
D pAddr1 30a
D pAddr2 30a
D pCity 25a
D pState 2a
D pZip 10a
D*----- =-- --- --- = ---------------------------
/free
// get the record:
chain pCusNo ARMstF1;
if %found;
pName = ARNm01;
pAddr1 = ARAd01;
pAddr2 = ARAd02;
pCity = ARCy01;
pState = ARSt01;
pZip = ARZp15;
endif;
// RPG makes use of switches. One switch "LR" stands for
// "last record". This ends program execution.
*InLR = *On;
/end-free
|
free-format RPG:
F...
D...
C* --------------------------------------
/FREE
var01 = var2 + var 3;
dou msgInf.bytRet >= msgInf.bytAvl;
//... call the API
QMHRTVM(msgInf: memSize: i_format: i_msgID: i_qMsgF:
i_rplData: %len(i_rplData): rplVars: rtnCtrlChr: errCode);
//... get more memory
if memSize < msgInf.bytAvl;
memSize = msgInf.bytAvl;
pMsgInf = %realloc(pMsgInf: memSize);
else;
o_msg = f_newMsg(cMsg_ID_OK);
endif;
enddo;
/END-FREE
C*
C*
o* -----------------------
O*
O*
o* -----------------------
* (subprocedure) b = begining
P procedurename b
D SubProc PI
C*
C*
/FREE
...etc.
/END-FREE
P procedurename e
C* -------------------------------------
MOVEing numeric to string:
the MOVEL etc. is not needed.
%SubSt(CurrInv:1:6) = %Char(InvNo);
alpha5 = digits(num5);
%SubSt replaces the dropped MOVEL operation
Notes:
(sub)Procedures follow the O-specs, if you have any.
Since most RPG programs these days don't have O-specs,
subprocedures usually follow the C-specs.
A program with a subprocedure
will not run in the default activation group, so include an
H-spec to force it to run in a named activation group.
ex: QILE
H dftactgrp(*no) actgrp('QILE')
F*-------- := - - --- - -------
Returning a Value:
Here's another thing subprocedures can do that subroutines can't:
A subprocedure can return a value in the same way that a built-in
function returns a value. This means that you can reference a
subprocedure name in such operations as EVAL, IF, and DOx.
Like:
C eval PWStateTax =
C CalcStateTax
C (PWGross:
C PWNbrPer:
C PWMarStat:
C PWNbrDep)
* where CalcStateTax is a sub-procedure
subprocedures support recursion.
That is, a subprocedure can call itself.
However: Don't start converting subroutines to subprocedures.
You may benefit from converting subroutines that carry out common
tasks or tend to break and need a lot of fixing; but otherwise,
don't.
There is one big advantage to the old subroutines worth mentioning.
Subroutines are accessed faster than subprocedures.
In a fast processing read loop of a file, the simple subrouting
may be noticeably faster and performance may be an issue.
a CLP message handling example from
Powertech Toolworks, Inc. Copyright 1995,1996
PGM
DCL &msgid *CHAR 7
DCL &msgf *CHAR 10
DCL &msgflib *CHAR 10
DCL &msgdta *CHAR 100
MONMSG CPF0000 EXEC(GOTO ERROR)
.
. (Include normal processing here)
.
RETURN /* Normal end of program */
/* ---------------------------------------- */
ERROR: RCVMSG MSGTYPE(*LAST) +
MSGDTA(&msgdta) +
MSGID(&msgid) +
MSGF(&msgf) +
SNDMSGFLIB(&msgflib)
MONMSG CPF0000 /* Just in case */
SNDPGMMSG MSGID(&msgid) +
MSGF(&msgflib/&msgf) +
MSGDTA(&msgdta) +
MSGTYPE(*ESCAPE)
MONMSG CPF0000 /* Just in case */
ENDPGM
"However, many programs have special error-handling
requirements, and should be accommodated whenever possible."
|
Binding ( or Linking )
In Windows, MS introduced the ".dll" or Dynamic Link Library, where
each .dll file contains one or more object modules that were
"linked" to create a single loadable .dll file that can be
(dynamically) loaded (on demand) into memory, if and when needed.
In OS/400, they call these a "service program" (*SRVPGM).
The CRTPGM command is used to combine one or more *MODULEs into a
*PGM, while CRTSRVPGM is used to combine one or more *MODULEs into
a *SRVPGM. Both of these commands, are part of the "binder" or
linker of OS/400.
UPDPGM can be used to replace one or more *MODULEs in a *PGM
(perhaps with a newer, "fixed" version). Similarly, UPDSRVPGM can
replace *MODULEs in a *SRVPGM.
All of these functions were provided by a single utilty program of
IBM's venerable mainframe OS/360, OS/VS, MVS thru OS/390, and it is
called the "Linkage Editor".
So, CRTPGM, CRTSRVPGM, UPDPGM and UPDSRVPGM are all a part of the
ILE "binder" in OS/400.
CRTBNDRPG - option 14=Compile in PDM
Activation Groups
Previous articles discussed creating programs out of modules, which
is a two-step process: In RPG, this would include CRTRPGMOD (Create
RPG Module) and then CRTPGM (Create Program). I use this approach
exclusively, but for single-module programs, these steps can be
consolidated into one command: CRTBNDRPG (Create Bound RPG
Program). In PDM, this is the old stand by option 14, and the
result is a *PGM object: The interim *MODULE object is not created.
The reason why I mention this approach now is that this is
typically the first run-in that new RPG IV programmers have with
activation groups.
If you prompt 14 in PDM, you will see an option for Default
Activation Group, with a default of *YES. If you try to create a
program with DFTACTGRP(*YES), that program can't use any ILE
features: no procedures (not even internal), no service programs,
no binding directories. This sort of program is considered OPM even
if it is written in RPG IV. As a result, you frequently see
examples that include an H-spec of DFTACTGRP(*NO). This allows the
program to compile with all of those ILE goodies because now, by
virtue of being created with something other than the DAG, it is an
ILE program.
From
"What You Should Know About Activation Groups"
by Joel Cochran at IT Jungle.
Binding Directories, A Way of Life
The first thing you should be aware of when building RPG IV
applications with multiple modules (source members) is the binding
directory. Binding directories contain lists of either modules or
service program objects. The AS/400 binder uses these objects to
compile RPG IV programs.
A binding contains only a list of the modules or service programs,
not the actual objects. So as new versions or fixes or introduced,
the latest object is used by the compilers. Another wonderful
byproduct of binding directories is that you don't have to specify
a long list of module names for the program your compiling.
While you can create your own binding directories, which is
something I do for each application I create, you can also take
advantage of a binding directory that is provided with all AS/400
systems. That binding directory name is QC2LE.
QC2LE Binding Directory
There is a special binding directory on your AS/400 named QC2LE. It
contains a list of modules and service programs needed for the C
language runtime environment.
The C language has several interesting methods for evoking a
procedure call, fortunately one of these methods allows the
procedure to be called via a pointer to a procedure. Consequently,
the functions for the C runtime library are stored in service
programs. This is where the binding directory comes in. IBM
provides with OS/400, the QC2LE binding directory. In this binding
directory is a list of all the modules and service programs that
make up the C runtime library.
In many ways, the IBM AS/400-iSeries has not
lived up to the adoration some,
mostly those who have not paid attention to the alternatives,
have given it.
Routerless Clients for the AS/400
"AS/400 Technology Showcase" (magazine) pg.43
"as the internet takes hold of the communications world, its
underlying protocol layer, TCP/IP, has become widespread and
the requirement for a router has been eliminated (the SNA
protocol subset of Logical Unit 6.2 - LU6.2).
... the router is a complex, slow, and resource-hungry component,
TCP/IP eliminates the need of the router layer. Gone are the 40
or so seconds waiting for the APPC router to establish its
connection with the as400. Gone are the mysterious connection points
that make it nearly imposslible to determine where the fault lies.
The router was eight miles of bumpy, gravel road, and now its gone.
finished. Done with. We've got TCP/IP now and we aren't going back.
Do you have a connection to the AS400? Just ping it and find out.
IBM has often blazed its own technological trail while failing to notice
the clearly marked and highly traveled path paralleling its course to an
identical destination. Thus IBM encoded characters in EBCDIC instead
of ASCII, invented the propriatary microchannel bus when the industry
was crying for non-propriatary bus standards, clung to the OS/2
operating system long after the world had clearly embraced Windows, and
promoted token ring topology over the simpler and less expensive Ethernet.
- Jerome Draper, specialist in connecting the AS400 to pc's lan's Macs
and to the internet.
|
|
|
PWSDB - Programming WebSites and DataBases * gregs@pwsdb.com
|
|