PDFService Example

This service uses files that have been shipped in the JSM instance folder.

FUNCTION   OPTIONS(*DIRECT)

**********

DEFINE     FIELD(#JSMSTS) TYPE(*CHAR) LENGTH(20)

DEFINE     FIELD(#JSMCMD) TYPE(*CHAR) LENGTH(256)

DEFINE     FIELD(#JSMMSG) TYPE(*CHAR) LENGTH(256)

**********

DEFINE     FIELD(#PRDID) TYPE(*CHAR) LENGTH(10)

DEFINE     FIELD(#PRDAVL) TYPE(*CHAR) LENGTH(200)

DEFINE     FIELD(#PRDDSC) TYPE(*CHAR) LENGTH(250)

DEFINE     FIELD(#PRDAMTMP) TYPE(*DEC) LENGTH(10) DECIMALS(2)

DEFINE     FIELD(#PRDAMTYP) TYPE(*DEC) LENGTH(10) DECIMALS(2)

DEFINE     FIELD(#PRDAMTB10) TYPE(*DEC) LENGTH(10) DECIMALS(2)

DEFINE     FIELD(#PRDAMTB20) TYPE(*DEC) LENGTH(10) DECIMALS(2)

DEFINE     FIELD(#PRDAMTB30) TYPE(*DEC) LENGTH(10) DECIMALS(2)

**********

DEFINE     FIELD(#TEXT) TYPE(*CHAR) LENGTH(30)

DEF_LIST   NAME(#LST1) FIELDS((#TEXT)) TYPE(*WORKING)

**********

DEFINE     FIELD(#COL1) TYPE(*CHAR) LENGTH(10)

DEFINE     FIELD(#COL2) TYPE(*CHAR) LENGTH(10)

DEFINE     FIELD(#COL3) TYPE(*DEC)  LENGTH(10) DECIMALS(2)

DEF_LIST   NAME(#LST2) FIELDS((#COL1) (#COL2) (#COL3)) TYPE(*WORKING)

**********

CHANGE     FIELD(#PRDID) TO(CORD443)

CHANGE     FIELD(#PRDAVL) TO('''Available in 24 hours''')

CHANGE     FIELD(#PRDDSC) TO('''18V Compact Hammer. Power output 350W''')

**********

CHANGE     FIELD(#PRDAMTMP) TO(499.99)

CHANGE     FIELD(#PRDAMTYP) TO(499.99)

CHANGE     FIELD(#PRDAMTB10) TO(431.99)

CHANGE     FIELD(#PRDAMTB20) TO(413.99)

CHANGE     FIELD(#PRDAMTB30) TO(359.99)

**********

********** JSM_OPEN

**********

USE        BUILTIN(JSM_OPEN) WITH_ARGS('LOCALHOST:7560') TO_GET(#JSMSTS #JSMMSG)

EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)

**********

********** SERVICE_LOAD

**********

CHANGE     FIELD(#JSMCMD) TO('SERVICE_LOAD SERVICE(PDFDocumentService) TRACE(*YES)')

USE        BUILTIN(JSM_COMMAND) WITH_ARGS(#JSMCMD) TO_GET(#JSMSTS #JSMMSG)

EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)

**********

********** CREATE

**********

CHANGE     FIELD(#JSMCMD) TO('''CREATE DOCUMENT(demo.pdf) CONTENT(demo-product.xml)''')

USE        BUILTIN(JSM_COMMAND) WITH_ARGS(#JSMCMD) TO_GET(#JSMSTS #JSMMSG)

EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)

**********

********** ADD PRODUCT

**********

CHANGE     FIELD(#TEXT) TO('''4-piece combo kit''')

ADD_ENTRY  TO_LIST(#LST1)

CHANGE     FIELD(#TEXT) TO('''3-speed transmission''')

ADD_ENTRY  TO_LIST(#LST1)

**********

USE        BUILTIN(JSM_COMMAND) WITH_ARGS('ADD CONTENT(PRODUCT) SERVICE_LIST(TEXT)') TO_GET(#JSMSTS #JSMMSG #LST1)

EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)

**********

********** ADD TABLE

**********

CHANGE     FIELD(#COL1) TO('''Text 11''')

CHANGE     FIELD(#COL2) TO('''Text 12''')

CHANGE     FIELD(#COL3) TO(100.34)

ADD_ENTRY  TO_LIST(#LST2)

CHANGE     FIELD(#COL1) TO('''Text 21''')

CHANGE     FIELD(#COL2) TO('''Text 22''')

CHANGE     FIELD(#COL3) TO(145.67)

ADD_ENTRY  TO_LIST(#LST2)

USE        BUILTIN(JSM_COMMAND) WITH_ARGS('ADD CONTENT(TABLE) SERVICE_LIST(COL1,COL2,COL3)') TO_GET(#JSMSTS #JSMMSG #LST2)

EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)

**********

********** CLOSE

**********

USE        BUILTIN(JSM_COMMAND) WITH_ARGS('CLOSE') TO_GET(#JSMSTS #JSMMSG)

EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)

**********

********** SERVICE_UNLOAD

**********

USE        BUILTIN(JSM_COMMAND) WITH_ARGS('SERVICE_UNLOAD') TO_GET(#JSMSTS #JSMMSG)

EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)

**********

********** JSM_CLOSE

**********

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