data queue

895 pts.
Tags:
AS/400
Data Queue
Pipe symbol
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

Answer Wiki

Thanks. We'll let you know when a new response is added.

In your RPG Program call a program QRcvDtaQ

Call ‘QRcvDtaQ’
Parm qname <– 10
Parm qlib <– 10
Parm flen <– 5p 0 — length of RcvFQ
Parm RcvFQ <—– actual character field to receive queue value width = width of queue
parm WaitQ <– 5p 0 number of seconds to wait for entry on Queue
negative value wait forever
0 do not wait
postive value wait nn seconds

If the data queue is “keyed” which means that you only want to get entries with a specific key value
then there are more parameters.

When you rcv an entry it is removed from the queue.

You will then need to parse the character string.

Phil

———————
You’re saying the dataqueue is keyed on the timestamp????
Then you would have to have the timestamp inorder to retrieve the entry.
Keyed fields are added below

Call ‘QRcvDtaQ’
Parm qname <– 10
Parm qlib <– 10
Parm flen <– 5p 0 — length of RcvFQ
Parm RcvFQ <—– actual character field to receive queue value width = width of queue
parm WaitQ <– 5p 0 number of seconds to wait for entry on Queue
negative value wait forever
0 do not wait
postive value wait nn seconds
parm krule ‘EQ’
parm klen 3 P0 length of key
parm keyval KeyValue
parm SdrLen 3p 0 – length of sender data to capture
parm SdrVal includes sender job name, user, number, user Prf

————-
You could write a short program calling QSndDtaQ

——————-
One more time .. keyed by timestamp?? — keying a dataqueue isn’t to put the data in a specific order
but providing a tool for extracting specific entries from the queue. To extract an entry from your queue your program will need to get the timestamp value somehow before it attempts to receive the entry.

If you want a queue which delivers the data in entry sequence create it as *FIFO not keyed!!!

Phil

————
I think Teandy links were
www.itjungle.com/mpo/mpo052302-story02.html
www.itjungle.com/mpo/mpo052302-story05.html

http://tutorialindia.com/articles/as400/data_queue.php

Phil

Discuss This Question: 6  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Satsho
    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,
    1,245 pointsBadges:
    report
  • Nutangujar
    thanks Phil. yes it is keyed data...timestamp is the key... i have to use stored procedure interface for update.
    895 pointsBadges:
    report
  • Nutangujar
    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......
    895 pointsBadges:
    report
  • Teandy
    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
    5,860 pointsBadges:
    report
  • Nutangujar
    I cant access those links...
    895 pointsBadges:
    report
  • Splat
    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.
    7,035 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following