Step 3a. Create WAM to Display Employee Documents
Follow this step if you did not set up documents for an employee using the demonstration VLF application, in the file DXDOCS.
This WAM will display a fixed list of documents for an employee, based on a data from a supplied text file. To simplify building the list of documents, the WAM reads a text file MYDOCS.txt to populate a working list. Another working list is populated for display. A later step will add another column to this list which will contain a clickable image.
1. Create a new WAM:
Name:iiiDspEmpDocs
Description:Display Employee Documents
Layout Weblet:iiilay01
2. Create your WAM based on the following logic:
- Map field STDRENTRY for *both as a *hidden field
- Define a Group_By, EMPDATA for fields, EMPNO, SURNAME, GIVENAME, ADDRESS1, ADDRESS2, ADDRESS3, POSTCODE, DEPTMENT and SECTION.
- Define a working list DOCLIST containing fields DF_ELFNAM
- Define a working list MYDOCS containing field STD_TEXTL
- Define a work field RETCODE with reference field IO$STS
- Define a webroutine BEGIN
- Map field EMPNO for *both
- Map fields FULLNAME, ADDRESS1, ADDRESS2, ADDRESS3, POSTCODE, DEPTMENT and SECTION for *output. All fields should have a display attribute of *output
- If STDRENTRY = S
- Clear list DOCLIST
- Clear list MYDOCS
- Fetch group_by EMPDATA from file PSLMST with the key EMPNO
- Use the BIF transform_file to populate the list MYDOCS from the file "C:\Program Files (x86)\LANSA\MYDOCS.txt"
- Selectlist MYDOCS
- Change DF_ELFNAM to STD_TEXTL
- Add an entry to DOCLIST
- Endselect
- Endif
3. Define a WebRoutine SEND_DOCUMENT with a Response keyword of #HTTPR
- Map field DF_ELFNAM for *input
- Set #HTTPR, property ContentFile to "C:\Program Files (x86)\LANSA\" + DF_ELFNAM
- Endroutine
Sample code is supplied in WAM095. Appendix B.
4. Compile your WAM. Open the WebRoutine BEGIN in the Design view, it should look like the following:
5. Drop a Push Button weblet alongside the employee number field.
Set up the push button properties:
|
6. Save your changes.
7. Select the column heading "Document long file" and delete it.
Type in a new column heading - Employee Documents.
You may need to click on another part of the layout to refresh the column heading.
8. Drop an Anchor weblet into the list's file name column. Ignore the increase in width of the column. At run time it will be displayed with the width of the actual file names.
Set up the Anchor weblet properties:
|
Your design should look like the following:
9. Save your changes.
10. Execute your WAM in the browser. Any employee number may be entered (A0070, A0090, A1234 etc). The WAM will always display the employee details and a fixed list of documents.
Click on one of the documents to display it. The way that the browser and Windows handles the request will depend on the version of browser and the version of Windows being used. For example, in Windows 7 with MS Office installed and IE10, the txt and pdf files are displayed in a new browser tab. The Office documents prompt to be displayed in the required Office program.
Continue with Step 4. Enhance Appearance of the Documents List (Optional)