**************************************************************************
*
* RPG program MDLDMOSR, receives message from FIFO data queue,
* sends
message to KEYED data queue
*
* Demonstrate for communication techiques used by
Model to,
* communicate with View-Controller
*
* Based on example DTAQSR from APISRC in RPGISCOOL
* see Redbook SG24-5402 section 5.2.3.
*
* Read MDLI, model input, data queue forever
* Build answer to put on MDLO, model output, data queue
* Write audit file so have record of Model operation
* Write MDLO, model output, data queue
* If the instruction on the input data queue is *ENDIT
* terminate the program, otherwise repeat
*
**************************************************************************
* Audit file. Input from
MDLIDS01 and output written to DMLODS01.
FMDLAFL01 O E DISK
*---------------------------------------------------------------------
* Prototype for API QSNDDTAQ - Send To a
Data Queue
D SndDtaQ PR EXTPGM('QSNDDTAQ')
D DataQueueNam 10A Const
D DataQueueLib 10A Const
D DataLength 5P 0 Const
D DataBuffer 32767A Const Options(*Varsize)
* Optional parameter group (Keyed DTAQ)
D KeyLength 3P 0 Const Options(*Nopass)
D KeyBuffer 256A Const Options(*Nopass
: *Varsize)
D AsyncRqs 10A Const Options(*Nopass
: *Varsize)
* Prototype for API QRCVDTAQ - Received From a Data Queue
D RcvDtaQ PR EXTPGM('QRCVDTAQ')
D DataQueueNam 10A Const
D DataQueueLib 10A Const
D DataLength 5P 0
D DataBuffer 32767A Options(*Varsize)
D WaitTime 5P 0 Const
* Optional parameter group 1 (Keyed DTAQ)
D KeyOrder 2A Const Options(*Nopass)
D KeyLength 3P 0 Const Options(*Nopass)
D KeyBuffer 256A Options(*Nopass : *Varsize)
D SndLength 3P 0 Const Options(*Nopass)
D SndBuffer 44A Options(*Nopass)
* Optional parameter group 2
D RemoveMsg 10A Const Options(*Nopass
: *Omit)
D RcvSize 5P 0 Const Options(*Nopass
: *Omit)
D Error
32767A Options(*Nopass : *Varsize)
*---------------------------------------------------------------------
* Input dtaq
D D@MDLIDS01 E DS EXTNAME(MDLIDS01)
* Outputt dtaq
D D@MDLODS01 E DS EXTNAME(MDLODS01)
* Program variable definitions
D Length
S
5P 0
D WaitTime C
-1
*---------------------------------------------------------------------
* Receives message from client
C CallP RcvDtaQ('MDLI' : '*LIBL'
C : Length
: D@MDLIDS01: WaitTime)
* Copy instruction from client to echo back to client
C Eval OINSTRTN
= IINSTRTN
* Build answer for client
C Eval OMESSAGE
= 'Hello Client '
C + %Trim(VCID)
C + ', received
instruction: '
C + %Trim(IINSTRTN)
C + ' with the message: '
C + %Trim(IMESSAGE)
* Write Audit file so results can be examined.
C Eval TMSP
= %TIMESTAMP()
C Write MDLAFM
* Send answer to client
C CallP SndDtaQ('MDLO' : '*LIBL'
C : %Len(D@MDLODS01)
C : D@MDLODS01
C : %Len(VCID) : VCID )
* End program in the instruction from client was *ENDIT
C If IINSTRTN = '*ENDIT'
C Eval *InLR = *On
C Endif
*---------------------------------------------------------------------