Step 2. Create a Function using Template JSMXSKEL

INT001 - Getting Started with Basic JSM Operations

In this step, you will create a test function using the template JSMXSKEL to Open and Close the JSM and load the FTPService service.

1.  Using the LANSA development environment, sign on to the partition nominated for the exercises.

2.  Check if fields below are defined in the Repository as these fields are required for this exercise as well as others. If these fields do not exist, you must create them as follows:

3.  Create a new LANSA process named iiiPRO01 JSM Test Process, where iii is your unique 3 characters. (If the process already exists, select a different set of characters for iii.)

4.  Create a new function named iiiFN01 JSM Open/Close, belonging to process iiiPRO01. Make sure that the Enabled for RDMLX checkbox is checked. Specify that the function is to be generated from an application template (from the Template dropdown, select JSMXSKEL).

5.  Answer the template question as shown in the table below.

Question

Answer

Comments

Do you wish to load a JSM Service?

FTPSERVICE

 

 

6.  Edit your iiiFN01 function and examine the generated RDMLX code.

     The function might appear something like the following:

* ====================================================

*  Process ........:  IIIPRO01

*  Function .......:  IIIFN01

*  Created on .....:  16/07/13  at  12:19:30

*  Description ....:  Test 01

*  Template........:  JSMXSKEL

* ====================================================

Function Options(*DIRECT)

*

*  OPEN JSM AND VERIFY STATUS

Use Builtin(JSMX_OPEN) To_Get(#JSMSTS #JSMMSG #jsmxhdle1)

Execute Subroutine(CHECK_STS) With_Parms(#jsmxhdle1)

*

* BUILD THE SERVICE LOAD COMMAND

#JSMXCMD := 'SERVICE_LOAD'

Execute Subroutine(KEYWRD) With_Parms(#JSMXCMD 'SERVICE' 'FTPSERVICE')

Use Builtin(JSMX_COMMAND) With_Args(#JSMXHDLE1 #JSMXCMD) To_Get(#JSMSTS #JSMMSG)

Execute Subroutine(CHECK_STS) With_Parms(#JSMXHDLE1)

*

*     YOUR OWN LOGIC HERE

*

* UNLOAD SERVICE

#JSMXCMD := 'SERVICE_UNLOAD'

Use Builtin(JSMX_COMMAND) With_Args(#JSMXHDLE1 #JSMXCMD) To_Get(#JSMSTS #JSMMSG)

Execute Subroutine(CHECK_STS) With_Parms(#JSMXHDLE1)

* CLOSE JSM AND VERIFY STATUS

Use Builtin(JSMX_CLOSE) With_Args(#JSMXHDLE1) To_Get(#JSMSTS #JSMMSG)

Execute Subroutine(CHECK_STS) With_Parms(#JSMXHDLE1)

*

Return

*

* Subroutine to build JSM commands. existing JSM command

*

Subroutine Name(KEYWRD) Parms((#W_CMDX *BOTH) (#W_KEYWRD *RECEIVED) (#W_KEYVAL *RECEIVED))

Define Field(#W_CMDX) Reffld(#JSMXCMD)

Define Field(#W_KEYWRD) Reffld(#STD_TEXT)

Define Field(#W_KEYVAL) Reffld(#STD_TEXTL)

#W_CMDX += ' ' + #W_KEYWRD + '(' + #W_KEYVAL + ')'

Endroutine

*

*  Check the status of the JSM command issued

*

Subroutine Name(CHECK_STS) Parms(#W_HDLE)

*

Define Field(#MSGDTA) Type(*CHAR) Length(132)

Define Field(#W_HDLE) Type(*CHAR) Length(4)

*

If Cond('#JSMSTS *NE OK')

*

#MSGDTA := 'Error Status Code: ' + #JSMSTS

Message Msgid(DCM9899) Msgf([email protected]) Msgdta(#MSGDTA)

#MSGDTA := 'Error Message: ' + #JSMMSG

Message Msgid(DCM9899) Msgf([email protected]) Msgdta(#MSGDTA)

Endif

*

Endroutine

 

     Notice the commands used to Open JSM, Load the FTPService Service, Unload the Service and Close JSM.