× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




With a cursory glance at your code, I think the following is your problem.
The update to SSW85 has to take place DIRECTLY AFTER reading/chaining of
SSW85. In your loop you read SSW85, then read and update other files before
the update of SSW85. The way around this is to save the keys for the record
you are reading and then chain that same record, change the fields where
necessary, and the update SSW85, with NO OTHER reads/updates of any
description to ANY OTHER files.



Alan Shore

NBTY, Inc
(631) 244-2000 ext. 5019
AShore@xxxxxxxx


                                                                       
             "Brian                                                    
             Piotrowski"                                               
             <bpiotrowski@simc                                          To
             oeparts.com>              "RPG programming on the AS400 / 
             Sent by:                  iSeries" <rpg400-l@xxxxxxxxxxxx>
             rpg400-l-bounces@                                          cc
             midrange.com                                              
                                                                   Subject
                                       Update Operation Failure Help   
             06/02/2006 11:33          Please                          
             AM                                                        
                                                                       
                                                                       
             Please respond to                                         
              RPG programming                                          
              on the AS400 /                                           
                  iSeries                                              
             <rpg400-l@midrang                                         
                  e.com>                                               
                                                                       
                                                                       




Hi All,



Can someone give me a hand trying to figure out why I can't update a
record when data has changed?  In my code, I have an update operation
near the end of the loop.  Whenever my program hits this statement, I
get an "Update or delete in file SSW85 without prior input operation."
error.



I know there are values changing because I have traced one of the values
to see if it changes.  For example, when I enter the loop, the field
"QUARTER" is blank.  However, after I do a %lookup on the index, the
value becomes "Q3".



Here's my current code:

         SetLL *LOVAL ssw85;

         prevSCAC = '';

         prevTRLR = '';

         read ssw85;

         DoW not %eof();

            select;

              when trlstat = 'D' and ordersts <> 'R';

                ordersts = 'R';

              when trlstat = 'E' and ordersts <> 'R';

                ordersts = 'R';

              when trlstat = 'R' and ordersts <> 'R';

                ordersts = 'R';

            ENDSL;

         if suppname = *BLANKS;

      /end-free

     C/Exec SQL

     C+ update SSW85 set suppname = (select min(scsnm) from SSM01

     C+ where concat(ssm01.sccd,ssm01.sclc)

     C+ = concat(ssw85.suppcode,ssw85.supploc))

     C+ where suppcode = :suppcode and supploc = :supploc

     C/End-Exec

     C*

      /free

           ENDIF;

       if ordersts = *BLANK;

      /end-free

     C/Exec SQL

     C+ select count(*) into :ASNCOUNT from sst02

     C+ where asodtp =:ordertyp and asodno =:ordernum and asplcd = :plcd

     C/End-Exec

      /free

       if SQLCOD <> 0;

         ASNCOUNT = 0;

       ENDIF;

      /end-free

     C*

     C/Exec SQL

     C+ select count(*) into :INVCOUNT from sst37

     C+ where ivodtp =:ordertyp and ivodno =:ordernum  and ivplcd =
:plcd

     C+ and ivrvdt <> 0

     C/End-Exec



      /free

         if SQLCOD <> 0;

           INVCOUNT = 0;

         ENDIF;

         ORDCOUNT = ASNCOUNT - INVCOUNT;

         Select;

           When ORDCOUNT = ASNCOUNT;

             OSTATUS = 'O';

           When INVCOUNT < ASNCOUNT;

             OSTATUS = 'P';

           When ORDCOUNT = 0;

             OSTATUS = 'R';

         ENDSL;

      /end-free

     C/Exec SQL

     C+ update ssw85 set ordersts = :OSTATUS

     C+ where plantcde = :plantcde and ordertyp=:ordertyp

     C+ and ordernum = :ordernum

     C/End-Exec

      /free

       ENDIF;

         curSCAC = scaccode;

         curTRLR = trlrnum;

         if %trim(curscac)+%trim(curtrlr) =
%trim(prevSCAC)+%trim(prevTRLR);

           quarter = curQTR;

         else;

           idxQTR =
%lookup((%char(pseqrrn)+%trim(%char(pseqsub))):arrPRODSEQ);

           quarter = arrQTR(idxQTR);

           curQTR = quarter;

           prevSCAC = curSCAC;

           prevTRLR = curTRLR;

         ENDIF;

         update rssw85;

         read ssw85;

       Enddo;



Thanks in advance for any ideas.  I'm sure it's something pretty
obvious, but I'm having trouble trying to figure out what it is.



Brian.



-=-=-=-=-=-=-=-=-=-=-=-=-=-

Brian Piotrowski

Specialist - I.T.

Simcoe Parts Service, Inc.

Ph: 705-435-7814 x343

Fx: 705-435-6746

-=-=-=-=-=-=-=-=-=-=-=-=-=-



--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.