Step 6 Create form iiiFRM02 Get Employees using SOAP

LANSA Integrator

Step 6. Create form iiiFRM02 - Get Employees using SOAP

INT010B - SOAP Service - Define Agent

This is a very simple form into which the user enters a department and section code and clicks a button labelled Get Employees.

The program then displays a list of employees for that department and section. The visual design of the form is as follows:

1.  In the LANSA Editor, from the File menu, create New / Basic Form,  iiiFRM02 – Get Employees using SOAP. Create the form as RDMLX enabled.

     Copy and paste the following code into the form:

Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Clientheight(460) Clientwidth(476) Height(494) Left(261) Top(120) Width(484)
Define Field(#MSGDTA) Type(*CHAR) Length(132)
Override Field(#empno)
Override Field(#surname)
Override Field(#givename)
Override Field(#salary)
Define_Com Class(#DEPTMENT.Visual) Name(#IN_DEPT) Displayposition(1) Height(19) Left(7) Parent(#COM_OWNER) Tabposition(1) Top(21) Usepicklist(False) Width(201)
Define_Com Class(#SECTION.Visual) Name(#IN_SECT) Displayposition(2) Height(19) Left(7) Parent(#COM_OWNER) Tabposition(2) Top(48) Usepicklist(False) Width(185)
Define_Com Class(#PRIM_PHBN) Name(#phbnGetEmployees) Caption('Get Employees') Displayposition(3) Left(240) Parent(#COM_OWNER) Tabposition(3) Top(45) Width(225)
Define_Com Class(#PRIM_LTVW) Name(#empList) Componentversion(2) Displayposition(4) Fullrowselect(True) Height(345) Left(7) Parent(#COM_OWNER) Showsortarrow(True) Tabposition(4) Top(88) Width(461)
Define_Com Class(#PRIM_LVCL) Name(#empList_1) Caption('Code') Captiontype(Caption) Displayposition(1) Parent(#empList) Source(#EMPNO)
Define_Com Class(#PRIM_LVCL) Name(#empList_2) Caption('Surname') Captiontype(Caption) Displayposition(2) Parent(#empList) Source(#SURNAME) Width(24)
Define_Com Class(#PRIM_LVCL) Name(#empList_3) Caption('Given Name') Captiontype(Caption) Displayposition(3) Parent(#empList) Source(#GIVENAME) Width(27)
Define_Com Class(#PRIM_LVCL) Name(#empList_4) Caption('Salary') Captiontype(Caption) Displayposition(4) Parent(#empList) Source(#SALARY)
Define_Com Class(#PRIM_STBR) Name(#STBR_1) Displayposition(5) Height(24) Left(0) Messageposition(1) Parent(#COM_OWNER) Tabposition(5) Tabstop(False) Top(436) Width(476)

Evtroutine Handling(#com_owner.Initialize)
Set Com(#com_owner) Caption(*component_desc)
Endroutine
*
Evtroutine Handling(#phbnGetEmployees.Click)

Endroutine
* --------------------------------------------------------------------
* Subroutine CHECK - check the JSM status after a JSM call and handle
* .                  exceptional conditions
* --------------------------------------------------------------------
Subroutine Name(CHECK) Parms((#jsmxsts *RECEIVED) (#jsmxmsg *RECEIVED))

If (#jsmxsts *NE OK)

* Close service and send the HTTP response
Use Builtin(JSMX_CLOSE) With_Args(#jsmxhdle1) To_Get(#jsmxsts #jsmxmsg)
#MSGDTA := 'Error Status Code: ' + #JSMXSTS
Message Msgid(DCM9899) Msgf(DC@M01) Msgdta(#MSGDTA)
#MSGDTA := 'Error Message: ' + #JSMXMSG
Message Msgid(DCM9899) Msgf(DC@M01) Msgdta(#MSGDTA)
Endif
Endroutine
End_Com

 

2.  In Integrator Studio open your iii SOAP Tutorial project. Locate the RDMLX code generated for your EmployeeAgent solution and open it the text editor. See file SAMPLE_RDMLX_GETEMPLOYEES.TXT.

3.  Copy all of the code between:

* The following fields are used by the soap binding map

* #DEPTMENT

. . . .

and

* Close service

USE        BUILTIN(JSMX_CLOSE) WITH_ARGS(#JSMXHDLE1) TO_GET(#JSMXSTS #JSMXMSG)

EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMXSTS #JSMXMSG)

including the code shown, into the event routine handling #phbnGetEmployees.Click in your form. This will provide most of the logic needed to call the SOAP service as described in the previous step.

4.  Examine the definition of visual fields DEPTMENT and SECTION on the form and note that they are named IN_DEPT and IN_SECT. The soaptutorial service maps these fields as variables DEPTMENT and SECTION. You need to set the value of DEPTMENT and SECTION variables before the set parameter occurs. Locate the comment lines for * set parameter – DEPARTMENTCODE and * set parameter – SECTIONCODE and add an assign statement to do this. Your code should now look like the following:

5.Locate the * Open SOAP Service comment line. Change the following line to use your SOAP service name:

* Open SOAP Service

Change Field(#JSMXCMD) To('OPEN SERVICE(IIIEMPLOYEEAGENT)') 

6.  In your form, locate the following code:

The command GET FRAGMENT(RESPONSE) SERVICE_EXCHANGE(*FIELD) will map the returned fields into your program variables. This means that within this loop, you can add entries to the list view on the form. Your completed code should look like the following:

7.  Compile your form.