SMBService

Refer to shipped RPG source file QRPGLRSRC and CRTDEMO program source in QCLSRC source file.

 

      *

     D JSMHDL          S              4    INZ(*BLANKS)

     D JSMSRV          S            100    INZ(*BLANKS)

     D JSMSTS          S             40    INZ(*BLANKS)

     D JSMMSG          S           4096    INZ(*BLANKS)

     D JSMCMD          S           2048    INZ(*BLANKS)

     D ZEROLENGTH      S             10I 0 INZ(0)

      *

      * JSMX_BEGIN

      *

     C                   CALLB(D)  'JSMX_BEGIN'

     C                   PARM                    *OMIT

     C                   PARM                    ZEROLENGTH

      *

      * JSMX_OPEN

      *

     C                   CLEAR                   JSMSRV

     C                   EVAL      JSMSRV = 'LOCALHOST:4560'

     C                   CALLB(D)  'JSMX_OPEN'

     C                   PARM                    JSMHDL

     C                   PARM                    JSMSRV

     C                   PARM                    JSMSTS

     C                   PARM                    JSMMSG

     C                   CALLP     checkSTS(JSMSTS:JSMMSG)

      *

      * SERVICE_LOAD

      *

     C                   CLEAR                   JSMCMD

     C                   EVAL      JSMCMD = 'SERVICE_LOAD' +

     C                                      ' SERVICE(SMBService)' +

     C                                      ' TRACE(*YES)'

     C                   CALLB(D)  'JSMX_COMMAND'

     C                   PARM                    JSMHDL

     C                   PARM                    JSMCMD

     C                   PARM                    JSMSTS

     C                   PARM                    JSMMSG

     C                   CALLP     checkSTS(JSMSTS:JSMMSG)

      *

      * SET SERVER

      *

     C                   CLEAR                   JSMCMD

     C                   EVAL      JSMCMD = 'SET SERVER(SYD5)' +

     C                                      ' DOMAIN(SYD)' +

     C                                      ' USER(ALICK)' +

     C                                      ' PASSWORD(xxxxxxxx)'

     C                   CALLB(D)  'JSMX_COMMAND'

     C                   PARM                    JSMHDL

     C                   PARM                    JSMCMD

     C                   PARM                    JSMSTS

     C                   PARM                    JSMMSG

     C                   CALLP     checkSTS(JSMSTS:JSMMSG)

      *

      * CHECKFOR

      *

     C                   CLEAR                   JSMCMD

     C                   EVAL      JSMCMD = 'CHECKFOR' +

     C                                      ' PATH(/Shared/Alick/' +

     C                                      'orders/order-123.xml)'

     C                   CALLB(D)  'JSMX_COMMAND'

     C                   PARM                    JSMHDL

     C                   PARM                    JSMCMD

     C                   PARM                    JSMSTS

     C                   PARM                    JSMMSG

     C                   CALLP     checkSTS(JSMSTS:JSMMSG)

      *

      * GET

      *

     C                   CLEAR                   JSMCMD

     C                   EVAL      JSMCMD = 'GET' +

     C                                      ' FROM(/Shared/Alick/' +

     C                                      'orders/order-123.xml)' +

     C                                      ' TO(order-smb-get.xml)'

     C                   CALLB(D)  'JSMX_COMMAND'

     C                   PARM                    JSMHDL

     C                   PARM                    JSMCMD

     C                   PARM                    JSMSTS

     C                   PARM                    JSMMSG

     C                   CALLP     checkSTS(JSMSTS:JSMMSG)

      *

      * SERVICE_UNLOAD

      *

     C                   CLEAR                   JSMCMD

     C                   EVAL      JSMCMD = 'SERVICE_UNLOAD'

     C                   CALLB(D)  'JSMX_COMMAND'

     C                   PARM                    JSMHDL

     C                   PARM                    JSMCMD

     C                   PARM                    JSMSTS

     C                   PARM                    JSMMSG

     C                   CALLP     checkSTS(JSMSTS:JSMMSG)

      *

      * JSMX_CLOSE

      *

     C                   CALLB(D)  'JSMX_CLOSE'

     C                   PARM                    JSMHDL

     C                   PARM                    JSMSTS

     C                   PARM                    JSMMSG

     C                   CALLP     checkSTS(JSMSTS:JSMMSG)

      *

      * JSMX_END

      *

     C                   CALLB(D)  'JSMX_END'

      *

     C                   SETON                                        LR

 

      ********************************

      * Procedure to check JSM status

      ********************************

     P checkSTS        B

     D checkSTS        PI

     D  csJSMSTS                           CONST LIKE(JSMSTS)

     D  csJSMMSG                           CONST LIKE(JSMMSG)

     D  csMSGTXT       S            512A

     C                   IF        csJSMSTS <> 'OK'

     C                   EVAL      csMSGTXT = %TRIM(csJSMSTS) + ' ' +

     C                                        %TRIM(csJSMMSG)

     C                   CALLP     sendMSG(csMSGTXT:'*DIAG')

     C                   ENDIF

     P                 E

 

      **************************************

      * Procedure to send a program message

      **************************************

     P sendMSG         B

     D sendMSG         PI

     D smMSGTXT                     512a   VALUE

     D smMSGT                        10a   VALUE

     D smMSGI          S              7a   INZ('CPF9897')

     D smMSGF          S             20a   INZ('QCPFMSG   *LIBL     ')

     D smMSGL          S             10i 0 INZ(%SIZE(smMSGTXT))

     D smSTKE          S             10a   INZ('*')

     D smSTKC          S             10i 0 INZ(1)

     D smMSGK          S              4a

     D smERRC          S             10i 0 INZ(0)

     C                   IF        smMsgT = '*ESCAPE'

     C                   EVAL      smMsgI = 'CPF9898'

     C                   ENDIF

     C                   CALL      'QMHSNDPM'

     C                   PARM                    smMSGI

     C                   PARM                    smMSGF

     C                   PARM                    smMSGTXT

     C                   PARM                    smMSGL

     C                   PARM                    smMSGT

     C                   PARM                    smSTKE

     C                   PARM                    smSTKC

     C                   PARM                    smMSGK

     C                   PARM                    smERRC

     P                 E