rpg skills for the new millenium - gomitec.com

26
© Copyright ComCon, 2004. 1 RPG Skills for the New Millennium Re-skill the RPG Programmer ComCon 5, Oakton Court Ballybrack Co. Dublin Ireland Phone: +353 1 282 6230 e-Mail: [email protected] Web: www.ComConAdvisor.com Paul Tuohy Paul Tuohy Paul Tuohy has worked in the development of IBM Midrange applications since the ’70s. He has been IT manager for Kodak Ireland Ltd. and Technical Director of Precision Software Ltd. and is currently CEO of ComCon, a midrange consultancy company based in Dublin, Ireland. He has been teaching and lecturing since the mid-’80s. Paul is the author of "Re-engineering RPG Legacy Applications“, “The Programmers Guide to iSeries Navigator” and the self teach course “iSeries Navigator for Programmers”. He writes regular articles for iSeries 400 Experts Journal and Search400 and is one of the quoted industry experts in the IBM Redbook "Who knew you could do that with RPG IV?". He is also an award winning speaker who speaks regularly at US Common conferences and the renowned RPG World conferences.

Upload: others

Post on 18-Mar-2022

3 views

Category:

Documents


0 download

TRANSCRIPT

© Copyright ComCon, 2004. 1

������������������������

RPG Skills for the New Millennium

Re-skill the RPG Programmer

ComCon5, Oakton CourtBallybrackCo. DublinIreland

Phone: +353 1 282 6230e-Mail: [email protected]: www.ComConAdvisor.com

Paul Tuohy

������������������������

Paul Tuohy

Paul Tuohy has worked in the development of IBM Midrange applications since the ’70s. He has been IT manager for Kodak Ireland Ltd. and Technical Director of Precision Software Ltd. and is currently CEO of ComCon, a midrange consultancy company based in Dublin, Ireland. He has been teaching and lecturing since the mid-’80s.Paul is the author of "Re-engineering RPG Legacy Applications“, “The Programmers Guide to iSeries Navigator” and the self teach course “iSeries Navigator for Programmers”. He writes regular articles for iSeries 400 Experts Journal and Search400 and is one of the quoted industry experts in the IBM Redbook "Who knew you could do that with RPG IV?". He is also an award winning speaker who speaks regularly at US Common conferences and the renowned RPG World conferences.

© Copyright ComCon, 2004. 2

������������������������

Agenda

Skills for what?� Why do you need to re-skill?� What has changed?

What Are The First Steps?� Use The Right Tools for the Job.� Get to Grips with RPG IV and ILE.� Find Out about Event Driven

Programming.� Learn the basics of HTML, XML and

Javascript.

Which GUI?� Decide on the New Interface -

Windows Application or Browser?� What is CGI and how do you use it?� Java

������������������������

Websphere

Java

ILE

Webfacing

RPG IVHTML/CGI

The times they are a changing...

© Copyright ComCon, 2004. 3

������������������������

Premise (V4R5 and V5R1)

You are not using Third Party Tools� There are many Great third party tools out there. � Maybe you should be using one of them!!!!

All You Have is Websphere Development Toolset!� Application Development Toolset (ADTS).� Websphere Development Tools for iSeries.

- CODE (Editor, Designer, Project Manager).- Distributed Debugger- Websphere Studio- Webfacing Tool- VisualAge for RPG.

� VisualAge for Java� ALL of the compilers for OS/400

- RPG, Cobol, C, Java etc.

������������������������

And on V5R2

Websphere Development Studio Client for iSeries� New packaging which replaces WDT/400 in V5R2 and later shipped

versions of V5R1

The good news:� Great new Java programming toolset, new web design tools, strategic

"Eclipse" plug-in technology base

The bad news:� CODE functionality is not yet incorporated into Eclipse base� Existing CODE tool is shipped with WDSC . . .� HOWEVER . . .

- It is NOT separately installable (you must install everything) until V5R3- Help text integration is not nearly as good as in existing (V5R1) CODE tool

The moral is:� If you are on V5R2 and you ONLY want CODE tools, don't lose the

V5R1 WDT/400 CD set!!!

© Copyright ComCon, 2004. 4

������������������������

Where to Start?

There are a few things you need to look into before you enhance your programming skills.

� Become familiar with the IFS (Integrated File System)� Become familiar with iSeries Navigator (was Operations Navigator)

- Especially the database.

� Grasp the basics of SQL (especially DDL)- You can do this from iSeries Navigator without Interactive SQL.- SQL is slowly(?) replacing DDS.

� Find out about triggers.� Find out about referential integrity.

������������������������

File Systems – The Integrated File System

© Copyright ComCon, 2004. 5

������������������������

SQL

Get to grips with SQL – especially Data Definition Language (DDL).

� It is becoming the standard for maintaining the database.� SQL is being developed - DDS is not.

������������������������

iSeries Navigator - Create a Table

© Copyright ComCon, 2004. 6

������������������������

iSeries Navigator - Create a View

������������������������

iSeries Navigator - Database Navigator

© Copyright ComCon, 2004. 7

������������������������

DB2/400

PRODUCTSTOCK

MOVEMENTUPDATE PRODUCT

Triggers

A Trigger is a program that is called whenever a specified record event occurs on a physical file.

� The Trigger Program is "called" by the DBMS, not by coding logic in your application.

External Triggers and SQL Triggers allowed

������������������������

Parent file

27

2727

Dependent file

Category File Product File

Constraints

DB2/400

Delete request Delete denied

Enforce constraint

Referential Integrity

The ability of the database management system to ensure:� logical consistency of data values between files� validity of data relationships� validity of column contents� robust enforcement of integrity constraints

© Copyright ComCon, 2004. 8

������������������������

GUI Application�Good old Client Server!

Browser Based�The interface is in a browser.

�Fast becoming the most popular.

�Easiest to distribute to the internet.

The Choices

Green Screen� Although everything is heading towards

GUI, there is still a place for green screen within applications.

� Not everything lends itself to point and click.

������������������������

The Right Tools

Get with the right tools.SEU/SDA/RLU are NOT up to the job.Use of CODE/WDSCi can increase productivity by 20% to 40%!!!

© Copyright ComCon, 2004. 9

������������������������

CODE

CODE is � A customizable editor� Reference manual as help� Navigator� Verifier� Much, much more

������������������������

CODE Editor

© Copyright ComCon, 2004. 10

������������������������

CODE Verifier

������������������������

CODE Help

© Copyright ComCon, 2004. 11

������������������������

CODE Navigator

������������������������

Code Designer

© Copyright ComCon, 2004. 12

������������������������

WDSC

������������������������

RPG IV Highlights (1/2)

Get up to speed with RPG IVIf you are still using RPG III - STOP NOWYou will start to see gains from RPG IV within a very short period of time.Here you have it - the brand new RPG!

� 10-character external names (files, format and field names).� Allow mixed case.� Allow blank lines.� Introduction of new Definition (D) Specification. � Elimination of Extension (E) and Line Counter (L) Specifications and the

practical elimination of Input (I) Specifications.� Re-definition of the Header (H), File (F) and Calculation (C)

Specifications.

© Copyright ComCon, 2004. 13

������������������������

RPG IV Highlights (2/2)

� More powerful array definition and processing.� Prefixing externally defined files.� Date processing and manipulation.� Named Indicators Introduction of new data types, especially integers and

pointers.� Introduction of Built in Functions (e.g. %SUBST).� Introduction of Sub Procedures and other ILE related features.� Integration with Java.� And, of course, free format.� But perhaps the most important change with RPG IV is that the re-

structuring has made RPG even easier to change in the future.

������������������������

The Multiple Faces of RPG IVCL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+..

C HRS IFLE 40C HRS MULT(H) RATE PAY 7 2C ELSEC RATE MULT 40 REGPAY 7 2C HRS SUB 40 HRSOT 3 0C RATE MULT 1.5 OTRATE 3 2C HRSOT MULT(H) OTRATE OTPAY 7 2 C REGPAY ADD OTPAY PAY 7 2C ENDIF

CL0N01Factor1++++++Opcode(E)Extended-factor2+++++++++++++++++++++

C If (Hours <= 40)C Eval(H) WeeklyPay = Rate * HoursC ElseC Eval(H) WeeklyPay = ((Hours-40) * (Rate*1.5))C + (Rate * 40)C EndIf

If (Hours <= 40); Eval(H) WeeklyPay = Rate * Hours;

Else; Eval(H) WeeklyPay = ((Hours - 40) * (Rate * 1.5)) + (Rate * 40);

EndIf;

© Copyright ComCon, 2004. 14

������������������������

DayNumber = DayofWeek(InputDate);

ErrInds = ValidCustomer(CustomerData);

If (GetCustomerDept(Customer)) = 'A01';

Subprocedures

Subprocedures are the biggest change to RPG - EVER!� They provide a means of encapsulation.� A great replacement for subroutines

- Can accept parameters (like a program)- Can contain local variables- Can be called recursively

� Subprocedures are do it yourself Built-In Functions- Can return a value- Can be used in expressions- Can be placed in Service Programs

������������������������

P DayOfWeek B D PI 1P 0 D InpDate D

D ASaturday S D Inz(D'02/13/99') D WorkDay S 1P 0

/Free

WorkDay = %Rem(%Diff(InpDate : ASaturday : *D): 7);

If WorkDay < 1; WorkDay = WorkDay + 7;

EndIf;

Return WorkDay;

/End-FREEP DayOfWeek E

Subprocedures

This is what the code looks like...

Begin Procedure

Procedure Interface

Local variables

Return Value

End Procedure

© Copyright ComCon, 2004. 15

������������������������

Procedure

Procedure

Procedure

Procedure

Procedure

Procedure

*Module

*Module

*SrvPgm

Procedure

Procedure

*Module

Procedure

Procedure

*Module

*Pgm

ILE

Subprocedures lead to Service Programs.You start to look at program design in a different way.

� Check the ILE Concepts manual

������������������������

Clients are Event Driven!

Client Applications are event driven.Client Applications can be written in:-

� Java� Visual Basic� C/C++� Any PC Programming Language� Even RPG!!!!

© Copyright ComCon, 2004. 16

������������������������

C DispText BegAct MenuSelect CalTestC 'calendar' GetAtr 'SHOWTEXT' ulTempC Eval ulTemp = 1 - ulTempC 'calendar' SetAtr ulTemp 'SHOWTEXT'C Exsr updateMBarC EndAct

VisualAge for RPG

You need to learn� GUI Design� Event Driven

But it is still RPG.

������������������������

<html><!-- Standard Work With Maintenance --><head>

<title>Work With Products</title><link rel="stylesheet" type = "text/css“

href="/cgiseminar/StyleSheet.css"></head><body>

<center><h1>RPG Meets the Web!</h1><h2>Work With Products</h2>

</center>

HTML

Learn the basics of HTML.� Easy to learn� Lots of good books� I liked "HTML for the World Wide Web"

by Elizabeth Castro ISBN 0-201-35493-4� CODE/WDSC is a HTML editor

© Copyright ComCon, 2004. 17

������������������������

Common Gateway Interface (CGI)

What is CGI?� A standard (APIs) for communicating between a browser, an HTTP

Server and a “script” program (RPG IV in this case)� The program generates HTML and passes it to the server

- Which then sends it out for display as it would any other page

The API's are not as simple as one would like� And the documentation is less than wonderful

Generating HTML directly in the program reduces flexibility� To change the text, one must change the program

- And it is much more difficult to use HTML editors to design the pages

It would be nice to have HTML “externally” defined (like DDS) � That way only the variable content is handled by the program

- But writing a generalized routine to perform text substitution is not trivial

IBM has an answer and it is FREE !!CGIDEV2 is available for download at www-922.ibm.com

������������������������

Sample of a CGI Web Page

© Copyright ComCon, 2004. 18

������������������������

: : /$TableRow<TR ALIGN=RIGHT><TD>/%ProdCd%/</TD><TD ALIGN=LEFT>/%ProdDs%/</TD><TD><img border=0 src="/cgiseminar/Images/P/%ProdCd%/.JPG"></TD><TD>/%CatCod%/</TD><TD>/%LndCst%/</TD><TD>/%SellPr%/</TD><TD>/%PrlOrdA%/</TD><TD>/%NoDaysA%/</TD></TR>: :

HTML for CGIDEV2

With CGIDEV2, the HTML is kept separate from (or external to) the RPG Program

� Identify sections or formats- /$TableRow

� Identify variables- /%ProdCd%/, /%CatCod%/ etc.

������������������������

// Load substitution variablesUpdHTMLVar('ProdCd':ProdCd);UpdHTMLVar('ProdDs':ProdDs);UpdHTMLVar('CatCod':CatCod);UpdHTMLVar('LndCst':%Char(LndCst));UpdHTMLVar('SellPr':%Char(SellPr));UpdHTMLVar('PrlOrdA':PrlOrdA);UpdHTMLVar('NoDaysA':NoDaysA);

// And add row to tableWrtSection('TableRow');

Code Using CGIDEV2

Coding is So Much easier with CGIDEV2!

© Copyright ComCon, 2004. 19

������������������������

Getting to the Web is Easy!!!!!

So Far...

If you learn� RPG IV� Some ILE� Some HTML

You can be on the Web in No Time!

������������������������

XML

Learn the basics of XML� Easy to learn, especially if you are familiar with HTML� Lots of good books� I liked “XML for the World Wide Web" by Elizabeth Castro

ISBN 0-201-71098-6� WDSC is an XML editor.

<?xml version='1.0'?><Products>

<Product><Code>0000001</Code><Description>Left Handed Spanner</Description>

</Product><Product>

<Code>0000003</Code><Description>Philips Screwdrivers</Description>

</Product></Products>

© Copyright ComCon, 2004. 20

������������������������

<HTML><HEAD><TITLE>Quote of the Day</TITLE></HEAD><BODY><DIV ALIGN=CENTER><H1>Quote of the Day</H1><HR><FONT COLOR="navy" SIZE="5"><SCRIPT><!--var quotes = new Array()quotes[0] = "Every time history repeats itself the price goes...quotes[1] = "The moment you think you understand a great work ...

.. .. .. ..

quotes[9] = "So little done, so much to do....

document.write(quotes[Math.round(Math.random()*9)])

// --></SCRIPT></FONT></DIV></BODY></HTML>

Javascript

Extend those HTML capabilitiesJavascript is NOT full blown Java

� by any means.

������������������������

Write Header; Write MsgSflC; ExFmt Detail;

ErrInds = *Zeros; ClrErrMsg(); PositionCursor = *Off;

Select; When FrcExt = 'Y';

#Ctl = '*END'; When F3Exit;

#Ctl = '*END'; #Retrn = 'X';

When F4Prompt; #Ctl = 'F4PM';

When F12Cancel; #Ctl = '*END';

RPG ProgramRPG Programenter Product number:_____

Time:8:05 date:Oct 22,2000

5250

Web

5250 to Web conversionWorkstation

manager

Converts DDS to Servlets and JSPsThere is NO change to the RPG Programs

Webfacing

© Copyright ComCon, 2004. 21

������������������������

WDSC for Web Design

������������������������

TCP/IP

HTTPserver

Servlet EngineJDBCRPGCoboEtc.l

Administrative Server

Database

Any Client,Any Browser

HTMLWeb

Browser

Admin Console

EJB Container

Application Server

EJB Client

Websphere Application Server

� Servlets� Java Server Pages (JSPs)� Enterprise Java Beans (EJBs)

© Copyright ComCon, 2004. 22

������������������������

Get Balance

Get Address

Set Balance

Set Name & Address

Set Balance

And then there is Java

Get to grips with OO.... it is very different.A good grounding in RPG IV and ILE makes it easier to understand.

������������������������

Java

Java is an OO Language

© Copyright ComCon, 2004. 23

������������������������

Java Code in CODE

������������������������

Java Code in WDSC

© Copyright ComCon, 2004. 24

������������������������

IFSiSeries

NavigatorSQL

Triggers and RI

HTMLCGI

XML

WebFacing

VisualAge for RPG

OO and Java

Websphere Application

Server, JSPs, etc.

WDSC/CODE

RPG IV and ILE

Javascript

A Plan of Action

Must Do... Should Do... And then Any of...

������������������������

� �� �� �� �� �� �� �� � � ���

�� ������

��������

������

���

��� !����

������

��� !��"#

��� !���$%�! &'

��#��%� ���$

((

)�*�

+�, !�

+-����� & &'��. *�

��. ��

#�/%�+��!-

� �!0 !�

The Learning Curve

� Times are opinion based on the experience of many.� "Practice" is to a level of proficiency as opposed to expertise.

© Copyright ComCon, 2004. 25

������������������������

3128227.5

30208Java

100103OO

1052WDSC for Web

1552Webfacing

20103Basic WAS

1552CGIDEV

2551Basic CGI

80102ILE

10104RPG IV

720.5Code/400

PracticeSelf TeachCourse

Course/Practice = 339.5 Self Teach/Practice = 394

How Long Will It Take?

Pick the Route Carefully!!!!!!

������������������������

The Choice is Yours!

Lay the foundations� IFS, SQL, iSeries Navigator, Triggers, Referential Integrity, RPG IV and

ILE.

Take the first step� CODE/WDSC� HTML� CGI� XML

Jump� VisualAge for RPG� Webfacing� OO and Java

© Copyright ComCon, 2004. 26

������������������������

Some References (1 of 2)

iSeries Navigator for Programmers� Self teach course by Paul Tuohy at www.lab400.com

"Who Knew You Could Do That With RPG IV".� IBM Red Book SG24-5402 at www.redbooks.ibm.com

“ILE Concepts Manual”� Information Center

"Re-Engineering RPG Legacy Applications"� By Paul Tuohy ISBN 1-58347-006-9 at mc-store.com

"HTML for the World Wide Web"� By Elizabeth Castro ISBN 0-201-35493-4

“XML for the World Wide Web"� By Elizabeth Castro ISBN 0-201-71098-6

“SQL/400 Developer's Guide”� by Paul Conte and Mike Cravitz ISBN 1-882-41970-7 at

www.iseriesnetwork.com

������������������������

Some References (2 of 2)

The CGIDEV2 web site� www-922.ibm.com

"e-RPG - Building AS/400 Web Applications with RPG"� By Brad Stone ISBN 158347-008-5 at mc-store.com

"Java for RPG Programmers"� By George Farr and Phil Coulthard ISBN 1-889671-23-1 at mc-

store.com