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.

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.

             //position the VARPG pointer to the top of the subfile (equivalent to a SETLL *LOVAL on a file)
       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;

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

       //leave the routine so the user can correct the error

       //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');
       sflx = sflx + 1;
       readc linerdet;


This was first published in December 2005

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

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
Sort by: OldestNewest

Forgot Password?

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

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.