Module custquery.4gl (function inpupd_cust)

A new function, inpupd_cust, is added to the custquery.4gl module, allowing the user to insert values for a new customer row into the form.

Function inpupd_cust (custquery.4gl):
01 FUNCTION inpupd_cust(au_flag)  
02   DEFINE au_flag CHAR(1),
03          cont_ok SMALLINT
04
05   LET cont_ok = TRUE 
06
07
08   IF (au_flag = "A") THEN
09     MESSAGE "Add a new customer"
10     INITIALIZE mr_custrec.* TO NULL
12   END IF
13
14   LET INT_FLAG = FALSE
15
16   INPUT BY NAME mr_custrec.*
17         WITHOUT DEFAULTS ATTRIBUTES(UNBUFFERED) 
18
19   ON CHANGE store_num 
20     IF (au_flag = "A") THEN
21       SELECT store_name, 
22              addr,
23              addr2, 
24              city, 
25              state, 
26              zip_code,
27              contact_name, 
28              phone 
29         INTO mr_custrec.*
30         FROM customer 
31         WHERE store_num = mr_custrec.store_num 
32       IF (SQLCA.SQLCODE = 0)THEN
33         ERROR "Store number already exists."
34         LET cont_ok = FALSE
35         CALL display_cust()
36         EXIT INPUT
37       END IF
38     END IF
39
40   AFTER FIELD store_name 
41     IF (mr_custrec.store_name IS NULL) THEN
42       ERROR "You must enter a company name."
43       NEXT FIELD store_name 
44     END IF
45
46   END INPUT
47
48   IF (INT_FLAG) THEN
49     LET INT_FLAG = FALSE
50     LET cont_ok = FALSE
51     MESSAGE "Operation cancelled by user"
52     INITIALIZE mr_custrec.* TO NULL
53   END IF
54  
55   RETURN cont_ok 
56
57 END FUNCTION