ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Using a keyed dataq...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using a keyed dataq...

    What the hell for: We have order picking units that are equipped with LXE wireless 5250 devices. We started routing them to pull from specific warehouse locations to satisfy order fulfillment requirements...
    Now we need to direct them to a workstation to unload the pulled material.

    For this we opted for 1 central dataq, we called it FC3TCOP. (Flight Control Traffic Cop)
    The workstations are desktop type units with their IP addresses statically set. We then entered
    them (as well as the picking units) into a workstation table. This is how we flight LOCATIONS to the order picking units during the pull and then to the workstations to be processed.

    Workstations could include working surfaces to package material, saws, sheers, flame cutters, etc...

    We wanted a way for the orders to "POP" to the displays as they were being pulled...




    Lets start with the workstation table.. Here are some example records:
    The braner a large device used to offload big-o-pans of steel
    PHP Code:
    CBWS CBWSDS                    CBIP            CBTYPE CBBAY CBSTATUS CBRUNDATE  CBAWS CBCUTINC CBSORTBY
    550  Braner                    10.0.10.128       W                   0001
    -01-01                   P 
    and my desk -- see how my desk is attached to the braner
    PHP Code:
    CBWS CBWSDS                    CBIP            CBTYPE CBBAY CBSTATUS CBRUNDATE  CBAWS CBCUTINC CBSORTBY
    599  Jamie
    's Desk              10.0.200.20       H     C             0001-01-01 550               P 
    When I scan a pan label (Bay,Row,Section,Shelf) I remove the location from the pulling area and write a record to the keyed dataq to unit 550 (braner) and it instantly prompts packager that material is on its way.

    The dataq -- Key is by the workstation number (in our example 550)
    PHP Code:
    CRTDTAQ DTAQ(JAMIELIB/FC3TCOPMAXLEN(4096)        
    SEQ(*KEYEDKEYLEN(3)                              
    TEXT('Flighting Traffic cop to workstation(s)'

    Code to grab IP from units
    PHP Code:
         d Format          s              8A   Inz('DEVD0600')                                
         
    d ipaddress       s             15a                                                  
         d Rcvar           S           5000A   Inz                                            
         d Varlen          S             10i 0 Inz
    (5000)                                      
                                                                                              
         
    d $getipaddress   pr                  extpgm('QDCRDEVD')                             
         
    d   rcvar                     5000                                                   
         d   varlen                      10i 0                                                
         d   format                       8                                                   
         d   
    @job                        10                                                   
         d   apierror                   256                                                   
                                                                                              
          
    //                                                                                  
          // Program Info                                                                     
          //                                                                                  
         
    d                SDS                                                                 
         d  
    @JOB                 244    253
                                                                                 
                                                                                 
         d APIError        ds                  Qualified                         
         d  BytesP                 1      4I 0 inz
    (%size(apiError))              
         
    d  BytesA                 5      8I 0 inz(0)                            
         
    d  Messageid              9     15                                      
         d  Reserved              16     16                                      
         d  messagedta            17    256                                      
                                                                                 
                                                                                 
                                                                                 
                                                                                 
                                                                                 
          
    /free                                                                  
                                                                                 
               $getipaddress
    rcvar   :                                          
                              
    varlen  :                                          
                              
    format  :                                          
                              @
    job    :                                          
                              
    Apierror    
                                      
    );                            
              
    ipaddress = %substrcvar:878:15);                    
              
    dsply ipaddress ' ';                                  
                                                                    
              *
    inlr = *on;                                          
         /
    end-free 
    ================================================== =============

    Cl code to write test data to the dataq
    PHP Code:
    /**************************************************************************/     
    /*   To Create:                                                           */     
    /*        CRTCLPGM PGM(XXX/SELFUPDC1) SRCFILE(XXX/QCLSRC)                 */     
    /*                                                                        */     
    /*                                                                        */     
    /*  CRTDTAQ DTAQ(JAMIELIB/FC3TCOP) MAXLEN(4096)                           */     
    /*  SEQ(*KEYED) KEYLEN(3)                                                 */     
    /*  TEXT('Flighting Traffic cop to workstation(s)')                       */     
    /*                                                                        */     
    /*                                                                        */     
    /**************************************************************************/     
                 
    PGM                                                                 
                                                                                     
              
    /* Declare input parameters */                                         
                 
    DCL        VAR(&DQDATA)   TYPE(*CHARLEN(4096)                     
                 
    DCL        VAR(&DQDLEN)   TYPE(*DECLEN(5VALUE(4096)             
                 
    DCL        VAR(&NUM)      TYPE(*DECLEN(5VALUE(1)                
                 
    DCL        VAR(&length)   TYPE(*DECLEN(3VALUE(3)                
                 
    DCL        VAR(&key)   TYPE(*CHARLEN(3)                           
                                                                                       
                                                                                       
      
    /* SEND INPUT PARM TO THE DATA QUEUE */                                          
      
    LOOP:                                                                            
                  
    CHGVAR     VAR(&DQDATAVALUE('D01-3-A-5    0012')                   
                  
    CHGVAR     VAR(&KEYVALUE('501')                                    
                                                                                       
                  
    CALL       PGM(QSNDDTAQPARM('FC3TCOP' '*LIBL' +                    
                               &
    DQDLEN &DQDATA &LENGTH &KEY)                           
                                                                                       
                  
    CHGVAR     VAR(&DQDATAVALUE('D02-2-Z-1    0006')                   
                  
    CHGVAR     VAR(&KEYVALUE('502')                                    
                                                                                       
                  
    CALL       PGM(QSNDDTAQPARM('FC3TCOP' '*LIBL' +                    
                               &
    DQDLEN &DQDATA &LENGTH &KEY)                           
                  
    CHGVAR     VAR(&NUMVALUE(&NUM 1)                                 
                                                                                       
               
    /* END THE LOOP AFTER 164 ENTRIES PLACED ON DATA QUEUE */               
                  
    IF         COND(&NUM *GT 10THEN(GOTO END)    
                                             
                 GOTO       
    LOOP             
                                             
                                             
     END
    :        ENDPGM 
    The DDS (with compile instructions in header)
    PHP Code:
         A*%%TS  SD  20110507  102449  FLANARY     REL-V5R4M0  5722-WDS         
         A
    **************************************************************        
         
    A*                                                                     
         
    ASELF UPDATING DISPLAY FILE                                          
         A
    *                                                                     
         
    ANOTECREATE DATA QUEUE SEFLUPDQ IN LIBRARY QGPL                    
         A
    *       BEFORE COMPILING THIS DISPLAY FILE                            
         A
    *                                                                     
         
    A*       CRTDTAQ DTAQ(QGPL/SELFUPDQMAXLEN(1000)                      
         
    A*                                                                     
         
    A*                                                                     
         
    A**************************************************************        
         
    A*  CRTDSPF FILE(JAMIELIB/SELFUPD1SRCFILE(JAMIELIB/SOURCE)           
         
    A*   WAITRCD(20DTAQ(*LIBL/FC3TCOPDFRWRT(*NO)                       
         
    A*                                                                     
         
    A**************************************************************        
         
    A*%%EC                                                                 
         A
    *%%FD Self updating display file                                    
         A                                      DSPSIZ
    (24 80 *DS3)       
         
    A                                      INDARA                       
         A                                      CF01                         
         A                                      CF02                         
         A                                      CF03                         
         A                                      CF04                         
         A                                      CF05                         
         A                                      CF06                         
         A                                      CF07                         
         A                                      CF08                         
         A                                      CF09                         
         A                                      CF10                         
         A                                      CF11                         
         A                                      CF12                         
         A                                      CF13                         
         A                                      CF14                         
         A                                      CF15                         
         A                                      CF16                         
         A                                      CF17                         
         A                                      CF18                         
         A                                      CF19    
         A                                      CF20                                   
         A                                      CF21                                   
         A                                      CF22                                   
         A                                      CF23                                   
         A                                      CF24                                   
         A N33                                  PAGEDOWN                               
         A                                      PAGEUP                                 
         A                                      
    PRINT                                  
         
    A                                      INVITE                                 
         A
    *=======================================================================     
         
    A*=======================================================================     
         
    A          R SUB01                     SFL                                    
         A
    *%%TS  SD  20110507  102449  FLANARY     REL-V5R4M0  5722-WDS                
         A            S1LOCATION    13A  O  6  4                                       
         A            S1QUANTITY     4Y 0O  6 19EDTCDE
    (L)                              
         
    A*=======================================================================     
         
    A*=======================================================================     
         
    A          R SUB01CTL                  SFLCTL(SUB01)                          
         
    A*%%TS  SD  20110507  094214  FLANARY     REL-V5R4M0  5722-WDS                
         A                                      KEEP 
         A                                      RTNCSRLOC
    (&#REC &#FLD)            
         
    A                                      BLINK                             
         A                                      OVERLAY                           
         A                                      PUTOVR                            
         A                                      OVRDTA                            
         A                                      OVRATR                            
         A                                      SFLCSRRRN
    (&WHERE)                 
         
    A                                      SFLMODE(&MODE)                    
         
    A  31                                  SFLDSP                            
         A  32                                  SFLDSPCTL                         
         A  30                                  SFLCLR                            
         A  33                                  SFLEND
    (*MORE)                     
         
    A                                      SFLSIZ(0100)                      
         
    A                                      SFLPAG(0030)                      
         
    A                                      SFLLIN(0003)                      
         
    A            SCRRN          4S 0H      SFLRCDNBR                         
         A            
    #REC          10A  H                                        
         
    A            #FLD          10A  H                                        
         
    A            WHERE          5S 0H                                        
         A            MODE           1A  H                
         A            ATR_DACONM     1A  P                                       
         A            DACONM        30A  O  1 21DSPATR
    (&ATR_DACONM)              
         
    A            H1ITEM        17A  H                                       
         A                                  4  4
    'Completed Packaging'            
         
    A                                      DSPATR(HI)                       
         
    A                                      COLOR(RED)                       
         
    A                                  5  4'Location'                       
         
    A                                      DSPATR(HI)                       
         
    A                                      DSPATR(UL)                       
         
    A                                  5 20'Qty'                            
         
    A                                      DSPATR(HI)                       
         
    A                                      DSPATR(UL)                       
         
    A                                  5 26'Location'                       
         
    A                                      DSPATR(HI)                       
         
    A                                      DSPATR(UL)                       
         
    A                                  5 42'Qty'                            
         
    A                                      DSPATR(HI)                       
         
    A                                      DSPATR(UL)                       
         
    A                                  5 64'Qty'                            
         
    A                                      DSPATR(HI
         
    A                                      DSPATR(UL)                         
         
    A                                  5 48'Location'                         
         
    A                                      DSPATR(HI)                         
         
    A                                      DSPATR(UL)                         
         
    A            C1TIME         6Y 0O  2  5EDTWRD('  :  :  ')                 
         
    A            C1DATE         6Y 0O  1  5EDTWRD('  /  /  ')                 
         
    A                                  2 43'Orders Completed:'                
         
    A            C1ORDERS       4Y 0O  2 61EDTCDE(2)                          
         
    A                                  3 46'Total Weight:'                    
         
    A            FLD002         8Y 0O  3 61EDTCDE(2)                          
         
    A          R F1   
          A                                      OVERLAY                               
          A                                 24  4
    'F3=Exit'                             
          
    A                                      COLOR(BLU)                            
          
    A                                 24 22'F5=Start Auto-fill of Subfile'       
          
    A                                      COLOR(BLU
    The RPG processing program (This version has the Key hardcoded.. The working version has the key being pulled by using the get ip code snippet above then chaining to the workstation file.
    PHP Code:
     *================================================================      
     * 
    To compile:                                                          
     *                                                                      
     *      
    CRTBNDRPG  PGM(XXX/SELFUPR1SRCFILE(XXX/QRPGLESRC)             
     *                   
    DFTACTGRP(*NO)                                     
     *                                                                      
     ****************************************************************       
    fSELFUPD1  cf   e             workstn INFDS(INFDSMaxdev(*FILE)        
    f                                     SFILE(SUB01:RRN)                  
     *                                                                      
    d EndScreen1      s               n                                     
    D Event           S              5a                                     
    D keepwaiting     S               n   inz
    ('1')                          
    D DataLen         S              5P 0                                   
    d RRN             s                   like
    (SCRRN)                       
    d Savrrn          s                   like(SCRRN)                       
    D keyOrder        S              2                                      
    D LengthKeyData   S              3  0                                   
    D KeyData         S              3                                      
                                                                                                     
     d dataqueue       s             10    inz
    ('FC3TCOP')                                            
     
    d dataqueueLib    s             10    inz('*LIBL')                                              
     
    d dataqueueLen    s              5  0 inz(4096)                                                 
     
    d datawait        s              5  0 inz(3)                                                    
     
    d datakorder      s              2    inz('EQ')                                                 
     
    d dataklen        s              3  0 inz(3)                                                    
     
    d datakey         s              3    inz('501')                                                
     
    d dataj1          s              3  0                                                           
     d dataj2          s              1                                                              
                                                                                                     
     d dqdata          ds                  qualified  inz                                            
     d  WholeTomato                4096                                                              
     d   Location                    13    overlay
    (WholeTomato:1)                                    
     
    d   Quantity                     4  0 overlay(wholeTomato:*next)                                
                                                                                                     
     
    d Infds           ds                                                       INFDS data structure 
     d Status            
    *STATUS                                                                     
     d Choice                369    369                                                              
     d Currec                378    379I 0                                                           
                                                                                        
     
    //                                                                                 
     // External calls                                                                  
     //                                                                                 
                                                                                        
    d $RcvDtaQ        pr                  extpgm('QRCVDTAQ')                            
    d   dataqueue                   10                                                  
    d   dataqueueLib                10                                                  
    d   dataqueueLen                 5  0                                               
    d   QueueData                   13                                                  
    d   datawait                     5  0                                               
    d   keyOrder                     2                                                  
    d   LengthKey                    3  0                                               
    d   KeyData                      3                                                  
    d   junk1                        3  0                                               
    d   junk2                        1                                                  
     
    // Command Keys                                                                    
                                                                                        
    d Cmd1            c                   const(x'31')                         Cmd-1    
    d cmd2            c                   
    const(x'32')                         Cmd-2    
    d LeaveProgram    c                   
    const(x'33')                         Cmd-3         
    d cmd4            c                   
    const(x'34')                         Cmd-4         
    d cmd5            c                   
    const(x'35')                         Cmd-5         
    d cmd6            c                   
    const(x'36')                         Cmd-6         
    d cmd7            c                   
    const(x'37')                         Cmd-7         
    d cmd8            c                   
    const(x'38')                         Cmd-8         
    d cmd9            c                   
    const(x'39')                         Cmd-9         
    d commandline     c                   
    const(x'3A')                         Cmd-10        
    d Cmd11           c                   
    const(x'3B')                         Cmd-11        
    d Cmd12           c                   
    const(x'3C')                         Cmd-12        
    d Cmd13           c                   
    const(x'B1')                         Cmd-13        
    d Cmd14           c                   
    const(x'B2')                         Cmd-14        
    d Cmd15           c                   
    const(x'B3')                         Cmd-15        
    d Cmd16           c                   
    const(x'B4')                         Cmd-16        
    d Cmd17           c                   
    const(x'B5')                         Cmd-17        
    d Cmd18           c                   
    const(x'B6')                         Cmd-18        
    d Cmd19           c                   
    const(x'B7')                         Cmd-19        
    d Cmd20           c                   
    const(x'B8')                         Cmd-20        
    d Cmd21           c                   
    const(x'B9')                         Cmd-21        
    d Cmd22           c                   
    const(x'BA')                         Cmd-22        
    d Cmd23           c                   
    const(x'BB')                         Cmd-23       
    d Cmd24           c                   
    const(x'BC')                         Cmd-24       
    d EnterKey        c                   
    const(x'F1')                                      
    d RollUp          c                   const(x'F5')                         Roll Up      
    d RollDown        c                   
    const(x'F4')                         Roll Down    
                                                                                            
     
    //                                                                                     
     //  external calls                                                                     
     //                                                                                     
                                                                                            
    d $command        pr                  extpgm('QCMD')                                    
                                                                                            
                                                                                            
     /
    free                                                                                  
                                                                                            
         exsr $clearsfl
    ;                                                                    
         
    exsr $receivedataq;                                                                
         
    exsr $screen1;                                                                     
         *
    inlr = *on;                                                                       
       
    //--------------------------------------------------------       
       // $Screen1 - Show screen of orders to pick/pull                 
       //--------------------------------------------------------       
            
    begsr $Screen1;                                             
                                                                        
            
    reset  EndScreen1;                                          
             
    dow  EndScreen1 = *off;                                    
                                                                        
                                                                        
              
    write(esub01ctl;                                        
              
    read(e)  SELFUPD1;                                        
              if %
    error;                                                
                
    exsr $receivedataq;                                     
              endif;                                                    
                                                                        
              
    select;                                                   
                                                                        
           
    //                                                           
           // F3 pressed end the program F3 = LeaveProgram              
           //          

               
    when  Choice LeaveProgram;                  
                
    EndScreen1 = *on;                            
                                                             
           
    //                                                
           // F10 pressed show command line                  
           //                                                
               
    when  Choice commandline;                   
                
    $command();                                  
            
    //                                               
            // Enter Key pressed                             
            //                                               
               
    when  Choice enterKey;                      
                                                             
                                                             
              
    endsl;                                         
                                                             
             
    enddo;                                          
                                                             
            
    endsr;                
                                                                         
        
    //-------------------------------------------------              
        // $receivedataq - receive dataq entries                         
        //-------------------------------------------------              
            
    begsr $receivedataq;                                         
                                                                         
               
    $RcvDtaQ (Dataqueue    :                                  
                         
    DataQueueLib :                                  
                         
    DataQueueLen :                                  
                         
    dqdata       :                                  
                         
    datawait     :                                  
                         
    datakorder   :                                  
                         
    dataklen     :                                  
                         
    datakey      :                                  
                         
    dataj1       :                                  
                         
    dataj2                                          
                                      
    );                                 
                                                                         
               if 
    dataqueueLen > *zeros or RRN = *zeros;                 
                
    exsr $writeone
              endif;                                                 
                                                                     
           
    endsr;                                                    
                                                                     
       
    //--------------------------------------------------------    
       // $WriteOne - write subfile                                  
       //--------------------------------------------------------    
            
    begsr $writeone;                                         
                                                                     
              
    RRN += 1;                                              
              
    SCRRN RRN;                                           
              
    s1location =  dqdata.location;                         
              
    s1quantity =  dqdata.quantity;                         
              
    write SUB01;                                           
              *
    in33 = *on;                                           
              
    savrrn SCRRN;                                        
                                                                     
             
    endsr;                                                  
                                                                     
       
    //----------------------------------------    
       // $clearSfl  - clear subfile 1 (detail)                 
       //----------------------------------------               
            
    begsr $clearSFL;                                    
                                                                
             
    // clear the subfile                               
                                                                
              
    *in31 = *On;                                      
              *
    in32 = *On;                                      
              *
    in30 = *Off;                                     
                                                                
              
    clear RRN;                                        
              
    clear SCRRN;                                      
              
    clear SavRrn;                                     
                                                                
            
    endsr;                                              
                                                                
     /
    end-free 
    Because this is a test version it can be demoed on your system kind cool to see..
    to get a good example I created two copies of the RPG each hardcoded to a different workstation number... I can post a save file with the code in if anyone is interested.
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com
Working...
X