There are many cases where file maintenance programs are also used as inquiries (the PDM is a good example with...
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
its options 2 and 5).
When you use this approached you need to take some extra steps:
- You add to the program a mode parameter to govern its functions (e.g. '*UPD' or '*INQ').
- Based on the mode parameter you will have to inhibit the program functions that deals with the maintenance:
- Function keys that deals with maintenance.
- Write/update/delete code.
- Make sure you get files data without locking records.
- You will have to protect all the input fields.
This is the biggest and most boring step. You will have to look for all the input field and add to them the DSPATR(PR) keyword.
This tip might help since it will take care of all the fields in one easy step. Another benefit is that it will take care of new fields that might be added to the input records in the future.
---- * * Normal record with input fields A R RCRD01 CF10 CA12 OVERLAY A FIELD01 R B 7 17 A FIELD02 R B 8 17 . . . * * footer record with be used in '*UPD' mode. A R FOOT01 OVERLAY A A 10 29'F10=Update' A 22 29'F12=Cancel' * * footer record with be used in '*INQ' mode. * the PROTECT keyword will protect all input-capable fields * already displayed. * A R FOOT02 A CA12 A OVERLAY PROTECT A HIDEME 1 I 23 2DSPATR(ND) A DSPATR(PC) A 22 29'F12=Cancel' I add a new record to the display file FOOT02 The RPG code changed to take into account the non '*UPD' mode Ffile01 uf a E k disk C *entry plist C parm PgmMod * * Lock the record based on PgmMod C if PgmMod = '*UPD' C klist02 chain file01 C else C klist02 chain(n) file01 C EndIf * C select C when PgmMod = '*UPD' C write FOOT01 C exfmt RCRD01 C when PgmMod = '*INQ' C write RCRD01 C exfmt FOOT02 C EndIf * C
MORE INFORMATION ON THIS TOPIC
The Best Web Links: tips, tutorials and more.
Ask your programming questions--or help out your peers by answering them--in our live discussion forums.
Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.