SMSService Example

LANSA Integrator

SMSService Example

This example demonstrates the use of the SMSService in an RDML function. It sends a predefined message to a predefined number. You may replace the message and mobile number here with your own hard coded values or replace them with fields that are populated from your database.

This example displays a screen after every JSM_COMMAND Built-in Function so that you can track the status of each step of the process. Such a technique can be useful for testing purpose. In production applications, end users would not want to see such screens.

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

* Description:
* This example demonstrates the use of the SMSService in
* an RDML function. It sends a predefined message to a
* predefined number. You may replace the message and
* mobile number here with your own hard coded values or
* replace them with fields that are populated from your
* database.
* This example displays a screen after every JSM_COMMAND
* Built-in Function so that you can track the status of
* each step of the process. Such a technique can be
* useful for testing purpose. In production applications,
* end users would not want to see such screens

* Disclaimer: The following material is supplied as
* sample material only. No warranty concerning the
* material or its use in any way whatsoever is
* expressed or implied.

* =======================================================
FUNCTION OPTIONS(*DIRECT)

* The following locally defined fields are used to hold
* the parameters required within the JSM Built-in
* Functions.
DEFINE FIELD(#JSMSTS) TYPE(*CHAR) LENGTH(020)
DEFINE FIELD(#JSMMSG) TYPE(*CHAR) LENGTH(255)
DEFINE FIELD(#JSMCMD) TYPE(*CHAR) LENGTH(255)
DEFINE FIELD(#JSMSRV) TYPE(*CHAR) LENGTH(050)

* 'Open service'

CHANGE FIELD(#JSMSRV) TO('SERVER:4560')
USE BUILTIN(JSM_OPEN) WITH_ARGS(#JSMSRV) TO_GET(#JSMSTS #JSMMSG)
EXECUTE SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)

* 'Load service'

USE BUILTIN(JSM_COMMAND) WITH_ARGS('SERVICE_LOAD SERVICE(SMSSERVICE) TRACE(*NO)') TO_GET(#JSMSTS #JSMMSG)
EXECUTE SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)

USE BUILTIN(JSM_COMMAND) WITH_ARGS('SET ENCODING(ISO8859_1)') TO_GET(#JSMSTS #JSMMSG)
EXECUTE SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)

* 'Send message'

CHANGE FIELD(#JSMCMD) TO('''SEND TO(+61429999999) MSG(Hello. Here is a sample message)''')
USE BUILTIN(JSM_COMMAND) WITH_ARGS(#JSMCMD) TO_GET(#JSMSTS #JSMMSG)
EXECUTE SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)

* 'Unload service'

USE BUILTIN(JSM_COMMAND) WITH_ARGS('SERVICE_UNLOAD') TO_GET(#JSMSTS #JSMMSG)
EXECUTE SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)

* 'Close service'

USE BUILTIN(JSM_CLOSE) TO_GET(#JSMSTS #JSMMSG)
EXECUTE SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)

* SUB ROUTINES

SUBROUTINE NAME(CHECK) PARMS((#JSMSTS *RECEIVED) (#JSMMSG *RECEIVED))

IF COND('#JSMSTS *NE OK')
DISPLAY FIELDS(#JSMSTS #JSMMSG)

USE BUILTIN(JSM_CLOSE) TO_GET(#JSMSTS #JSMMSG)

MENU MSGTXT('Java service error has occurred')

ENDIF

ENDROUTINE