Coding Standards for Database Files › Command Coding Conventions › Command processing programs (CPP)
Command processing programs (CPP)
A command-processing program is the program to which a command hands control once it has validated the entry parameters. Command processing programs are normal CL or other HLL programs to which some extra considerations should be applied.
You should ensure that your CPPs handle processing and messages in a manner that is consistent with standard CL command usage. In particular:
- Processing to check for the presence of all required objects and the authorization to use those objects should be carried out before any processing which changes any data or objects starts. This helps to ensure that the command runs cleanly: either it functions completely, or not at all. The CL Check Object (CHKOBJ) command is a relatively fast operation.
- If errors occur in a command-processing program, the errors should be retransmitted to the invoking program. An escape message should be sent, preceded by diagnostic messages if appropriate. This will help the user to diagnose the cause of the fault. Refer to the chapter on CL programming for an example.
- Command-processing programs should send a completion message, containing substitution data if relevant; for example, "Object FRED deleted". The substitution data should be as specific as possible.
- Command processing programs should remove irrelevant messages from the log, in other words from the program message queue of the receiving program. This can be achieved using the OS/400 Receive message (RCVMSG) command.
For example:

Command processing programs that process generic lists of items should be structured so that:
- A diagnostic or a completion message is sent to the CPP for each item processed; for example "Object &1 already exists - ignored".
- An overall completion message is sent to the program that invokes the command; for example "&1 objects successfully processed, &2 errors".
Note: It is particularly important to do this so that the user can determine which items the command has actually processed.