Hi,
I want to write programs which will read from a data queue a string of bytes delimited by '|' and update the database. how to achieve this..this is the first time i'm dealing with data queues...
Thanks,
Nutan
Software/Hardware used:
AS400
ASKED:
August 31, 2009 3:32 PM
UPDATED:
September 4, 2009 2:45 PM
I am assuming since the data is delimited, the data will be of varying length ?
I’ve never tried it myself, but as Phil says, you probably need to read it in as a single record and parse it by the delimiter. Let me know how this works,
thanks Phil. yes it is keyed data…timestamp is the key…
i have to use stored procedure interface for update.
Thanks…the next question is how to test this kinda programs in which, i have to pick up something from a dataq and put it into the database….
is it something i have to load the dataque and then call my program to pick it up …if yes then how will i load the data q……
Here are some links that may help you create your test program.
http://www.itjungle.com/mpo/mpo052302-story02.html
http://www.itjungle.com/mpo/mpo052302-story05.html
http://tutorialindia.com/articles/as400/data_queue.php
I cant access those links…
You can use data queues to retrieve data in a specific order.
Here’s an example from a print program where the incoming data is disparate:
D #qq S 10 D #qql S 10 D #qfl S 5 0 D #qf S 1024 D #qwt S 5 0 D #qord S 2 D #qkl S 3 0 inz(%len(dta_0)) D #qk S 256 D #qsl S 3 0 D #qs S 44 D Dta_0 Ds inz D @svc_iso 8 0 D @trndy 4 0 overlay(@svc_iso) D @trndm 2 0 overlay(@svc_iso: *next) D @trndd 2 0 overlay(@svc_iso: *next) D @grp D @chg# 7 0 D @act# 11 0 D @seq# 5 0 D Dta_1 Ds inz D @pst_iso 8 0 D @tpsdy 4 0 overlay(@pst_iso) D @tpsdm 2 0 overlay(@pst_iso: *next) D @tpsdd 2 0 overlay(@pst_iso: *next) D @qty like(tqty) D @amnt like(tamnt) * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Process commands (QCAPCMD) * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - D ProcCmd Pr extpgm('QCAPCMD') D 1024a options(*varsize) const D 9b 0 const D 20a options(*varsize) const D 9b 0 const D 8a const D 1024a options(*varsize) const D 9b 0 const D 9b 0 const D 512a options(*varsize) const D Cc_loscs S 9b 0 D Cc_ocbl S 9b 0 D Cc_ocbf S 8 inz('CPOP0100') D Cc_lafccs S 9b 0 inz(0) D Cc_loccsatr S 9b 0 D Cpop0100 Ds inz D cpop_tocp 9b 0 inz(0) D cpop_dbcs 1 inz('0') D cpop_pa 1 inz('0') D cpop_css 1 inz('0') D cpop_mk 4 D 9 inz(x'000000000000000000') * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Clear data queue (QCLRDTAQ) * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - D Clrdtaq Pr extpgm('QCLRDTAQ') D 10a const D 10a const * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Send data queue (QSNDDTAQ) * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - D Snddtaq Pr extpgm('QSNDDTAQ') D 10a const D 10a const D 5p 0 const // Create data queue #qq = s00proc; #qql = 'QTEMP'; Cmdstr = 'CRTDTAQ DTAQ(' + %trim(#qql) + '/' + %trim(#qq) + ') MAXLEN(' + %trim(%editc(%len(dta_0) + %len(dta_1):'3')) + ') SEQ(*KEYED) KEYLEN(' + %trim(%editc(%len(dta_0):'3')) + ') SIZE(*MAX2GB)'; Proccmd(%trim(cmdstr): %len(%trim(cmdstr)): cpop0100: cpop0100: %len(cpop0100): cc_ocbf: cmdstr: %len(cmdstr): cc_loccsatr: api_error); Clrdtaq(#qq: #qql); Snddtaq(#qq: #qql: %len(dta_0) + %len(dta_1): dta_0 + dta_1: %len(dta_0): dta_0); Clear #qfl; Clear #qs; First = *on; Dou #qfl <= *zero; /End-free C Call(e) 'QRCVDTAQ' C parm #qq C parm #qql C parm #qfl C parm #qf C parm *zero #qwt C parm 'GE' #qord C parm #qkl C parm *blanks #qk C parm 44 #qsl C parm #qs /Free If #qfl <= *zero; Exsr subroutine; *inlr = *on; Leave; EndIf; Dta_0 = %subst(#qf: 1: %len(dta_0)); Dta_1 = %subst(#qf: %len(dta_0) + 1: %len(dta_1)); If first; Exsr subroutine; EndIf; EndDo;Sorry about the length of the entry, but I didn’t want to leave out the important bits.