0 pts.
 rpg
I have created a subroutine to update a display file. key CHAINfile 90 *IN90 IFEQ *OFF MOVELfieldvalue screenvalue EXFMTscreen MOVELscreenvalue filevalue UPDATrecfmt of file END ENDSR Is this logic right? 1.the value in the file is not getting displayed when screen is invoked 2.the field appears blank when updated the file doesnt get updated.

Software/Hardware used:
ASKED: December 9, 2008  4:00 PM
UPDATED: December 10, 2008  2:52 PM

Answer Wiki:
Hi, The logic looks OK. Bear in mind that the record you've CHAINed will be locked until the UPDAT is done. Do you only have one record in your data file with a matching key? It's possible that the CHAIN will work and retrieve the first record with a matching key if you have several records with the same key. Maybe that first record has blanks in the fieldvalue? Regards, Martin Gilbert.
Last Wiki Answer Submitted:  December 9, 2008  5:11 pm  by  Gilly400   23,625 pts.
All Answer Wiki Contributors:  Gilly400   23,625 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

and make sure that the field screenvalue on the screen is coded ‘B’ both input/output.

Current coding might look more like this

key CHAINfile 90
If %found(file)
Eval screenvalue = fieldvalue
EXFMT Screen
Eval fieldvalue = screenvalue
UPDATrecfmt
ENDif
ENDSR

When you make a change on the screen are you pressing the enter key .. or are you pressing a function key?

 44,190 pts.

 

Sorry
First line should read
key CHAINfile
Indicator is not necessary when using the %found

 44,190 pts.

 

hey thanks all….i was able to successfully display value on a screen and update the same.

But i have not handled record lock while doing the update.Can i just add unlck opcode right after updat opcode or is there any other logic.I have done the updation in a seperate subroutine.

 0 pts.

 

Not necesary.
If your program updates the record, it is unlocked.
If your program reads another record the previous one is unlocked– your program can
only lock one record per file (actually one per access path-but that’s another story)
If your program ends with *inlr on the file is closed and the record is unlocked.
If your program closes the file the record is unlocked.

So the unlock is used when your program reads a record (for update) but doesn’t
update it and doesn’t immediately read another record.

The exception to all above (for the experts) is commitment control where a commit may be
required after one of these events to unlock the record.

 44,190 pts.