The 5250 Bridge API is a more
flexible implementation of the Emulator's capabilities which allows you
to access and customize the PHP/CSS and JavaScript code (also used by
the emulator) to create additional functionality.
This is suitable for users who want to make cosmetic changes to their application
and apply some additional display logic. In addition, users can choose
to remove or filter out content/data for a subset of end-users (e.g. redundant
fields) or even pipeline the data coming from the bridge for usage in
other, non browser applications (Java, Web Services, others.). Also suitable
for users who expect to continue significant development of their RPG
5250 applications and want to minimize their Parallel Maintenance considerations.
The 5250 Bridge API offers a number of functions/classes for PHP developers to grab fields and strings from an interactive (5250) program and wrap them into real web applications. This way you can seamlessly integrate output of green screen applications into your PHP Web application without the need to rewrite the business logic and directly access the database. Alternatively you can use the 5250 Bridge API to directly access the database and create completely new Web applications (e.g. omit certain fields or integrate fields from different screens into one).
The 5250 Bridge APIs have two interfaces: object oriented and procedural functions. If a developer is not comfortable using object oriented (class access) methods in PHP he can use regular procedural functions to access the same APIs.
The 5250 Bridge API accessed information in your 5250 application's input/output fields and allows you to use this information to 'transform' your application in PHP and HTML, while still using your 5250 back-end logic.
The Zend 5250 Bridge API has the following purposes:
Starting an interactive job or 5250 session.
Running IBM i interactive program or menu in an interactive job..
Accessing 5250 screen data such as screen size, input/output field values, size, location and attributes.
Updating input-field value content.
Sending updated input-fields to an interactive job.
Sending a function-key action to an interactive job.
To see examples of how the 5250 Bridge API can be used to web-enable your 5250 application, see the Working with the Demo Applications.
There are three ways of discovering the field ID's used in your application:
Using the 'hover' function
in the emulator demo.
Run the Zend 5250 Emulator. Hovering
over the fields will display the field ID.
Using the 'Show XML code'
option in the Emulator demo.
Clicking the Show XML button will display... containing the field array
structure.
Using 5250 Bridge API
functions such as 'zend_5250_get_input_fields' and 'zend_5250_get_output_fields'
in your PHP program.
This will perform a 'screen dump' of the XML information for a screen,
which can then be used to write code for the next screen.
When writing a PHP application, you must first include the 5250 Bridge PHP API library in your code in order to be able to use the 5250 API functions.
This example shows the include code for 5250 Bridge PHP API procedural functions:
set_include_path ('/usr/local/zendsvr/5250/API/' );
require_once ('Zend/ProceduralApi.php');
This example shows the include code for 5250 Bridge PHP API classes:
set_include_path ('/usr/local/zendsvr/5250/API/' );
require_once ('Zend/5250.php');
Developing using the Zend 5250 Bridge API then involves using the input and output field data from your 5250 application screens and setting an appropriate function-key action. Each field has an id number and certain characteristics such as row column and attributes.
In order to use this screen information in your PHP Program, you must first examine the fields by using 5250 Bridge API functions such as 'zend_5250_get_input_fields' and 'zend_5250_get_output_fields' in your PHP program.
For example, start with code which:
<?php
set_include_path('/usr/local/zendsvr/5250/API/');
require_once('Zend/ProceduralApi.php');
// Opens a 5250 session
$bridge = Zend_5250_open ( 'simple' );
$response = @zend_5250_connect($bridge);
// Get the 5250 screen output fields for the IBM i login screen
$outputFields = zend_5250_get_output_fields($response);
// Print the output fields information
echo "<pre>";
print_r($outputFields);
echo "<pre>";
// End the 5250 session
zend_5250_disconnect($bridge);
?>
Notes:
The Zend 5250 Bridge without a valid Zend Server for IBMi license will enable
a single connection at a time. Therefore, ensure you close the 5250 Bridge
connection at the end of a program by using the zend_5250_disconnect()
function.
Running this code will launch your IBM i connection screen and display
the array structure information for this screen as follows (the following
information is only partial):
Array
(
[0] => Array
(
[id] => 0
[row] => 1
[column] => 23
[length] => 33
[value] => Sign On
[color] => 3
)
[1] => Array
(
[id] => 1
[row] => 2
[column] => 48
[length] => 19
[value] => System . . . . . :
[color] => 1
)
[2] => Array
(
[id] => 2
[row] => 2
[column] => 70
[length] => 8
[value] => I5QA2
[color] => 1
)
[3] => Array
(
[id] => 3
[row] => 3
[column] => 48
[length] => 19
[value] => Subsystem . . . . :
[color] => 1
)
[4] => Array
(
[id] => 4
[row] => 3
[column] => 70
[length] => 10
[value] => QINTER
[color] => 1
)
[5] => Array
(
[id] => 5
[row] => 4
[column] => 48
[length] => 19
[value] => Display . . . . . :
[color] => 1
)
[6] => Array
(
[id] => 6
[row] => 4
[column] => 70
[length] => 10
[value] => QQF048FE62
[color] => 1
)
[7] => Array
(
[id] => 7
[row] => 6
[column] => 17
[length] => 33
[value] => User . . . . . . . . . . . . . .
[color] => 1
)
[8] => Array
(
[id] => 8
[row] => 7
[column] => 17
[length] => 33
[value] => Password . . . . . . . . . . . .
[color] => 1
)
[9] => Array
(
[id] => 9
[row] => 8
[column] => 17
[length] => 33
[value] => Program/procedure . . . . . . . .
[color] => 1
)
[10] => Array
(
[id] => 10
[row] => 9
[column] => 17
[length] => 33
[value] => Menu . . . . . . . . . . . . . .
[color] => 1
)
[11] => Array
(
[id] => 11
[row] => 10
[column] => 17
[length] => 33
[value] => Current library . . . . . . . . .
[color] => 1
)
[12] => Array
(
[id] => 12
[row] => 24
[column] => 40
[length] => 40
[value] => (C) COPYRIGHT IBM CORP. 1980, 2005.
[color] => 3
)
)
Using the array structure information displayed for the input and output fields, you can then write further code utilizing the Zend 5250 Bridge API. You can either create HTML browser based screens for user input, or automatically continue running the 5250 application by setting input field values and sending the function key actions.
You must then get array structure information for the next screen in order to continue developing.
For example, the following code will start a 5250 sess5sion, log you in to the IBM i system and display array structure information for the next screen:
<?php
set_include_path('/usr/local/zendsvr/5250/API/');
require_once('Zend/ProceduralApi.php');
// Opens a 5250 session
$bridge = Zend_5250_open ( 'simple' );
$response = @zend_5250_connect($bridge);
// Sets and submits username and password for the IBM i login screen
zend_5250_set_input_field ( $bridge, 0, 'Z5250DEMO' );
zend_5250_set_input_field ( $bridge, 1, 'Z5250DEMO' );
$response = zend_5250_submit ( $bridge );
// Get the 5250 screen output fields for the IBM i login screen
// Gets arrays structure information from the next screen
$outputFields = zend_5250_get_output_fields($response);
$inputFields = zend_5250_get_input_fields($response);
// Print the output fields information
echo "<pre>";
print_r($outputFields);
echo "<pre>";
// Print the input fields information
echo "<pre>";
print_r($inputFields);
echo "<pre>";
// End the 5250 session
zend_5250_disconnect($bridge);
?>
You will need to repeat this process to get and use field array structure information for each 5250 screen in your PHP application.
There is an additional way a developer can identify the 5250 screen
field type (input/output) and field id.
Run an interactive (5250) application using the 5250 Bridge Emulator program.
Place the cursor on a screen location where you want to know the screen
type and screen id.
For example, in the screen below the cursor is placed on '2.Office tasks' location and the 5250 Bridge emulator program shows that this is an output field and its id is 7.
FLD_06_007. where 06 is a field row and 007 is a field starting colum7.
Identifying 5250 Screen Field Types
See the 5250 Demo Applications included with the 5250 Bridge for further examples on writing applications using the 5250 Bridge API. For example, to see the code for the 'subfile' demo application go to: /usr/local/zend/5250/demos/subfile/index.php. For more sample code, refer to Zend 5250 Bridge Use Case Examples.
Note:
The 5250 Bridge installation includes two Java Script files to catch function key clicks. You can find more information in the Zend installation folder: /usr/local/zendsvr/5250/demos/ JSfunctionKeyListener on your System i server.
|
|
|
Related Links: |
|
|
© 1999-2013 Zend Technologies, Ltd. All rights reserved.