Analyzing the report field on IBM i
The MDREP field contains subfields. Because of this, some applications need to check whether the sender of the message requested a particular report. Those applications should use the technique described in this topic.
Use arithmetic
The following steps should be performed using integer arithmetic:- Select one of the following values, according to the type of report to be checked:
- ROCOA for COA report
- ROCOD for COD report
- ROEXC for exception report
- ROEXP for expiration report
Call the value A.
- Divide the MDREP field by A ; call the result B.
- Divide B by 8 ; call the result C.
- Multiply C by 8 and subtract from B ; call the result D.
- Multiply D by A ; call the result E.
- Test E for equality with each of the values that is possible for that type of report.
For example, if A is ROEXC, test E for equality with each of the following to determine what was specified by the sender of the message:
- RONONE
- ROEXC
- ROEXCD
- ROEXCF
The tests can be performed in whatever order is most convenient for the application logic.
The following pseudocode illustrates this technique for exception report messages:
A = ROEXC B = Report/A C = B/8 D = B - C*8 E = D*A
A similar method can be used to test for the ROPMI or ROPCI options; select as the value A whichever of these two constants is appropriate, and then proceed as described previously, but replacing the value 8 in the previous steps by the value 2.
Parent topic: Report options and message flags on IBM i