Friday, July 18, 2008

1.Message file

Using Message file to display the error message in the 24th line along with the error value entered in the respective field.

In General WRKMBRPDM, when you press an invalid option in front of the member, say 22, you get the error message ‘Option 22 is not valid’. So here the system takes in the wrong value entered and displays it in the message column.

This can be done through message file.

Firstly, create a message file say MSGF1 using the CRTMSGF command.
Now you need to add a message description to this message file.
Use the ADDMSGF command for this.
You need to type a 7-length user-defined MSGID in the Message Identifier parameter
The created message file(MSGF1) and the library name are specified.

Then in the first-level message text, the error message is typed. The error value is denoted by &n where n=1,2,3 and so on. For example, here you can give
‘Option &1 is not valid’.

Optionally a second level message text can also be given which is populated when you press F1 over the first-level error.

This &1 denotes the error variable. This field’s formats need to specified in the ‘Message data field formats’ parameter where you give the datatype, length and field position. The variable which should be picked by the system to show the error and the above-declared field should be of the same datatype and length.
For instance, you declare a name field with a length 10. If someone types a number say 12345 on the name field, the error message should be ‘Option 12345 is not valid’. Here ‘12345’ is referred by &1. So both this field and the name field should be of the same datatype and length.

Now coming to the display file, you need to declare a Program-to-system field. Press F4 from the design screen and you will have a list of variables used in the program and some options to add more variable. Right down at the bottom, just above the function keys, you will have an option to add a Program-to-system field. Give the sequence number, name of the field and the length and create the field.

Now press * before the field from which the value needs to be captured. You will get the ‘Select Field Keywords’ display. Go to ‘Error messages’ option where you get two panes. Go to the bottom pane where there are 5 options to specify the ERRMSGID along with the Message file. Here you need to specify an indicator, the message identifier you created in the message file, the filename and library name and also the name of the field. Note that this name should be equal to the name of the Program-to-system field that was just declared.

The first entry will correspond to &1 in the message file description. The second entry will correspond to &2 and so on.

In the program, the code needs to be written in such a way that the indicator is switched on when a wrong value is typed. And hence the error message is displayed below.

No comments: