Step by Step: RPG Report to the web -...

48
Step by Step: RPG Report to the web Mike Pavlak Zend Technologies, Inc. [email protected]

Transcript of Step by Step: RPG Report to the web -...

Page 1: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Step by Step:RPG Report to the web

Mike PavlakZend Technologies, Inc.

[email protected]

Page 2: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Join us at ZendConthe premier PHP conference!

October 19-22, 2009 - San Jose California

Zend/PHP Conference

www.zendcon.com

Conference Highlights Conference Tracks� Learn how to best develop and deploy PHP � Server/Operations� Technical sessions for all knowledge levels � Lifecycle Best Practices� In‐depth tutorials for advanced learning � Frameworks � PHP Certification courses and testing � Real‐World PHP� Exhibit hall showcasing the latest products � PHP Development Techniques� Networking opportunities with peers and luminaries � Zend Solutions for PHP on IBM i

Page 3: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Target audience

• Looking to move beyond Green Screen• Have little to no experience with PHP• Want to pick up a little about HTML and CSS• Have done about a million RPG reports...

Copyright © 2009 Zend Technologies, Inc, All rights reserved 10/5/2009 | 3

Page 4: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Agenda

• Review of recorded webinars• Look at database & sample report• Explore the result of the web page• Step by step:

1. Connect to DB22. Build main loop3. Add references and calculations4. Add formatting5. Bells and whistles

1. RPG program Call2. Output to PDF (free and easy!)

• Wrap up / Q&ACopyright © 2009 Zend Technologies, Inc, All rights reserved 10/5/2009 | 4

Page 5: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Review of Webinars

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved| 5

Page 6: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Webinars for IBM i

• http://www.zend.com/en/resources/webinars/i5-os

! Getting Started with PHP for i5 shops! Web Services on i5! PHP 101 for i5 shops! Confessions from RPG developer: Why use Zend Framework?! Confessions from RPG developer: Why use Zend Framework?! How RPG Programmers can Leverage Arrays! Give Your IBM iSeries an Extreme Makeover with Zend & PHP!! Using PHP and System i to Improve Vendor Productivity! Platform for i5/OS - What i5 shops need to know! 5250 Bridge and Zend Platform! Platform for i5/OS - What i5 shops need to know

| 5-Oct-09Modernizing legacy applications on i5 with PHP | 6

Page 7: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Look at the data base

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved| 7

Page 8: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

How is this thing going to work?

• New series offered by Zend: Step by Step! Move your RPG report to the web with PHP

• This is a very simple but manual process, no magic here• Everything to run RPG and PHP is provided• You can play all you want• No copyright on any code, use as-is-as-shown• Website will contain periodic updates

! Next: Maintain your DB2 data with PHP! After that it is up to you! What do you want to see?

| 5-Oct-09Modernizing legacy applications on i5 with PHP | 8

[email protected]

Page 9: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Sample Database is provided using PHP

• Used pure PHP and SQL to create database• Run PHP script called: builddata.php• Create collection, then tables, then load tables…• You can add records as you see fit• This may even prove useful in your shop

• Let’s look at some code

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 9

Page 10: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Create Collection - ZENDSMP010

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 10

Page 11: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Create Table

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 11

Page 12: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Load data in table

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 12

Page 13: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

• Now you have the sample data base, how about the sample report?

• It is a very basic Order Summary• Written in RPG Free

U i SQL d t• Using SQL data access

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 13

Page 14: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

RPG Code Sample

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 14

Page 15: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Report Output

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 15

Page 16: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Let’s see the new web page!

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved| 16

Page 17: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Target solution:

•What you see:•Logo•Headings•Green bar look

•(ahhhhhhhh!)•Detail records•Data &cell formatting

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 17

•Totals

•What you don’t see•PHP Code•HTML•CSS•How we get here

•Step-by-step

Page 18: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Here are the steps

1. Connect to DB2 (Top of the cycle)2. Build main loop (Mainline)3. Add references (Chain)4. Add formatting (Edit codes)

Database layout:

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 18

SALESORD

SALESLINE CUSTOMER

Page 19: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Before we begin…Do your homework!

• Research the RPG program! Many details can be overlooked! What is it doing well, not so well

• Talk to primary user! Are there additional needs! Are there additional needs! Would a web version truly help them! Will they still require hard-copy

• Prepare for the onslaught! Once one user gets web based solutions, they all want them!

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 19

Page 20: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Step 1: Connect to DB2

• Use DB2_Connect function! Why not i5_connect? Could have done

• A few words about authority! If your data sets are *PUBLIC *Read, no auth necessary! Can do authentication a couple of ways! Can do authentication a couple of ways! Or hard code userid and password

• Let’s look at the code…• The code for each step will be provided on the

website in a week or so.

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 20

Page 21: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Connect to DB2 code

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 21

Page 22: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Connect to DB2 Display

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 22

Page 23: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Step 2: Build Main Loop

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 23

Page 24: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Step 2 Output

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 24

Page 25: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Step 3: Add references to other tables

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 25

Page 26: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Step 3 Output

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 26

Page 27: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Step 4a Code & Output

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 27

Standard HTML Heading

Page 28: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Step 4b code & output

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 28

Format web page in script:Effective, but is it

smart?

Page 29: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Step 4c Part 1

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 29

Page 30: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

PHP Toolkit Example

Access IBM i via PHP toolkit for Data Area

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 30

Page 31: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Step 4c part 2

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 31

Page 32: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Total time!

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 32

Page 33: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Finished product

Completed scriptTake it home and embellishWorks on complex RPG too!

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 33

Page 34: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Bells and whistles…

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved| 34

Page 35: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Bells and whistles

• Consider an i5 program call• Order detail and PDF formatting

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 35

Page 36: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

i5 Program Call

• Three main ways to modernize! Rewrite! Restructure! Reface

• Put business logic where it makes sense for youPut business logic where it makes sense for you• Leverage the decades of RPG routines that work

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 36

Page 37: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Program call prepare…

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 37

Page 38: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Program call, Execute

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 38

Page 39: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Order Detail Print…

• Read order detail file• Instantiate a PDF object• Update the object with the contents of the order• Write the PDF• Dispose of the object• Admire our work!

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 39

Page 40: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Zend_PDF

• Component of Zend Framework• Comes with Zend Core for i5• FREE!!!• ZF is built by the community, for the community• Documentation at: http://framework.zend.com/manual/en/zend.pdf.html

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 40

•Tutorial•Documentation•Examples at framework.zend.com

Page 41: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Read through detail

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 41

Page 42: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Build PDF & heading

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 42

Page 43: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Roll through the detail in the PDF

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 43

Page 44: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

PDF File in IFS

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 44

Page 45: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

PDF file

10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 45

Page 46: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

New book!

Kevin Schroeder from Zend’s Global Services Group

with Jeff Olen, co-author of…

Get yours at MCPressonlineor at fine bookstores

everywhere

| 5-Oct-09Name of this section | 46

Page 47: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Join us at ZendConthe premier PHP conference!

October 19-22, 2009 - San Jose California

Zend/PHP Conference

www.zendcon.com

Conference Highlights Conference Tracks� Learn how to best develop and deploy PHP � Server/Operations� Technical sessions for all knowledge levels � Lifecycle Best Practices� In‐depth tutorials for advanced learning � Frameworks � PHP Certification courses and testing � Real‐World PHP� Exhibit hall showcasing the latest products � PHP Development Techniques� Networking opportunities with peers and luminaries � Zend Solutions for PHP on IBM i

Page 48: Step by Step: RPG Report to the web - static.zend.comstatic.zend.com/topics/StepbyStep---RPG-report-to-web.pdf · Step by Step: RPG Report to the web Mike Pavlak Zend Technologies,

Q&A Thank you!

Contact info:Contact info:Mike Pavlak

[email protected]