Skip to main content  
        iSeries home   |   Easy400  
Freeware
 
 
Introduction
About it
Prerequisites
Installation
Operation
Notes
Updates
FAQ
User Guide
 PFF
 
 Download
 
 

 
CGI_WRKDBF  
Preset Filter Feature (PFF)
  • 1-About it
  •  
  • 4-Using a query string
  • 2-Operations allowance flags
  • 5-Using a CL program
  • 3-An HTML example


  • 1-About it
    In a WEB page of yours, you may post an HTML <form> to run a special WRKDBF page filtering the records of a given database that meet a given field comparison with a given value.
    All WRKDBF features (such as filter change, record updates and record additions) are available.

    The HTML <form> must specify

    • the method and the action needed to invoke the WRKDBF program, example:
      <form name="go" method="post" action="http://.../cgiwrkdbfp/wrkdbf.pgm">
      where ... is the host name or host IP address (followed, if needed, by : and a port number)
    • the following HTML hidden fields:
      <input type="hidden" name="xFeature" value="PFF">
      <input type="hidden" name="xfilename" value="..."> where ... is the database file name
      <input type="hidden" name="xfilelib" value="..."> where ... is the database file library name
      <input type="hidden" name="xfilembr" value="..."> where ... is the database file member name
      <input type="hidden" name="xftrfld" value="..."> where ... is the name of the field to be compared
      <input type="hidden" name="xftropr" value="..."> where ... is the comparison operator (*EQ, *NE, *LT, *LE, *GT, or *GE)
      <input type="hidden" name="xftrval" value="..."> where ... is the comparison value
      <input type="hidden" name="xaspgrp" value="..."> where ... is the IASP group name or *NONE
      <input type="hidden" name="xtabw" value="..."> where ... is the width of the records table in pixel (example: 800)
      <input type="hidden" name="xtabh" value="..."> where ... is the height of the records table in pixel (example: 200)
      <input type="hidden" name="xrecsinpage" value="..."> where ... is the number of rows in a table page (example: 100)
      <input type="hidden" name="xallow" value="..."> where ... are the record operations allowed/inhibited, see the next topic.


    2-Operations allowance flags
    Besides displaying data base records, WRKDBF allows four more possible operations:
    1. Update existing records
    2. Add new records
    3. Delete existing records
    4. Remove a predefined record filtering and add your own one.
    These operations are enabled/disabled by passing a 4-character input parameter named xallow.
    Each of the four characters can have either value "1" or value "0".
    Value "1" enables an operation, value "0" disables it:
    Char numberValue "1"Value "2"
    1allows updateinhibits update
    2allows addinhibits add
    3allows deleteinhibits delete
    4allows filter maintenanceinhibits filter maintenance
    Example: the following
    <input type="hidden" name="xallow" value="1010">
    just allows records update and records delete.
    Default values of input variable xallow:
    1. When not using PFF: all operations allowed (value="1111")
    2. When using PFF: no operation allowed (value="0000")


    3-An HTML example

    In order to get some practice with this FFT feature, we provide an HTML example that you may run with the URL
    http://.../cgiwrkdbf/html/testPFF.html .
    It runs PFF allowing just the record update operation.
    We suggest that you display the HTML source of this page to see the <form> used. You may want to copy-paste it into some HTML page of yours and customize it to your needs.

    4-Using a query string
    If your HTML knowledge is not that much, instead of using a <form> ... </form> HTML script to dynamically invoke a special record filtering WRKDBF, you may use a URL followed by a query string.
    You could for instance run the above example with the following URL:
    http://www.easy400.net/cgiwrkdbfp/wrkdbf.pgm?xFeature=PFF&xfilename=CATALOG_K&xfilelib=CGIWRKDBFD&xfilembr=*FIRST&xftrfld=CTGPRICE&xftropr=*GT&xftrval=50&xallow=1010&xaspgrp=*NONE&xtabw=800&xtabh=200&xrecsinpage=100.
    (replace "www.easy400.net" with the IP address of your IBM i)
    However, you should be aware of the following when using this technique:

    • The query string can be easily modified by the WEB user, who could for instance change the database file and/or the filter.
    • Each WEB browser has its own maximum query string length
    • Spaces and special characters in the parameter values must be properly encoded, see page https://www.w3schools.com/tags/ref_urlencode.ASP.


    5-Using a CL program
    Another way to invoke a special record filtering WRKDBF is to use a CLLE program that sets the input variables as environment variables.
    It requires no HTML knowledge and has none of the disadvantages lidted for the "query string" approach.
    Member ENVAR_SAMP in CGIWRKDBF/QCLSRC demonstrates how this can be done in order to execute the special record filtering WRKDBF example.
    Here is the source of that CLLE program:
    /*============================================================================*/
    /* How to invoke record filtering WRKDBF using environment variables          */
    /*                                                                            */
    /* Run it on CGIWRKDBF http instance (port 8015)                              */
    /* with URL                                                                   */
    /* http://...:8015/cgiwrkdbfp/envar_samp.pgm                                  */
    /*                                                                            */
    /* CRTPGM PGM(CGIWRKDBF/ENVAR_SAMP) MODULE(CGIWRKDBF/ENVAR_SAMP)              */
    /*         BNDDIR(CGIWRKDBF/CGIWRKDBF)                                        */
    /*============================================================================*/
                 PGM
                 DCL        VAR(&ENVSTR) TYPE(*CHAR) LEN(100) /* +
                              Environment variable string */
                 DCL        VAR(&ENVSTRLEN) TYPE(*INT) LEN(2)
                 DCL        VAR(&ENVSTRV) TYPE(*CHAR) LEN(102) /* +
                              Environment variable Variable_length +
                              string */
                 DCL        VAR(&ERRCODE) TYPE(*CHAR) LEN(516)
    /* Put environment variable CGIWRKDBF_XFEATURE                                */
                 CHGVAR     VAR(&ENVSTR) +
                              VALUE('CGIWRKDBF_XFEATURE=PFF')
                 CHGVAR     VAR(&ENVSTRLEN) VALUE(22)
                 CHGVAR     VAR(%BIN(&ENVSTRV 1 2)) VALUE(&ENVSTRLEN)
                 CHGVAR     VAR(%SST(&ENVSTRV 3 100)) VALUE(&ENVSTR)
                 CALLPRC    PRC(PUTENV) PARM((&ENVSTRV) (&ERRCODE))
    /* Put environment variable CGIWRKDBF_XFILENAME                               */
                 CHGVAR     VAR(&ENVSTR) +
                              VALUE('CGIWRKDBF_XFILENAME=CATALOG_K')
                 CHGVAR     VAR(&ENVSTRLEN) VALUE(30)
                 CHGVAR     VAR(%BIN(&ENVSTRV 1 2)) VALUE(&ENVSTRLEN)
                 CHGVAR     VAR(%SST(&ENVSTRV 3 100)) VALUE(&ENVSTR)
                 CALLPRC    PRC(PUTENV) PARM((&ENVSTRV) (&ERRCODE))
    /* Put environment variable CGIWRKDBF_XFILELIB                                */
                 CHGVAR     VAR(&ENVSTR) +
                              VALUE('CGIWRKDBF_XFILELIB=CGIWRKDBFD')
                 CHGVAR     VAR(&ENVSTRLEN) VALUE(30)
                 CHGVAR     VAR(%BIN(&ENVSTRV 1 2)) VALUE(&ENVSTRLEN)
                 CHGVAR     VAR(%SST(&ENVSTRV 3 100)) VALUE(&ENVSTR)
                 CALLPRC    PRC(PUTENV) PARM((&ENVSTRV) (&ERRCODE))
    /* Put environment variable CGIWRKDBF_XFILEMBR                                */
                 CHGVAR     VAR(&ENVSTR) +
                              VALUE('CGIWRKDBF_XFILEMBR=*FIRST')
                 CHGVAR     VAR(&ENVSTRLEN) VALUE(30)
                 CHGVAR     VAR(%BIN(&ENVSTRV 1 2)) VALUE(&ENVSTRLEN)
                 CHGVAR     VAR(%SST(&ENVSTRV 3 100)) VALUE(&ENVSTR)
                 CALLPRC    PRC(PUTENV) PARM((&ENVSTRV) (&ERRCODE))
    /* Put environment variable CGIWRKDBF_XFTRFLD                                 */
                 CHGVAR     VAR(&ENVSTR) +
                              VALUE('CGIWRKDBF_XFTRFLD=CTGPRICE')
                 CHGVAR     VAR(&ENVSTRLEN) VALUE(29)
                 CHGVAR     VAR(%BIN(&ENVSTRV 1 2)) VALUE(&ENVSTRLEN)
                 CHGVAR     VAR(%SST(&ENVSTRV 3 100)) VALUE(&ENVSTR)
                 CALLPRC    PRC(PUTENV) PARM((&ENVSTRV) (&ERRCODE))
    /* Put environment variable CGIWRKDBF_XFTROPR                                 */
                 CHGVAR     VAR(&ENVSTR) +
                              VALUE('CGIWRKDBF_XFTROPR=*GT')
                 CHGVAR     VAR(&ENVSTRLEN) VALUE(21)
                 CHGVAR     VAR(%BIN(&ENVSTRV 1 2)) VALUE(&ENVSTRLEN)
                 CHGVAR     VAR(%SST(&ENVSTRV 3 100)) VALUE(&ENVSTR)
                 CALLPRC    PRC(PUTENV) PARM((&ENVSTRV) (&ERRCODE))
    /* Put environment variable CGIWRKDBF_XFTRVAL                                 */
                 CHGVAR     VAR(&ENVSTR) +
                              VALUE('CGIWRKDBF_XFTRVAL=50')
                 CHGVAR     VAR(&ENVSTRLEN) VALUE(20)
                 CHGVAR     VAR(%BIN(&ENVSTRV 1 2)) VALUE(&ENVSTRLEN)
                 CHGVAR     VAR(%SST(&ENVSTRV 3 100)) VALUE(&ENVSTR)
                 CALLPRC    PRC(PUTENV) PARM((&ENVSTRV) (&ERRCODE))
    /* Put environment variable CGIWRKDBF_XALLOW                                  */
                 CHGVAR     VAR(&ENVSTR) +
                              VALUE('CGIWRKDBF_XALLOW=1010')
                 CHGVAR     VAR(&ENVSTRLEN) VALUE(21)
                 CHGVAR     VAR(%BIN(&ENVSTRV 1 2)) VALUE(&ENVSTRLEN)
                 CHGVAR     VAR(%SST(&ENVSTRV 3 100)) VALUE(&ENVSTR)
                 CALLPRC    PRC(PUTENV) PARM((&ENVSTRV) (&ERRCODE))
    /* Put environment variable CGIWRKDBF_XASPGRP                                 */
                 CHGVAR     VAR(&ENVSTR) +
                              VALUE('CGIWRKDBF_XASPGRP=*NONE')
                 CHGVAR     VAR(&ENVSTRLEN) VALUE(23)
                 CHGVAR     VAR(%BIN(&ENVSTRV 1 2)) VALUE(&ENVSTRLEN)
                 CHGVAR     VAR(%SST(&ENVSTRV 3 100)) VALUE(&ENVSTR)
                 CALLPRC    PRC(PUTENV) PARM((&ENVSTRV) (&ERRCODE))
    /* Put environment variable CGIWRKDBF_XTABW                                   */
                 CHGVAR     VAR(&ENVSTR) +
                              VALUE('CGIWRKDBF_XTABW=800')
                 CHGVAR     VAR(&ENVSTRLEN) VALUE(19)
                 CHGVAR     VAR(%BIN(&ENVSTRV 1 2)) VALUE(&ENVSTRLEN)
                 CHGVAR     VAR(%SST(&ENVSTRV 3 100)) VALUE(&ENVSTR)
                 CALLPRC    PRC(PUTENV) PARM((&ENVSTRV) (&ERRCODE))
    /* Put environment variable CGIWRKDBF_XTABH                                   */
                 CHGVAR     VAR(&ENVSTR) +
                              VALUE('CGIWRKDBF_XTABH=200')
                 CHGVAR     VAR(&ENVSTRLEN) VALUE(19)
                 CHGVAR     VAR(%BIN(&ENVSTRV 1 2)) VALUE(&ENVSTRLEN)
                 CHGVAR     VAR(%SST(&ENVSTRV 3 100)) VALUE(&ENVSTR)
                 CALLPRC    PRC(PUTENV) PARM((&ENVSTRV) (&ERRCODE))
    /* Put environment variable CGIWRKDBF_XRECSINAPAGE                            */
                 CHGVAR     VAR(&ENVSTR) +
                              VALUE('CGIWRKDBF_XRECSINAPAGE=100')
                 CHGVAR     VAR(&ENVSTRLEN) VALUE(26)
                 CHGVAR     VAR(%BIN(&ENVSTRV 1 2)) VALUE(&ENVSTRLEN)
                 CHGVAR     VAR(%SST(&ENVSTRV 3 100)) VALUE(&ENVSTR)
                 CALLPRC    PRC(PUTENV) PARM((&ENVSTRV) (&ERRCODE))
    
    /* Call program WRKDBF                                                        */
                 CALL       PGM(CGIWRKDBF/WRKDBF)
    
                 RETURN
                 ENDPGM