Step by Step: RPG Report to the web -...
Transcript of Step by Step: RPG Report to the web -...
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
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
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
Review of Webinars
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved| 5
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
Look at the data base
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved| 7
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
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
Create Collection - ZENDSMP010
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 10
Create Table
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 11
Load data in table
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 12
• 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
RPG Code Sample
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 14
Report Output
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 15
Let’s see the new web page!
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved| 16
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
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
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
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
Connect to DB2 code
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 21
Connect to DB2 Display
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 22
Step 2: Build Main Loop
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 23
Step 2 Output
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 24
Step 3: Add references to other tables
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 25
Step 3 Output
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 26
Step 4a Code & Output
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 27
Standard HTML Heading
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?
Step 4c Part 1
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 29
PHP Toolkit Example
Access IBM i via PHP toolkit for Data Area
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 30
Step 4c part 2
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 31
Total time!
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 32
Finished product
Completed scriptTake it home and embellishWorks on complex RPG too!
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 33
Bells and whistles…
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved| 34
Bells and whistles
• Consider an i5 program call• Order detail and PDF formatting
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 35
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
Program call prepare…
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 37
Program call, Execute
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 38
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
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
•
Read through detail
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 41
Build PDF & heading
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 42
Roll through the detail in the PDF
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 43
PDF File in IFS
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 44
PDF file
10/5/2009Copyright © 2009 Zend Technologies, Inc, All rights reserved | 45
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
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