&<img src="../resources/images/opentocr.png" title="Open Contents list" border="0"&>
You are here:
Modify the previous inquiry function to also maintain records in the file.
Files Involved
Physical file CUSMST (customer master file)
RDML Program
GROUP_BY NAME(#CUSTOMER) FIELDS((#CUSTNO *NOCHG)
#NAME #ADDL1 #ADDL2 #ADDL3)
BEGIN_LOOP
REQUEST FIELD(#CUSTNO)
FETCH FIELDS(#CUSTOMER) FROM_FILE(CUSMST)
WITH_KEY(#CUSTNO)
IF_STATUS IS(*OKAY)
SET_MODE TO(*DISPLAY)
DISPLAY FIELDS(#CUSTOMER) CHANGE_KEY(*YES)
IF_MODE IS(*CHANGE)
UPDATE FIELDS(#CUSTOMER) IN_FILE(CUSMST)
VAL_ERROR(*LASTDIS)
ENDIF
ELSE
MESSAGE MSGTXT('No customer exists with this number')
ENDIF
END_LOOP
Points to Note:
So the possibility arises that another user could update the record in the interval between the FETCH and the UPDATE. This interval could be 30 minutes if the user decided to go to lunch.
If file CUSMST is created and maintained by LANSA this will not be a problem because the UPDATE command automatically checks for a change to the record in the interval between reading it and updating it. If another user has changed the record in the interval ..... the UPDATE command will act exactly as if a validation error had occurred and automatically issue a message indicating that the update was rejected. This will cause the DISPLAY screen to be re-displayed with an error message.
&<img src="../resources/images/opentoc-dark.png" title="Open Contents List" border="0"&>