blog: email: [email protected] ... slides/php-case-study-on...zend studio ibm, oracle endorse php...

80
5250 to Web: PHP Case Study on IBM i Alan Seiden PHP on IBM i consultant/developer email: [email protected] blog: http://alanseiden.com

Upload: others

Post on 16-Sep-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i

Alan SeidenPHP on IBM i consultant/developeremail: [email protected]: http://alanseiden.com

Page 2: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 2Alan Seiden, Strategic Business Systems

Strategic Business Systems, Inc.

• Developing Web apps on IBM i (and iSeries, i5...) since 1996• Based in Ramsey, New Jersey

• IBM Business Partner Power Systems hardware, software development, consulting

• Zend Business Partner Working with Zend since they brought PHP to IBM i in 2006 We offer Zend’s training and Zend Server software to complement

our own consulting/development services

Page 3: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 3Alan Seiden, Strategic Business Systems

Alan Seiden

PHP on IBM i Developer / Consultant / Mentor• Contributor to IBM’s Redbook PHP: Zend Core for i5/OS• First IBM i developer certified in Zend Framework• Developer of IBM/COMMON’s “Best Web Solution” of 2009

Contact: [email protected] or 201-327-9400Blog/articles: http://alanseiden.com

Page 4: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 4Alan Seiden, Strategic Business Systems

What we’ll discuss today

• Update on Zend Server (new PHP install for i) • PHP basics quick overview

Focus on two ways to call CL/RPG from PHP

• Case study: re-imagine green screens as web• Tips and techniques

• Questions

Page 5: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 5Alan Seiden, Strategic Business Systems

1995 1997 1999 2000 2002 2003 2004 2005 2006 2007

20M

15M

10M

5MRasmusLerdorfIntroducesPHP/FI

PHP 4 Released

• 1M Internet domains

• Zend Engine• Zend Founded

Yahoo! Standardizeson PHP

PHP 5.0(XML,SOAP,OOP)Zend Studio

IBM, Oracle Endorse PHP

Zeev Suraski & Andi Gutmanslead the development of PHP 3

PHP’s growth as web dev language (as of 2007)

Zend Framework & Eclipse project (PDT) announced; i5/OS support

PHPInternet Domains

25M

ZF and PDT released, PHP 4 EOLannounced

PHP Proliferation

37% growth in PHP developers

34% of the internet runs on PHP

Page 6: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 6Alan Seiden, Strategic Business Systems

Who uses PHP?

• Yahoo, eBay, Wikipedia, Facebook

• Open source developers – 10,000+ projects

• 7 million+ developers

• Growing community of IBM i shops

Page 7: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 7Alan Seiden, Strategic Business Systems

Reasons for PHP’s success

• Easy way to get data to Web Generates ordinary HTML, viewable in any browser

• Cross-platform: also runs on Windows, Linux, any mainstream OS

• Open source with commercial backing Managed by Zend, “the PHP company” Contributors from community and corporations

Page 8: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 8Alan Seiden, Strategic Business Systems

Free, open source apps (fine on IBM i)

WordPress blog/CMS MediaWiki (Wikipedia) ZenCart e-Commerce

SugarCRMBug Tracker (Mantis400.com)

Page 9: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 9Alan Seiden, Strategic Business Systems

PHP on i—always something new

• 2004: i5php.net Unofficial PHP binary for “i” available online

• 2005: IBM and Zend got together

• 2006: Zend Core for i5/OS Official release with help from IBM Professional technical support from Zend

• 2007: Zend Studio: IDE/code editor and Zend Platform: performance booster and code tracer/monitor

• 2008: Zend Framework supports “i” variant of db2

• 2009: Zend Server Beta for “i” Combines the best of Core and Platform

• 2010: Zend Server released

Page 10: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 10Alan Seiden, Strategic Business Systems

PHP on i—a comfortable fit

• Runs completely on your good old “i” Uses IBM’s native Apache web server Shipped by IBM with v5r4 and higher Connects directly to db2 database

• Light on its feet Efficient—runs well out of the box Create useful functionality quickly; start small and grow

• Plenty of room for sophistication in larger apps

Page 11: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 11Alan Seiden, Strategic Business Systems

Zend ServerZend Server

Page 12: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 12Alan Seiden, Strategic Business Systems

Zend Server for IBM i

• Next generation PHP stack for IBM i Best of Zend Core and Platform in one licensed program

• Two license levels Zend Server for IBM i Community Edition (CE)

• Available at no charge per IBM partnership• Includes “Optimizer+” that speeds up code• One year silver (email) support

Zend Server for IBM i, a.k.a. Professional Edition (PE)• Subscription-based license• High value extra features, higher Support SLAs

• Details of differences: http://mikepavlak.blogspot.com/2010/08/i-want-to-do-php-on-

ibm-i-so-what-do-i.html

Page 13: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 13Alan Seiden, Strategic Business Systems

Installation

• http://www.zend.com/products/server/downloads Click on the “IBM i” tab

• Prerequisites v5r4 and:

• http://files.zend.com/help/Zend-Server-IBMi/i5_installing_zend_server.htm

• IBM’s FastCGI PTF (free)

• Try Zend Studio’s IDE (no charge, courtesy of IBM) “Zend Studio for Eclipse, IBM i Edition” http://zend.com/en/products/studio/downloads Look for “IBM i Edition”

Page 14: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 14Alan Seiden, Strategic Business Systems

Administration

• Zend Server combines “Core” and “Platform”controls in one interface

• Simpler Apache setup Single web server

• PASE server eliminated

IBM HTTP Server Powered by Apache• PHP implemented using IBM’s Fast CGI

Clean, more complete graphical user interface • Favorite: the Restart button

Page 15: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 15Alan Seiden, Strategic Business Systems

Admin menu (GO ZENDSVR/ZSMENU)

Page 16: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 16Alan Seiden, Strategic Business Systems

Zend Server’s Interface

Page 17: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 17Alan Seiden, Strategic Business Systems

Cheat sheet for upgrade

http://alanseiden.com/2010/04/21/differences-between-zend-core-and-zend-server-on-ibm-i/

Page 18: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 18Alan Seiden, Strategic Business Systems

Zend Server and PHP resources

• Support: Zend Server CE includes one year of email support. Upgrade to Zend Server PE for more years and fast phone support Register at http://www.zend.com/products/server/downloads

and also get Zend’s IBM i newsletter

• Web: Zend’s recorded webinars: http://www.zend.com/resources/webinars/i5-os Zend Forums: forums.zend.com (look for IBM i Zend Server forums) http://alanseiden.com (of course!)

• Books (online and print) PHP Manual: http://php.net PHP on IBM i book by Jeff Olen & Kevin Schroeder

(MC Press)

• Training from Zend/others

Page 19: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 19Alan Seiden, Strategic Business Systems

Community PHP resources

• PHP User Groups See http://php.net for a list Not only learn, but tell the PHP world about IBM i

• Conferences COMMON Fall Conference (Congratulations—you made it!) Zend/PHP (ZendCon), Nov 1-4, 2010, Santa Clara, Calif.

• Your local IBM i / Power Systems user group Consider asking your board to schedule some PHP talks PHP topics tend to boost attendance

Page 20: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 20Alan Seiden, Strategic Business Systems

PHP basics on iPHP basics on i

Page 21: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 21Alan Seiden, Strategic Business Systems

PHP basics: Step 1

• Learn some basic HTML Try http://w3schools.com/html Tables (<table>,<tr>,<td>) useful for business data “View Source” in browser to borrow bits of HTML

• Then learn these as you go Javascript

• Adds dynamic functionality to pages

Cascading style sheets (CSS)• Modern way to specify colors, fonts, and other attibutes of how

a site looks

Page 22: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 22Alan Seiden, Strategic Business Systems

Step 2: Try a simple PHP script

• PHP scripts are text files that reside in the IFS• Edit using notepad or Zend Studio for Eclipse, IBM i

edition• Script file: /www/zendsvr/htdocs‏/helloworld.php• Run in browser: http://yourIBMi:10088/helloworld.php

<?php

// simple script to test PHP

echo “Hello, world!”;

?>

Page 23: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 23Alan Seiden, Strategic Business Systems

“Hello, world!” in browser

Output from helloworld.php

Page 24: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 24Alan Seiden, Strategic Business Systems

Step 3: Access db2

Example:Code: /www/zendsvr/htdocs/Samples/SQL_access/DB2_SQL_example.phpURL: http://yourIBMi:10088/Samples/SQL_access/DB2_SQL_example.php

Connect to db2 on i Select records from a db2 table Output the records into an HTML table

Page 25: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 25Alan Seiden, Strategic Business Systems

Step 4: Call RPG/CL from PHP

Two methods:

• i5 PHP Toolkit included with Zend Server call commands and programs access data areas, spool files and other resources Remote IBM i systems/LPARs can be accessed if you request a free

license from Aura Easycom• http://www.easycom-aura.com/en/services_reg.asp

• db2 Stored Procedures “Native” way to call RPG/CL Flexible: add SQL or multiple program calls in one s.p. Remote IBM i systems/LPARs can be accessed using ordinary DRDA-

type connections. Supply an entry from WRKRDBDIRE

Page 26: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 26Alan Seiden, Strategic Business Systems

Let’s call this CL using both methods

0001.00 /* MYLIB/MYPGM, type CLLE */

0002.00

0003.00 PGM PARM(&CODE &FNAME)

0004.00 DCL VAR(&CODE) TYPE(*DEC) LEN(5)

0005.00 DCL VAR(&FNAME) TYPE(*CHAR) LEN(10)

0005.01

0005.02 CHGVAR VAR(&CODE) VALUE(6)

0008.00 CHGVAR VAR(&FNAME) VALUE('JOHN')

0009.02

0010.00 ENDPGM

Page 27: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 27Alan Seiden, Strategic Business Systems

First method: i5 Toolkit

• Special “i5_” functions let PHP access system resources call commands and programs access data areas, spool files, and other resources Examples: i5_connect (secure user/pw), i5_program_prepare,

i5_program_call, i5_spool_list

• Documentation http://files.zend.com/help/Zend-Core-i5/i5_php_api_toolkit.htm http://files.zend.com/help/Zend-Core-i5/i5_php_connector_api.htm

• Samples http://files.zend.com/help/Zend-Core-i5/program_samples.htm

Page 28: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 28Alan Seiden, Strategic Business Systems

i5 Toolkit functions for calling CL/RPG

• i5_connect(server, user, password, options) $conn = i5_connect("1.2.3.4", "MYUSER", "MYPWD");

• i5_command(command, inputs, outputs) Good for commands/programs with no parameters E.g. i5_command("call LIB_NAME/PROGRAM_NAME")

• i5_program_prepare(name, description) Sets up parameter names and data types program library is optional; e.g. MYLIB/MYPROG if needed.

• i5_program_call(program, params, retvals) Calls program with parameter values More about this on next slide

Page 29: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 29Alan Seiden, Strategic Business Systems

Simplify i5 Toolkit calls with “Toolkit Classes”

• A code library in a single .php file that provides: Handling of connection errors Code to connect to i5, prepare, call programs Proper naming of description/params/retvals Output params in an object rather than scattered all around in

individual variables

• One caveat: to get the convenience of “Toolkit Classes,” you need a bit of Object Oriented syntax

Page 30: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 30Alan Seiden, Strategic Business Systems

Calling our CL with“Toolkit Classes”

Simpler than direct connect/prepare/callNote: In OO syntax, “->” calls a method/function or gets/sets a property (like a field in a data structure)

// include “Toolkit “Classes” file, assuming Toolkit_classes.php is in same folder as this PHP script

require_once('Toolkit_classes.php');

// define parameters

$desc = new i5_Description();

$desc->I5_TYPE_INT('code', ‘5', I5_INOUT);

$desc->I5_TYPE_CHAR(‘fname', '10', I5_INOUT);

// prepare program definition

$prog = new i5_Program(‘MYLIB',‘MYPGM', $desc);

// provide input param value(s)

$prog->code = ‘5’;

$prog->fname = ‘Frederick;

// call the program

prog->call();

// if no errors, show the output (properties of the $prog object)

if(is_null($prog->LastErr)){

echo 'Code:'.$prog->code.'<br>';

echo ‘First Name:'.$prog->fname.'<br>}

// output based on CL shown earlier is Code: 6 and First Name: John

Page 31: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 31Alan Seiden, Strategic Business Systems

Zend Server “Toolkit Classes” specifics

• Location of the code: /www/zendsvr/htdocs/i5Toolkit_library/Toolkit_classes.php

• Demo code: /www/zendsvr/htdocs/i5Toolkit_library/demo_for_toolkit_class

es.php One update and then you can run it:

/* Define i5/OS user and password before running

this demo program */

$USER=“i5USER";

$PASSWORD=“i5PWD";

• URL to run the demo:

http://yourIBMi:10088/i5Toolkit_library/demo_for_toolkit_classes.php

Page 32: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 32Alan Seiden, Strategic Business Systems

i5_program_prepare in detail

We can avoid these details because Toolkit Classes handles them

resource i5_program_prepare(string name[,

array description][,

resource connection])

Parameters:• Name: program name. Library is optional (lib/pgm)• Description: definition of parameters to be passed

Sample:• $description = Array (

array('Name' => ‘code', 'IO' => I5_INOUT, 'Type' => I5_TYPE_INT, 'Length' => ‘5'),array('Name' => ‘fname', 'IO' => I5_INOUT, 'Type' => I5_TYPE_CODE, 'Length' => ‘10'));

• For details: http://files.zend.com/help/Zend-Core-i5/easycom_php_data_description.htm

• Connection: optional connection handle

Page 33: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 33Alan Seiden, Strategic Business Systems

i5_program_call in detail

We can avoid these details because Toolkit Classes handles them

bool i5_program_call(resource program,

array params[,

array retvals])

Parameters:• Program: resource id from i5_program_prepare

• Params: array of key => value pairs for input Supplies input parameters Key: name of input parameter, which

• Should match name given in “prepare” Value: value of input parameter Example: array("code"=>"5", “fname"=>"Fred")

• Retvals: array of key => value pairs for output Supplies names of variables to receive output parameters Key: name of output parameter

• Should match name given in “prepare” Value: name of PHP variable to receive the output parameter

• OK to use same name you gave in Key (documentation shows this)• Will generate new PHP variable of this name, containing output data

Example: array("code"=>"code", “fname"=>“fname")

• Full example: http://files.zend.com/help/Zend-Core-i5/program_samples.htm

Page 34: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 34Alan Seiden, Strategic Business Systems

Second method: db2 stored procedures

• Benefits: Re-use existing db2_connect connection from any SQL calls Access remote programs using DRDA capabilities if you provide

the remote database name from WRKDBRDIRE db2 calls are more portable than i5 Toolkit calls Bundle several program calls or SQL statements in one s.p. As db2 improves, you can take advantage of the improvements

• I’ve noticed a trend toward stored procedures A conversation with John Valance at VTMUG convinced me to

give them serious consideration when calling CL/RPG

Page 35: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 35Alan Seiden, Strategic Business Systems

Create the stored procedure

Example: Define call to CL MYLIB/MYPGM with two input/output params

DROP procedure SPLIB/CALL_MYPGM ;

CREATE procedure SPLIB/CALL_MYPGM (

INOUT CODE dec(5),

INOUT FNAME char(10) CCSID 37

)

RESULT SETS 0

LANGUAGE CL

EXTERNAL NAME MYLIB/MYPGM

PARAMETER STYLE GENERAL;

Page 36: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 36Alan Seiden, Strategic Business Systems

Run stored procedure from PHP

$conn = db2_connect ('', '', '',

array ('i5_libl' => "ALAN",

'i5_naming' => DB2_I5_NAMING_ON ) )

or die("Connection failed! ". db2_conn_errormsg());

$sql = 'CALL SPLIB/CALL_MYPGM (?, ?)';

$stmt = db2_prepare($conn, $sql)

or die("<br>Prepare failed! ". db2_stmt_errormsg());

$code = 5;

$fname = "Frederick";

db2_bind_param($stmt, 1, "code", DB2_PARAM_INOUT, DB2_DOUBLE, 5, 0);

db2_bind_param($stmt, 2, "fname", DB2_PARAM_INOUT, DB2_CHAR, 10);

print "Values of bound parameters before CALL:<br>";

print "code: <b>{$code}</b> <br> fname: <b>{$fname}</b> <br>";

if (db2_execute($stmt)) {

print "<HR>Values of bound parameters after CALL:<br>";

print "code: <b>{$code}</b> <br> fname: <b>{$fname}</b> <br>";

}

db2_close ( $conn );

// output based on CL shown earlier is Code: 6 and First Name: John

Page 37: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 37Alan Seiden, Strategic Business Systems

RPG/PHP RPG/PHP side by sideside by side

Page 38: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 38Alan Seiden, Strategic Business Systems

That age-old issue

• “New users don’t like the green screens”

• “We need to open up our apps/data to the outside, safely, and with a GUI”

• But we don’t want to lose our investment in RPG code

• We still want stability…and to run on the “i” !!

Page 39: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 39Alan Seiden, Strategic Business Systems

First thought: automatic webfacing

• Tools such as NewLook do it fast, but: Often require java or plug-ins for browser Users know they’re not true web apps Still green screens in disguise

• Zend has “5250 Bridge” for PHP Pulls 5250 data stream into a PHP app

• Essential if you don’t have the RPG source code Shows promise, but not a slam dunk

• Requires coding for each field unless you can automate• Performs slower than a native PHP app• Web app will still be based on original 5250 app

• OK if your changes will be minor

• These solutions serve a purpose but don’t get you something new

Page 40: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 40Alan Seiden, Strategic Business Systems

Next thought: an approach for true web apps

• I used it with my team at SBS for the first time in 2002 (before PHP on i)

• A smart ‘i’ friend of mine just came up with the same approach independently

• It’s time to talk about it

• All it needs is a catchy name

Page 41: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 41Alan Seiden, Strategic Business Systems

Here is the basic ormula

• PHP calls modified RPG with parameters Copy the RPG and replace its input screen with a list of parameters

• (a unique sequence and/or session id and other key values) RPG looks up data, does calculations, validation

• RPG returns data and error messages in work file(s)• Redirect output to a file instead of the screen

• PHP reads the work file using SQL; outputs data on page

• It is worth the effort if your RPG is complex and valuable

Page 42: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 42Alan Seiden, Strategic Business Systems

Some RPG is already prepared for this

• Some shops already structure their RPG into screen/logic components, even in 5250 mode Parameters rather than one monolithic program Not that there’s anything wrong with monolithic programs

• In that case you may be able to use your “logic”RPG virtually unmodified

Page 43: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 43Alan Seiden, Strategic Business Systems

Flow of PHP/RPG

• PHP controls the flow Receive input from browser Zero-pad numeric fields Write records (if any) to work file(s) Call appropriate RPG(s)

• RPG processes, calculates, validates Writes results to work files(s) Returns status flag to PHP

• PHP reads work file(s) and shows any validation results and data

Page 44: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 44Alan Seiden, Strategic Business Systems

Example of RPG Example of RPG parametersparameters

Page 45: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 45Alan Seiden, Strategic Business Systems

Parameter list of RPG includes sequence and flag

0008.00 H* PARAMETERS : SEQ - (*CHAR 11) - transaction sequence #

0009.00 H* SESS - (*CHAR 25) - session key

0010.00 H* FLAG - (*CHAR 1) - Success Flag (Y/N)

0011.00 H* Y = ... Processed Normally

0012.00 H* N = Not Processed Normally (validation error)

0137.00 C *ENTRY PLIST

0138.00 C PARM SEQ 11

0139.00 C PARM SESS 25

0140.00 C PARM FLAG 1

Page 46: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 46Alan Seiden, Strategic Business Systems

How work files might look

1. PHP creates work file records keyed by sequence#2. PHP fills records with data that user entered on web page3. PHP calls RPG4. RPG fills appropriate work file records with additional data and validation messages. All complex RPG logic occurs here. RPG

returns stat5. PHP reads records, shows messages and other data

Transaction work file(s)/table(s) containing data. Could have header and details.

Transaction sequence 284

Order Number 332

Sales Rep 105

Dollar total 100.35

Validation Request 2951

Validation Group 1

Sample: Validation log file containing validation errors and so on Headers and each detail line of transaction can have multiple validation messages “Validation Group” usage: group 1 = header; group 2, 3, 4, … are detail lines.

Validation Request 2951

Validation Group 1

Validation Unique Seq 8032

Message Id VOR4039

Message Severity 60

Message Text Invalid model year/exterior/interior combination.

• You can devise your own conventions that work for you

Page 47: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 47Alan Seiden, Strategic Business Systems

TipTip

Page 48: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 48Alan Seiden, Strategic Business Systems

Use MONMSG

• Avoid any possibility of a crash in RPG/CL If an RPG/CL does not complete, it won’t return control Web page will “hang” till it times out

• Use MONMSG in CL; provide a return flag to tell PHP if an error occurred

• You could even email yourself the error message

• This technique will avoid head-scratching while you test, change file layouts, etc.!

Page 49: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 49Alan Seiden, Strategic Business Systems

Order Entry Case Order Entry Case Study #1Study #1

Page 50: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 50Alan Seiden, Strategic Business Systems

Medrano Express: four into one

Page 51: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 51Alan Seiden, Strategic Business Systems

Screen #1, Order header

Page 52: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 52Alan Seiden, Strategic Business Systems

Screen #2, Order detail

Page 53: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 53Alan Seiden, Strategic Business Systems

Screen #3, Content package from detail

(Option 4 from order header)

Page 54: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 54Alan Seiden, Strategic Business Systems

Screen #4, Notes from order detail

F9 key launches this

Page 55: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 55Alan Seiden, Strategic Business Systems

Web page combines all 4 “green screens”

Page 56: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 56Alan Seiden, Strategic Business Systems

How do we fit all that on one page?

• Vertical scrolling• Contrasting fonts and colors

Page 57: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 57Alan Seiden, Strategic Business Systems

One PHP script, four RPG programs

• Call each RPG; it fills a work file with data to read• Repeat 4x !• “header” RPG returns useful information for

calling “detail” RPG, etc.• Show results in one PHP “view”

• (Thanks to Jessie Clark)

Page 58: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 58Alan Seiden, Strategic Business Systems

Order Entry Case Order Entry Case Study #2Study #2

Page 59: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 59Alan Seiden, Strategic Business Systems

Allied Beverage Group

Page 60: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 60Alan Seiden, Strategic Business Systems

Original 5250-mode order entry process

• Aimed at expert customer service users• Sales reps accessed it using Jadvantage java

applet in browser Better than nothing S-l-o-w logon Forced reps to have expert knowledge of system

• Dicey wireless signals on the road = lost sessions• RPG was powerful but too complex to be updated

with major new functionality

Page 61: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 61Alan Seiden, Strategic Business Systems

Intro screen

Page 62: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 62Alan Seiden, Strategic Business Systems

Intro with error message (customer)

Page 63: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 63Alan Seiden, Strategic Business Systems

Intro with error message (“return to number”)

Page 64: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 64Alan Seiden, Strategic Business Systems

Main screen

Page 65: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 65Alan Seiden, Strategic Business Systems

Search for a product by description

Page 66: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 66Alan Seiden, Strategic Business Systems

Select a product

Page 67: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 67Alan Seiden, Strategic Business Systems

Help!

Page 68: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 68Alan Seiden, Strategic Business Systems

What Allied wanted in web-based order entry

• Good for sales reps and customers Keep speed while making it easier for newcomers Reps can copy from past orders Lots of information at fingertips (fewer clicks)

• Users can save drafts of orders Drafts are brand-new functionality We use the old RPG logic, but we’re not tied to it

• No problem if temporarily disconnected Stateless web connection can easily resume later

• Overcome 90-item limit So we didn’t have to treat that as an error Internally we split order into 90-item bunches and sent multiple orders to RPG

Page 69: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 69Alan Seiden, Strategic Business Systems

Web ordering intro page

Page 70: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 70Alan Seiden, Strategic Business Systems

Web with account type/search box

Page 71: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 71Alan Seiden, Strategic Business Systems

Web Mode #1: Quick Order Entry

Page 72: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 72Alan Seiden, Strategic Business Systems

Search results

Page 73: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 73Alan Seiden, Strategic Business Systems

Web Mode #2: Standard Order Entry

Page 74: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 74Alan Seiden, Strategic Business Systems

AJAX technology (javascript) loads dynamic info

Page 75: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 75Alan Seiden, Strategic Business Systems

Usability tipsUsability tips

Page 76: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 76Alan Seiden, Strategic Business Systems

Check error messages for user friendliness

• Don’t assume users are experts

• Old style “CODE NOT ON FILE”

• New style “We’re sorry, but the warranty code you entered was not valid.” (Better: provide a lookup to avoid errors)

• Old style “WARNING-LIMIT EXCEEDED”

• New style “You entered more than the maximum number of line items (100).” (Better: find a way to allow more items, perhaps by calling the old

RPG program once for each 100 you need to process.)

Page 77: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 77Alan Seiden, Strategic Business Systems

Graphical appeal = usability and “sizzle”

• Need HTML skills or know someone who does

• Borrow from: your corporate logos or graphics sites that you like

• Use “View Source” command in browser

• Use Photoshop, Snagit, or other graphic programs

• Match colors for instant professional look See next slide for a tip

Page 78: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 78Alan Seiden, Strategic Business Systems

Colorzilla for Firefox (free)

• https://addons.mozilla.org/en-US/firefox/addon/271

Page 79: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 79Alan Seiden, Strategic Business Systems

Now itNow it’’s your turns your turn

Page 80: blog: email: aseiden@sbsusa.com ... slides/PHP-case-study-on...Zend Studio IBM, Oracle Endorse PHP Zeev Suraski & Andi Gutmans lead the development of PHP 3 PHP s growth as web dev

5250 to Web: PHP Case Study on IBM i | | 80Alan Seiden, Strategic Business Systems

Questions?

To receive free PHP/i tips by email, write to [email protected] with subject: “PHP tips.”

Alan [email protected], 201-327-9400, http://alanseiden.com