ibm-information-center/dist/eclipse/plugins/i5OS.ic.apis_5.4.0.1/wfenvapi.htm

149 lines
5.7 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
<title>WebFacing Environment (QqfEnvironment) API</title>
<!-- Begin Header Records ========================================== -->
<!-- Miscellaneous API-->
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<!-- File cleanup completed 3/28/02 -->
<!-- End Header Records -->
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</head>
<body>
<!-- Java sync-link -->
<script type="text/javascript" language="Javascript" src="../rzahg/synch.js">
</script>
<a name="Top_Of_Page"></a>
<h2>Using the WebFacing Environment API (QqfEnvironment)</h2>
<p>The WebFacing Environment (QqfEnvironment) API enables you to check whether a user is
accessing your application through a Web browser or through 5250 emulation. Use
this API when you would like to change the behavior of your program according
to the type of access a user has. For example, there may be an extra field or
different text that you would like to display if your program is being accessed
through a browser, but you would like to suppress display of the field or text
if 5250 emulation is being used.</p>
<p>The WebFacing Environment API is called QqfEnvironment and is part of the
WebFacing server runtime. The external procedure name QqfEnvironment is case
sensitive. It is a procedure packaged in a service program called QQFENV that
is located in the QSYS library. The API returns 1 if the application is running
under WebFacing and 0 if it is running under 5250 emulation.</p>
<h3>Examples</h3>
<p>The following examples show how to use this API. In the RPG sample, the external
procedure QqfEnvironment is defined with the DSpec <samp>QQFENV</samp>. In this
example, the <code><samp>QQFENV</samp></code> DSpec has been given the same
name as the service program and has been defined as an integer since the
procedure returns 0 or 1. A DSpec <samp>rc</samp> has also been defined to hold
the value 0 or 1 when the <samp>Eval rc = QQFENV</samp> is performed. The RPG
progam then uses the value of <samp>rc</samp> to conditionally determine the
behaviour of the program and what will get displayed on the DDS display.</p>
<p>In the DDS sample below, if the value for <samp>rc</samp> in the RPG module
is NOT 1, the text &quot;Application is not running in the Webfacing environment&quot;
will be displayed. If the value for <samp>rc</samp> is 1, the text &quot;Application
is running in the Webfacing environment&quot; will be displayed.</p>
<p>When you are creating a program to use this API:</p>
<ol>
<li>Use the CRTRPGMOD command to create a module with your RPG code that is
calling the API. An RPG module needs to be created because it is using a
procedure not in the program.</li>
<li>When you create your program (CRTPGM) use the BNDSRVPGM keyword to bind
your RPG module with the QQFENV service program in QSYS.</li>
</ol>
<p>See <a href="../apiref/aboutapis.htm#codedisclaimer">Code disclaimer information</a>
for information pertaining to code examples.</p>
<br>
<p><strong>RPGLE sample</strong></p>
<pre>
.........1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
FCHKENVFM CF E Workstn
*
DQQFENV PR 10I 0 Extproc('QqfEnvironment')
*
Drc S 10I 0
*
C Eval rc = QQFENV
C Eval FLD001 = rc
*
C Dow NOT *IN03
*
C If rc = 1
C Eval *in01 = *on
*
C Else
C Eval *IN01 = *off
C EndIf
*
C Exfmt FMT01
C EndDo
*
C Eval *inlr = *on
</pre>
<br>
<br>
<p><strong>DDS Sample</strong></p>
<pre>
....+A*..1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
A*%%TS SD 20010924 150104 USERID REL-V4R4M0 5769-PW1
A*%%EC
A DSPSIZ(24 80 *DS3)
A R FMT01
A*%%TS SD 20010924 150104 USERID REL-V4R4M0 5769-PW1
A CA03(03)
A 1 24'Testing Webfacing Environment API'
A DSPATR(HI)
A 10 3'F3=Exit'
A COLOR(BLU)
A N01 5 13'Application is not running in the -
A Webfacing environment'
A 01 6 15'Application is running in the Webf-
A acing environment'
A COLOR(RED)
A FLD001 4S 0O 7 39
A 7 22'QqfEnvironment:'
A
A*%%GP SCREEN1 01
</pre>
<hr>
API introduced: V5R1
<hr>
<center>
<table cellpadding="2" cellspacing="2">
<tr align="center">
<td valign="middle" align="center"><a href="#top">Top</a> | <a href=
"misc1.htm">Miscellaneous APIs</a> | <a href="aplist.htm">APIs by
category</a></td>
</tr>
</table>
</center>
</body>
</html>