Function SET206A - Remote Procedure for Form S_206F02
* =======================================================
* Process ........: SET_206
* Function .......: SET206A
* Created on .....: 11th September 2001
* Description ....: Queue Manager
* Version.........: 1
*
* Full Description: This function is the remote procedure
* being called by the Interface program. It takes the
* exchanged data, puts it into a list, and then sends it
* to the appropriate data queue. It also checks the
* message data queue to see whether a message has been
* posted.
*
* Disclaimer: The following material is supplied as
* example material only. No warranty concerning the
* material or its use in any way whatsoever is
* expressed or implied.
*
Function Options(*DIRECT *HEAVYUSAGE) Rcv_List(#S_WRKMESS)
*
* Field definitions
*
Define Field(#S_206PART) Type(*CHAR) Length(005)
Define Field(#S_206STR) Type(*CHAR) Length(200)
Define Field(#S_206CNT) Type(*DEC) Length(007) Decimals(0)
*
* List definitions
*
* This working list is used to put a message on the
* S_206MESS data queue
Def_List Name(#S_WRKMESS) Fields(#S_206CMD #S_206TYPE #S_206FRM #S_206TO #S_206MESS) Counter(#S_206CNT) Type(*WORKING) Entrys(0001000)
*
* Program mainline
*
Clr_List Named(#S_WRKMESS)
Case Of_Field(#S_206QUE)
When Value_Is('= *blank')
Change Field(#S_206CMD) To(AQ)
Execute Subroutine(GETQUEUE)
Exchange Fields(#S_206FRM)
When Value_Is('*ne *blank')
If Cond('#S_206CMD *EQ CK')
Execute Subroutine(GETMESSAGE)
Else
Change Field(#S_206FRM) To(#S_206ALS)
Add_Entry To_List(#S_WRKMESS)
Use Builtin(SND_TO_DATA_QUEUE) With_Args('S_206TLKQ' 256 #S_WRKMESS)
Endif
Endcase
Execute Subroutine(INITIALIZE)
Return
*
* Subroutine GetQueue
*
Subroutine Name(GETQUEUE)
* Get a queue name
Execute Subroutine(STARTMGR)
Clr_List Named(#S_WRKMESS)
Add_Entry To_List(#S_WRKMESS)
* Sends a request to the S_206TLKQ queue for a queue name
Use Builtin(SND_TO_DATA_QUEUE) With_Args('S_206TLKQ' 256 #S_WRKMESS)
Clr_List Named(#S_WRKMESS)
* Waits for a reponse in the S_206ALOT queue
Use Builtin(RCV_FROM_DATA_QUEUE) With_Args('S_206ALOT' 256 10) To_Get(#S_WRKMESS)
Get_Entry Number(1) From_List(#S_WRKMESS)
Change Field(#S_206QUE) To(#S_206MESS)
Change Field(#S_206ALS) To(#S_206FRM)
Endroutine
*
* Subroutine GetMessage
*
Subroutine Name(GETMESSAGE)
* When the alias is blank it checks the S_206MESS for
* new messages
Use Builtin(RCV_FROM_DATA_QUEUE) With_Args(#S_206QUE 256 0) To_Get(#S_WRKMESS)
If Cond('#S_206CNT *GT *ZERO')
Get_Entry Number(1) From_List(#S_WRKMESS)
Endif
Endroutine
*
* Subroutine Initialize
*
Subroutine Name(INITIALIZE)
Change Field(#S_206MESS) To(*BLANK)
Change Field(#S_206CMD) To(*BLANK)
Change Field(#S_206TYPE) To(*BLANK)
Change Field(#S_206JOBQ) To(*BLANK)
Change Field(#S_206TO) To(*BLANK)
Endroutine
*
* Subroutine STARTMGR
*
Subroutine Name(STARTMGR)
* This routine checks to see whether the Conversation
* Manager has been started. If it hasn't it starts it.
*
* Check to see if dataarea exists.
Exec_Os400 Command('CHKOBJ OBJ(QGPL/S_206DTA) OBJTYPE(*DTAARA)') If_Error(R1)
* Try and obtain an object lock on the data area. If this
* isn't possible the Communications Manager is running.,
Exec_Os400 Command('ALCOBJ OBJ((QGPL/S_206DTA *DTAARA *EXCL))') If_Error(R2)
Exec_Os400 Command('DLCOBJ OBJ((QGPL/S_206DTA *DTAARA *EXCL))')
R1: * Adds QGPL to the library list
Exec_Os400 Command('ADDLIBLE LIB(QGPL)') If_Error(*NEXT)
* Create the talk queue so that messages can be sent
Exec_Os400 Command('CRTDTAQ DTAQ(QGPL/S_206TLKQ) MAXLEN(25600)') If_Error(*NEXT)
Exec_Os400 Command('CRTDTAQ DTAQ(QGPL/S_206ALOT) MAXLEN(25600)') If_Error(*NEXT)
* If necessary, start the Communications Manager
Submit Process(SET_206) Function(SET206B) Job(CHAT_MON) Jobq(#S_206JOBQ)
R2: Endroutine
* =======================================================
* Process ........: SET_206
* Function .......: SET206A
* Created on .....: 11th September 2001
* Description ....: Queue Manager
* Version.........: 1
*
* Full Description: This function is the remote procedure
* being called by the Interface program. It takes the
* exchanged data, puts it into a list, and then sends it
* to the appropriate data queue. It also checks the
* message data queue to see whether a message has been
* posted.
*
* Disclaimer: The following material is supplied as
* example material only. No warranty concerning the
* material or its use in any way whatsoever is
* expressed or implied.
*
Function Options(*DIRECT *HEAVYUSAGE) Rcv_List(#S_WRKMESS)
*
* Field definitions
*
Define Field(#S_206PART) Type(*CHAR) Length(005)
Define Field(#S_206STR) Type(*CHAR) Length(200)
Define Field(#S_206CNT) Type(*DEC) Length(007) Decimals(0)
*
* List definitions
*
* This working list is used to put a message on the
* S_206MESS data queue
Def_List Name(#S_WRKMESS) Fields(#S_206CMD #S_206TYPE #S_206FRM #S_206TO #S_206MESS) Counter(#S_206CNT) Type(*WORKING) Entrys(0001000)
*
* Program mainline
*
Clr_List Named(#S_WRKMESS)
Case Of_Field(#S_206QUE)
When Value_Is('= *blank')
Change Field(#S_206CMD) To(AQ)
Execute Subroutine(GETQUEUE)
Exchange Fields(#S_206FRM)
When Value_Is('*ne *blank')
If Cond('#S_206CMD *EQ CK')
Execute Subroutine(GETMESSAGE)
Else
Change Field(#S_206FRM) To(#S_206ALS)
Add_Entry To_List(#S_WRKMESS)
Use Builtin(SND_TO_DATA_QUEUE) With_Args('S_206TLKQ' 256 #S_WRKMESS)
Endif
Endcase
Execute Subroutine(INITIALIZE)
Return
*
* Subroutine GetQueue
*
Subroutine Name(GETQUEUE)
* Get a queue name
Execute Subroutine(STARTMGR)
Clr_List Named(#S_WRKMESS)
Add_Entry To_List(#S_WRKMESS)
* Sends a request to the S_206TLKQ queue for a queue name
Use Builtin(SND_TO_DATA_QUEUE) With_Args('S_206TLKQ' 256 #S_WRKMESS)
Clr_List Named(#S_WRKMESS)
* Waits for a reponse in the S_206ALOT queue
Use Builtin(RCV_FROM_DATA_QUEUE) With_Args('S_206ALOT' 256 10) To_Get(#S_WRKMESS)
Get_Entry Number(1) From_List(#S_WRKMESS)
Change Field(#S_206QUE) To(#S_206MESS)
Change Field(#S_206ALS) To(#S_206FRM)
Endroutine
*
* Subroutine GetMessage
*
Subroutine Name(GETMESSAGE)
* When the alias is blank it checks the S_206MESS for
* new messages
Use Builtin(RCV_FROM_DATA_QUEUE) With_Args(#S_206QUE 256 0) To_Get(#S_WRKMESS)
If Cond('#S_206CNT *GT *ZERO')
Get_Entry Number(1) From_List(#S_WRKMESS)
Endif
Endroutine
*
* Subroutine Initialize
*
Subroutine Name(INITIALIZE)
Change Field(#S_206MESS) To(*BLANK)
Change Field(#S_206CMD) To(*BLANK)
Change Field(#S_206TYPE) To(*BLANK)
Change Field(#S_206JOBQ) To(*BLANK)
Change Field(#S_206TO) To(*BLANK)
Endroutine
*
* Subroutine STARTMGR
*
Subroutine Name(STARTMGR)
* This routine checks to see whether the Conversation
* Manager has been started. If it hasn't it starts it.
*
* Check to see if dataarea exists.
Exec_Os400 Command('CHKOBJ OBJ(QGPL/S_206DTA) OBJTYPE(*DTAARA)') If_Error(R1)
* Try and obtain an object lock on the data area. If this
* isn't possible the Communications Manager is running.,
Exec_Os400 Command('ALCOBJ OBJ((QGPL/S_206DTA *DTAARA *EXCL))') If_Error(R2)
Exec_Os400 Command('DLCOBJ OBJ((QGPL/S_206DTA *DTAARA *EXCL))')
R1: * Adds QGPL to the library list
Exec_Os400 Command('ADDLIBLE LIB(QGPL)') If_Error(*NEXT)
* Create the talk queue so that messages can be sent
Exec_Os400 Command('CRTDTAQ DTAQ(QGPL/S_206TLKQ) MAXLEN(25600)') If_Error(*NEXT)
Exec_Os400 Command('CRTDTAQ DTAQ(QGPL/S_206ALOT) MAXLEN(25600)') If_Error(*NEXT)
* If necessary, start the Communications Manager
Submit Process(SET_206) Function(SET206B) Job(CHAT_MON) Jobq(#S_206JOBQ)
R2: Endroutine