Panel validation ensures that user input meets requirements before processing. Return codes indicate how panels were exited, and message handling provides feedback to users. Understanding validation, return codes, and messages is essential for creating robust ISPF panels. This tutorial covers input validation techniques, return code handling, message display, and best practices.
Effective panel validation prevents errors and improves user experience. Return codes enable proper flow control, and messages provide clear feedback. Learning these concepts helps you create professional, user-friendly panels. This tutorial provides practical guidance for validation and error handling.
Panel validation checks input before processing.
Panel validation is:
Validation is performed in:
Various techniques for validating panel input.
Check that required fields are filled:
1234567891011)PROC IF (&ZDSN = '') + DO .MSG = 'Dataset name is required' .RC = 8 END ELSE + DO /* Continue processing */ END )END
This checks if ZDSN is empty and sets an error message if so.
Validate data formats:
Example format validation:
123456)PROC IF (&ZDSN = '') + .MSG = 'Dataset name required' IF (SUBSTR(&ZDSN,1,1) < 'A' | SUBSTR(&ZDSN,1,1) > 'Z') + .MSG = 'Dataset name must start with letter' )END
Validate value ranges:
Validate multiple fields:
12345678910)PROC IF (&ZDSN = '') + .MSG = 'Dataset name required' IF (&ZMEM = '') + .MSG = 'Member name required' IF (&ZDSN <> '' & &ZMEM <> '') + DO /* All validations passed */ END )END
Return codes indicate panel exit conditions.
Return codes indicate:
Common return codes:
Return codes are set using:
Example setting return code:
123456789)PROC IF (&ZDSN = '') + DO .MSG = 'Dataset name required' .RC = 8 END ELSE + .RC = 0 )END
Messages provide feedback to users.
Messages are displayed using:
Error messages indicate problems:
123456)PROC IF (&ZDSN = '') + .MSG = 'Error: Dataset name is required' IF (&ZMEM = '') + .MSG = 'Error: Member name is required' )END
Informational messages provide guidance:
1234)PROC IF (&ZCMD = '') + .MSG = 'Enter a command or press PF3 to exit' )END
Success messages confirm actions:
1234567)PROC IF (&ZCMD = 'S') + DO .MSG = 'Operation completed successfully' .RC = 0 END )END
Common validation patterns for panels.
Standard required field validation:
1234567)PROC IF (&FIELD = '') + DO .MSG = 'Field name is required' .RC = 8 END )END
Format validation example:
123456)PROC IF (LENGTH(&ZDSN) < 3) + .MSG = 'Dataset name too short' IF (INDEX(&ZDSN,'.') = 0) + .MSG = 'Dataset name must contain period' )END
Validating multiple conditions:
123456789101112)PROC &ERROR = '' IF (&ZDSN = '') + &ERROR = 'Dataset name required; ' IF (&ZMEM = '') + &ERROR = &ERROR || 'Member name required' IF (&ERROR <> '') + DO .MSG = &ERROR .RC = 8 END )END
Handling return codes in applications.
In REXX, check return codes:
123456789101112131415/*REXX*/ address ispexec 'DISPLAY PANEL(MYPANEL)' if rc = 0 then do /* User pressed Enter, continue */ end else if rc = 4 then do /* User cancelled */ exit 0 end else do /* Error condition */ say 'Error: RC=' rc exit 8 end
Understanding return code meanings:
Following best practices improves validation quality:
Think of panel validation like checking homework:
So panel validation is like having a teacher check your homework, give you a result (return code), and write notes (messages) to help you fix anything that's wrong!
Complete these exercises to reinforce your validation skills:
Practice basics: add basic validation to a panel, check required fields, set error messages, test validation, and learn basic validation. Master basic validation.
Practice format: add format validation to a panel, validate data formats, test format checks, and learn format validation. Master format validation.
Practice return codes: handle different return codes, test return code handling, understand return code meanings, and learn return code handling. Master return code handling.
Practice messages: display different message types, test message display, understand message usage, and learn message handling. Master message handling.
Practice complete: implement complete validation with multiple checks, handle all return codes, provide comprehensive messages, and learn complete validation. Master complete validation.
1. Where is panel validation typically performed?
2. What return code indicates user pressed Enter?
3. How do you display a message in a panel?
4. What return code typically indicates user cancelled?
5. What happens when validation fails?