VARPG -- Reprocess changed records

Scenario: You're validating data in changed records of a subfile, but you need to keep those records in a changed status to be processed by a future readc operation.

Scenario: You're validating data in changed records of a subfile, but you need to keep those records in a changed...

status to be processed by a future readc operation.

When you set up a readc loop to read changed records, after every readc operation the record will no longer be a "changed" record and therefore will not be processed by a future readc loop (writing, deleting or updating the record in the database.)

You will need to use the sflnxtchg function in Visual Age RPG (VARPG) to "mark" a record changed after it has been read by a readc operation.

 
/free
             //position the VARPG pointer to the top of the subfile (equivalent to a SETLL *LOVAL on a file)
       %setatr('LinerOrder':'linerdet':'startat')=1;
       readc linerdet;
       dow not %eof;
       //if the quantity field in the subfile is zero, display an error message and set the gui focus to the subfile
       if qty = 0;
       dsply *msg0005;
       %setatr('Linerorder':'linerdet':'Focus')=1;

       //set the record to be a changed record for future processing

       %setatr('LinerOrder':'linerdet':'sflnxtchg')=1;
       //leave the routine so the user can correct the error
       return;
       endif;

       //otherwise the record has changed and passes the validation, so set it to be read as a changed record
       //but start the processing on the next record.  (This prevents an endless loop).
       sflx = %getatr('Linerorder':'linerdet':'index');
       %setatr('LinerOrder':'linerdet':'sflnxtchg')=1;
       sflx = sflx + 1;
       %setatr('LinerOrder':'linerdet':'startat')=sflx;
       readc linerdet;

       enddo;
/end-free


This was last published in December 2005

Dig Deeper on RPG iSeries programming

Start the conversation

Send me notifications when other members comment.

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

Please create a username to comment.

-ADS BY GOOGLE

SearchEnterpriseLinux

SearchDataCenter

Close