Step 1. Output Employee Enquiry to a File
This exercise uses a simple enquiry WAM. When running in the browser, an employee number is requested via WebRoutine begin. A second WebRoutine details is invoked which displays employee data.
Using X_RUN the details WebRoutine is invoked, passing employee number as a parameter on the X_RUN, the web page containing data for the requested employee can be written to a file.
To execute a WAM, the parameters required by the X_RUN command for Windows are as follows:
Argument |
Value |
PROC |
*WAMSP is the value to activate the "output to file" function |
WMOD |
WAM Name |
WRTN |
WebRoutine Name |
WAML |
Mark up language, e.g. LANSA:HTML |
PART |
Partition |
LANG |
Language, e.g ENG |
USER |
User. Optional for some platforms |
WASP |
Output file path where the output will be saved. Format depends on platform. e.g. for Windows c:\temp\wam_output.html |
The format of the X_RUN command for Windows is:
X_RUN PROC=*WAMSP WMOD=IIIEmpEnqToFile WRTN=DETAILS . . . . etc.
The X_RUN command does not have a parameter to input a field and value, but its does have a user defined parameter UDEF, which is a 256 long character field. If the UDEF parameter is used, the WebRoutine will require a simple modification to retrieve the UDEF value using the Built-in Function GET_SESSION_VALUE. If the value returned by the BIF is non blank, the DETAILS WebRoutine can retrieve employee data using the session value as employee number.
1. Create a new Employee Enquiry WAM by copying the following code.
Name: iiiEmpEnqToFile
Description: Employee Enquiry to File
Layout Template: iiilay01
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_WAM)
Group_By Name(#empgroup) Fields((#SURNAME *OUT) (#GIVENAME *OUT) (#ADDRESS1 *OUT) (#ADDRESS2 *OUT) (#ADDRESS3 *OUT) (#POSTCODE *OUT) (#PHONEHME *OUT) (#PHONEBUS *OUT) (#DEPTMENT *OUT) (#SECTION *OUT) (#SALARY *OUT) (#STARTDTE *OUT) (#TERMDATE *OUT))
Webroutine Name(begin) Desc('Select Employee')
Web_Map For(*output) Fields(#empno)
Endroutine
Webroutine Name(DETAILS) Desc('Employee Details')
Web_Map For(*BOTH) Fields((#EMPNO *OUTPUT))
Web_Map For(*OUTPUT) Fields(#empgroup)
Fetch Fields(#empgroup) From_File(PSLMST) With_Key(#EMPNO) Val_Error(*NEXT)
If_Status Is_Not(*OKAY)
Message Msgtxt('Employee not found')
Endif
Endroutine
End_Com
2. Add logic to the details WebRoutine to retrieve session value and if non blank, use as employee number.
Add the following code in WebRoutine details, immediately before the FETCH command.
Define Field(#retcode) Type(*char) Length(2)
Use Builtin(get_session_value) With_Args(UDEF) To_Get(#STD_QSEL #retcode)
If (#std_qsel *NE *blanks)
#empno := #std_QSEL.trim
Endif
3. Compile your WAM.
4. Open the begin WebRoutine in the design view.
a. Add a right hand column to the table containing employee number.
b. Drag and drop a push button weblet into the new column.
c. Change the caption to Select.
d. Set the push button on_click_wrname property to invoke the Details WebRoutine.
e. The submitExtraFields property does not need to be specified.
f. Remove the place holder characters.
g. Save your changes.
5. Run the begin WebRoutine in the browser and ensure that the details WebRoutine executes normally when invoked from the begin web page. Enter an employee number such as A0090, A0070 or A1001.