| |
How to Use the Search Option in mrc Generated CGI Retrievals |
| by Margaret Jeronim |
|
| |
|
Not that long ago, mrc introduced a new template update that allows unlimited substitutions within RPG/CGI inquiries. By specifying A in 'User defined field' under option 5 (Preformat), you're able to include a list of quick links, from A-Z, for an alphanumeric search in multiple record retrievals.
Follow these steps for creating a new application:
- Create a new inquiry (retrieval) application.
- Sequence by the alphanumeric key field (Salesman Name in our example).
- In option 5 (Preformat) select your key field and put 2 (Update) in that field. Specify A under 'User defined field control:' (see screen shot below).
- In option 7 (Client/Server) select Create Retrieval Y and choose R8 (Web/CGI) Multiple Record Inquiry template.
- Compile your application.
- Access you retrieval from the browser.

You will notice a bar of quick links from A to Z across the page right below the application heading. (see Salesman Search below). When you click on any of these letters, you will be able to see records corresponding to that particular letter. The application will reposition itself to the record specified by the selected letter (if records for a specified letter do not exist, the retrieval will reposition to the closest record to the selected letter that it can find).
Salesman Search by Name

The HTML source code for that application includes additional code that was generated when you specified A in the 'User defined field'. The code is placed right after the application heading (it appears after <h1> </h1> tags).
<!-- A to Z links -->
<table border="0" width="100%">
<tr>
<td align="center">
<a href="I01500GC.mrc">Start
<a href="I01500GC.mrc?K001=A">A
<a href="I01500GC.mrc?K001=B">B
<a href="I01500GC.mrc?K001=C">C
<a href="I01500GC.mrc?K001=X">X
<a href="I01500GC.mrc?K001=Y">Y
<a href="I01500GC.mrc?K001=Z">Z
</td>
</tr>
</table>
As you can see retrieval application I01500 is linked to itself multiple times. Each time a different letter is passed to the application. This allows the application to position itself based on the selected letter.
This generated code can be used as a guideline for adding a bar of quick links to any CGI multiple record retrieval application that you have already created. This is helpful if you have an application in production and you would like to add bar of links for a quick search without re-compiling the source.
For existing CGI applications that are in production or already painted to suit your business specifications please study the following example.
Let's assume that you have an application that is a Product Look-Up. It is sequenced by Product Class, which, in this case, is an alphanumeric field of size 3. You may have many products that belong to a specific class, but only few classes. If you want to prevent users from entering incorrect class numbers, instead allow them to select them from the menu bar above the table. The way the search feature works is that the application (I01475 in this case) is linked to itself multiple times and each time it is linked, it is passing a different value (K001=100, K001=200, K001=300, etc, where K001 is key field representing Product Class). Each time a new link is specified, the same value is displayed on the line as a link that you can select. The number of links displayed on the bar corresponds with the number of valid product classes that you may have in your file.
See the example below:
Product Class Look-Up

In order to include the links in the example above, the following code was added to the HTML source of the retrieval.
It was added right below the <h1> </h1> tags.
<h1>Product Class Look-Up </h1>
<!-- Product Class Links -->
<table border="0" width="100%">
<tr>
<td align="center">
<a href="I01475GC.mrc">Start
<a href="I01475GC.mrc?K001=100">100
<a href="I01475GC.mrc?K001=200">200
<a href="I01475GC.mrc?K001=300">300
<a href="I01475GC.mrc?K001=400">400
<a href="I01475GC.mrc?K001=500">500
<a href="I01475GC.mrc?K001=600">600
<a href="I01475GC.mrc?K001=800">800
<a href="I01475GC.mrc?K001=900">900
</td>
</tr>
</table>
A similar approach can be used in a Web/Servlet retrieval application. You can add code to the generated HTML source to include a list of quick links. (See the example below). Since 'A' as 'User defined field' is not available in Servlets, modifying the HTML source is the only option available to include a list of quick links in the retrieval.
Search By Product Number

The code below shows the syntax of a servlet application that is linked to itself and passes a different value each time. This code looks a little different than the one that is used for CGI applications.
<H1>Search by Product#
<!-- Links for Product Classes -->
<table border="0" width="100%">
<tr>
<td align="center">
<a href="MRCEDUCATE.I01465s">Start
<a href="MRCEDUCATE.I01465s?PRDNO=A1000">A1000
<a href="MRCEDUCATE.I01465s?PRDNO=B1000">B1000
<a href="MRCEDUCATE.I01465s?PRDNO=C0010">C0010
<a href="MRCEDUCATE.I01465s?PRDNO=D1010">D1010
<a href="MRCEDUCATE.I01465s?PRDNO=L0100">L0100
</td>
</tr>
</table>
This month’s technical article is a contribution from Margaret Jeronim, an mrc-Productivity Series and Web application expert.
|
|
 |
mrc publishes this newsletter on a monthly basis. Subscription is free of charge. Please send any questions or comments about this newsletter to news@mrc-productivity.com. This newsletter is edited by Heather Gately.
To unsubscribe, please just reply to this e-mail with Unsubscribe in the subject line.
View our privacy promise.
|
 |
|