Readc with Chain in rpgle

I have a window subfile with few output fields and one character option field. I want user to enter 'X' in option field. if he enters wrong option I simply highlight fields my problem is: fields get highlighted but users input value does not retain in option fields. It gets disappeared. I am using following technique:

DOW not *IN26; write sflctl; write footer; read sflctl; readc sfl; dow not %eof(); chain rrn sfl; if %found(); if fldoption <> 'X' and fldoption <> *blanks; *IN25 = *on; //highlight; flag_ok = 0; update sfl; elseif fldoption = 'X'; flag_ok = 1; *in25 = *off; endif; endif; if flag_ok = 1; *IN26 = *ON; else; *IN26 = *OFF; endif; readc sfl; enddo;
enddo;

fields get highlighted exactely but wrong value in fldoption doesn't retain there. Where I am doing mistake as I am just 4 months old in RPG.

Thanks in advance.

2

2 Answers

Your option field may be defined with usage I input only, and if so, should be changed to B both (input & output).

Once you have used READC to read a subfile record, there should be no need to CHAIN to the same record.

When I rewrite a subfile record showing errors, I sometimes use the SFLNXTCHG keyword on the subfile record, which will set the record-level MDT (modified data tag). Then after I have re-executed the screen, and go through a READC loop again, this subfile record will be found as one of the changed records, even if the user has not touched it again.

One point to check wil be the field usage option whether it is B or I as mentioned by Warren. Altogether, if you are not doing this validation for any specific reasons. Why don't use the field level keyword VALUES in the display file itself? which can take away few lines of codes.

And since its Window subfile why don't use Change(NN) record level keyword with indicator to capture change and read again even SFLNXTCHG also can be used. yes options are many but important thing is it should do the intend.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like