Using the WebFacing Environment API (QqfEnvironment)

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.

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.

Examples

The following examples show how to use this API. In the RPG sample, the external procedure QqfEnvironment is defined with the DSpec QQFENV. In this example, the QQFENV 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 rc has also been defined to hold the value 0 or 1 when the Eval rc = QQFENV is performed. The RPG progam then uses the value of rc to conditionally determine the behaviour of the program and what will get displayed on the DDS display.

In the DDS sample below, if the value for rc in the RPG module is NOT 1, the text "Application is not running in the Webfacing environment" will be displayed. If the value for rc is 1, the text "Application is running in the Webfacing environment" will be displayed.

When you are creating a program to use this API:

  1. 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.
  2. When you create your program (CRTPGM) use the BNDSRVPGM keyword to bind your RPG module with the QQFENV service program in QSYS.

See Code disclaimer information for information pertaining to code examples.


RPGLE sample

.........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


DDS Sample

....+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

API introduced: V5R1
Top | Miscellaneous APIs | APIs by category