In this lesson we create another CUSTOMER enquiry program. In this one, however, access is by customer name rather than by customer number. This makes the finished program more user friendly since the user is more likely to know customers by their names than by their numbers. The program uses the Scan if no match search method and INDEX_CUST_NAME, which is the secondary index of the CUSTOMER table.
1. Start the Program Editor and create a new program called MYPROG5
2. When filling out the program summary, specify the Program Type as Enquiry
3. For the name of the procedure and the procedure body, type C_NAME_ENQUIRY
4. For the procedure overview, just enter a suitable description, e.g. Customer name enquiry
5. For table processing, specify:
· the CUSTOMER table as the main table to process
· Scan if no match as the search method
· INDEX_CUST_NAME as the search index
The Main Table Processing should look like this:
[screenshot goes here]
6. Having specified the CUSTOMER table processing, select Generate Parent Checks, since you also need to access information from parent tables
7. For the screen layout, you can copy the MYPROG4 main map (map number 1) as before, changing the title bar text to reflect the new programs function. There is no need to alter the screen layout, but you must renumber the fields so that CUSTOMER.NAME is field 1. To do this:
8. In the Map Editor select field 2 by double clicking on it.
9. Change the Field Nr to 1, followed by <Enter> or clicking on OK. Confirm your intentions to renumber the field when the Map Editor asks A control with field nr 1 already exists. Renumber fields? Click on Yes. Although this map is, strictly speaking, no longer correctly set up for cursor movement, this does not matter because there is only one input field that the cursor can visit. Save the map and exit from the map editor.
10. Use Generate Field Processing followed by the Field Editing option from the Field Processing tab to ensure that:
· the only input field is CUSTOMER.NAME. This should be field number 1 in the field editing list
· the NAME field at the end of the field editing list is specified as being from the REGION table
Your customer name enquiry program is now complete. Compile and run the program.