ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

I can't find why this would write a duplicate record

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

  • I can't find why this would write a duplicate record

    here's the rpg

    Code:
    egsr loadsfl;
    
             setll fac fsol17;
             reade fac fsol17;
             dow not %eof;
               chain sprod iiml01;
               if %found(iiml01);
                 if iclas = 'DE' or iclas = 'DI' or iclas = 'DR';
                   if sbu <> *blanks;
                     chain (fac:iclas) pns101pf;
                     if %found(pns101pf);
                       if icsbucde <> sbu;
                         reade fac fsol17;
                         iter;
                       endif;
                     else;
                       reade fac fsol17;
                       iter;
                     endif;
                   endif;
    
                   // if from date <> blanks or to date <> blanks;
                   // then check the date on the shop order to make sure;
                   // that it falls in the date range.
                   // ***still need clarification on the date field to use;
                   if fdate <> *zeros and tdate <> *zeros;
                     chain (sord:sopno) fodl01;
                     if %found(fodl01);
                       if ocdte < fdate or ocdte > tdate;
                         reade fac fsol17;
                         iter;
                       endif;
                     else;
                       reade fac fsol17;
                       iter;
                     endif;
                   endif;
                   //***************************************************************
                   //check to make sure that the current operation matches
                   //the operation number
                   //***************************************************************
                   if op <> *zeros;
                     if op <> sopno;
                       reade fac fsol17;
                       iter;
                     endif;
                   endif;
    
                   //***************************************************************
                   //calculate the hours remaining based on labor tickets posted
                   //against the shop order and make sure it falls in range.
                   //***************************************************************
                   if fhrs <> *zeros;
                     chain (sord:op) fodl01;
                     if %found(fodl01);
                       remhrs = orun - orunp;
                       if remhrs >= fhrs and remhrs <= thrs;
                       else;
                         reade fac fsol17;
                         iter;
                       endif;
                     else;
                       reade fac fsol17;
                       iter;
                     endif;
                   endif;
    
                   //***************************************************************
                   //check that the order has a follow up date
                   //***************************************************************
                   if fup = 1;
                     chain scord echl02;
                     if %found(echl02);
                       if chcxdt = *zeros;
                         reade fac fsol17;
                         iter;
                       endif;
                     else;
                       reade fac fsol17;
                       iter;
                     endif;
                   endif;
    
                   //***************************************************************
                   //check if the shop order has been assinged.
                   //if assigned then skip it
                   //***************************************************************
                   if nodft = 1;
                     if suemp1 <> *blanks or suemp2 <> *blanks;
                       reade fac fsol17;
                       iter;
                     endif;
                   endif;
                 else;
                   reade fac fsol17;
                   iter;
                 endif;
               else;
                 reade fac fsol17;
                 iter;
               endif;
    
    
             //load the sfl record and write it.
               if suemp1 <> *blanks;
                 sfldfter = suemp1;
               elseif suemp2 <> *blanks;
                 sfldfter = suemp2;
               else;
                 sfldfter = *blanks;
               endif;
    
               sflord = scord;
               chain scord echl02;
               if %found(echl02);
                 sfljob = chbcon;
               else;
                 sfljob = *blanks;
               endif;
    
               sflsord = sord;
    
    
               chain (sord:sopno) fodl01;
               if %found(fodl01);
                 //NEED TO FORMAT THE DATE BEFORE MOVING TO A 10A FIELD.
                 //sflschdate = ocdte;
                 sflhrs = orun - orunp;
               else;
                 sflschdate = *zeros;
                 sflhrs = *zeros;
               endif;
    
               sflop = sopno;
               sflwrkc = swrkc;
    
               if mrrrn < 9999;
                 mrrrn = mrrrn + 1;
                 write sfl1;
                 //reade fac fsol17;
                 //iter;
               else;
                 msgtxt = 'OVER 9999 RECORDS SELECTED, PLEASE SELECT A SMALLER +
                           RANGE AND TRY AGAIN.';
                 MRRRN = *HIVAL;
                 leave;
               endif;
    
             reade fac fsol17;
             enddo;
             sflend = *on;
    
             if mrrrn > 0 and mrrrn <> *hival;
               sfldsp = *on;
               saverrn = mrrrn;
               mrrrn = 1;
             endif;
           endsr;

    here's the dds
    Code:
         A          R SFL1
         A*%%TS  DD  20080722  141125  bmartin     REL-V5.0.1  WDSc
         A                                      SFL
         A            SFLSEL         1   B 11  2
         A            SFLDFTER       8   O 11  5
         A            SFLORD         6Y 0O 11 15
         A            SFLJOB        20   O 11 23
         A            SFLSORD        6Y 0O 11 50
         A            SFLSCHDATE    10   O 11 70
         A            SFLHRS         3Y 0O 11 45
         A            SFLOP          2Y 0O 11 58
         A            SFLWRKC        6Y 0O 11 62
         A          R CTL
         A*%%TS  DD  20080722  141125  bmartin     REL-V5.0.1  WDSc
         A                                      SFLCTL(SFL1)
         A                                      SFLSIZ(10)
         A                                      SFLPAG(9)
         A                                      CA03(03 'F3=EXIT')
         A                                      CF06(06 'F6=PRINT')
         A                                      CA12(12 'F12=CANCEL')
         A                                      OVERLAY
         A  31                                  SFLDSP
         A  32                                  SFLDSPCTL
         A  33                                  SFLCLR
         A  34                                  SFLEND(*MORE)
         A                                      SFLCSRRRN(&CURSPOS)
         A                                  1  2'PNS230R -02'
         A                                      COLOR(BLU)
         A            MSGFLD0001    38A  O  1 18MSGID(L01 9301 SSAZ03)
         A                                      DSPATR(HI)
         A            WORKSN        10A  O  1 62
         A                                  1 73DATE
         A                                      EDTCDE(Y)
         A                                  2  2SYSNAME
         A                                  2 23'Drafter Capacity Management'
         A                                      COLOR(BLU)
         A                                  2 62USER
         A                                  2 73TIME
         A                                  4  2'Facility:'
         A                                  4 17'SBU:'
         A                                  4 29'From:'
         A                                  4 48'To:'
         A            CTLFAC         2   O  4 13COLOR(WHT)
         A            CTLSBU         3   O  4 22COLOR(WHT)
         A            CTLFDATE      10   O  4 35COLOR(WHT)
         A            CTLTDATE      10   O  4 52COLOR(WHT)
         A                                  5  2'Operation: '
         A            CTLOP          2   O  5 14COLOR(WHT)
         A                                  5 21'Hours Remaining:'
         A            CTLHRS         3   O  5 38COLOR(WHT)
         A                                  5 46'Follow Up:'
         A            CTLFUP         1   O  5 58COLOR(WHT)
         A                                  6 46'Unassigned:'
         A            CTLNODFT       1   O  6 58COLOR(WHT)
         A                                  7  2'1=Notes  2='
         A                                      COLOR(BLU)
         A                                  8 15'CUST'
         A                                      COLOR(WHT)
         A                                  8 45'HOURS'
         A                                      COLOR(WHT)
         A                                  8 51'SHOP'
         A                                      COLOR(WHT)
         A                                  8 58'OPR'
         A                                      COLOR(WHT)
         A                                  8 62'WORK'
         A                                      COLOR(WHT)
         A                                  8 72'SCHEDULE'
         A                                      COLOR(WHT)
         A                                  9  2'S'
         A                                      COLOR(BLU)
         A                                  9  5'DRAFTER'
         A                                      COLOR(WHT)
         A                                  9 50'ORDER'
         A                                      COLOR(WHT)
         A                                  9 23'JOB NAME'
         A                                      COLOR(WHT)
         A                                  9 15'ORDER'
         A                                      COLOR(WHT)
         A                                  9 72'DATE'
         A                                      COLOR(WHT)
         A                                  9 45'REM'
         A                                      COLOR(WHT)
         A                                  9 58'NO'
         A                                      COLOR(WHT)
         A                                  9 62'CENTER'
         A                                      COLOR(WHT)
         A                                 10  2'-----------------------------------
         A                                      ------------------------------------
         A                                      ---------'
         A                                      COLOR(WHT)
         A            CURSPOS        5S 0H
         A            MRRRN          4S 0H
         A            RRN            4S 0H      SFLRCDNBR(CURSOR)
    When I debug it, the data looks ok to me. Its not actually writing the same data twice...

    I thought maybe it had something to do with my RRNs but I've compared this code to other working code that I have and I can't seem to find what is wrong. The only thing that is different (other than the fact that its now in /free) is the way I'm handling my INDDS... I'm using Tom's method for it by using INFDS instead... I can't figure out what's going on with this...
    Last edited by bryce4president; July 29, 2008, 08:53 AM.
    Your future President
    Bryce

    ---------------------------------------------
    http://www.bravobryce.com

  • #2
    Re: I can't find why this would write a duplicate record

    NEVERMIND! you can't see the problem in the code provided.
    Your future President
    Bryce

    ---------------------------------------------
    http://www.bravobryce.com

    Comment


    • #3
      Re: I can't find why this would write a duplicate record

      Originally posted by bryce4president View Post
      NEVERMIND! you can't see the problem in the code provided.
      i'm guessing you found the problem? (was it user error??)
      I'm not anti-social, I just don't like people -Tommy Holden

      Comment


      • #4
        Re: I can't find why this would write a duplicate record

        yeah.... it helps if you reference the correct rrn
        Your future President
        Bryce

        ---------------------------------------------
        http://www.bravobryce.com

        Comment


        • #5
          Re: I can't find why this would write a duplicate record

          Pebkac!!!!!!

          Comment


          • #6
            Re: I can't find why this would write a duplicate record

            haha, hey Rick. Good to see you around. Can we assumed that the interview for your job was a success?
            Your future President
            Bryce

            ---------------------------------------------
            http://www.bravobryce.com

            Comment

            Working...
            X