&<img src="../resources/images/opentocr.png" title="Open Contents list" border="0"&>
You are here:
4.5.3.1 Data Entry Program
The following is an example of a simple application template for a data entry program:
/ =================================================== /
/ ASK FOR THE "WORD" - ask the user a question. /
/ Note the prompt text and extended prompt text that /
/ can be entered on the command. More detailed help /
/ can also be entered in HELP panels for the template. /
/ Note the special format of the ANSWER parameter. /
/ ==================================================== /
@@QUESTION PROMPT('Supply word to describe+
WHAT this data entry program wo+
rks with') ANSWER(@@CANS001) EX+
TEND('The word you specify here+
is used to build messages that +
appear on the' 'data entry scre+
en panel. You should use ONE wo+
rd only, use lowercase' 'charac+
ters only and only use singular+
form (eg: "customer", "employee+
"' '"order"). Do NOT use more t+
han 18 characters in your answe+
r.' 'Use the HELP function key +
for more information and exampl+
es.') HELPIDS (HELP010 HELP020 +
HELP030 HELP040 HELP050)
/ ====================================================/
/ GET NAME OF JUST ONE PHYSICAL FILE /
/ Ask the user to enter the name of a single primary /
/ file used for data entry. Note the prompt text /
/ and extended prompt text that can be entered on the /
/ command. More detailed help can also be entered on /
/ HELP panels for the template. /
/ ====================================================/
@@GET_FILS TO(1) PROMPT('Enter name of PHYSICAL
file to be used by this template') E+
XTEND('The file name may be specifie+
d partially (to cause a partial' 'li+
st of available files to be displaye+
d), or in left blank (to cause a ful+
l list' 'of available files to be di+
splayed). When a list of files is d+
isplayed,' 'the file required may be+
selected from the list. ' ' ' 'Use t+
he HELP function key for more detail+
s about this template and' 'examples+
of the type of RDML applications it +
can create.') HELPIDS(HELP010 HELP02+
0 HELP030 HELP040 HELP050)
/ =============================================== /
/ GET FIELDS OF CHOSEN FILE INTO LIST 1 /
/ Note that all lists must be defined by an /
/ @@CLR_LST command before being used in an /
/ application template. /
/ =============================================== /
@@CLR_LST NUMBER(1)
@@RTV_FLDS FROM_FILE(1) INTO_LST(1)
/ =============================================== /
/ GET KEYS OF CHOSEN FILE INTO LIST 2 /
/ =============================================== /
@@CLR_LST NUMBER(2)
@@RTV_KEYS OF_FILE(1) INTO_LST(2)
/ ================================================= /
/ GET USER TO CHOOSE FIELDS TO APPEAR ON PANEL /
/ AND PUT RESULTS INTO LIST 3 /
/ Note how the keys of the file are used as a /
/ force list to ensure all the fields are chosen. /
/ Note the column headings for the selection column /
/ and that sequence numbers are pre-filled on all /
/ fields in the selection list. This allows fields /
/ to be ordered in the desired sequence. /
/ ================================================= /
@@CLR_LST NUMBER(3)
@@MAK_LSTS FROM_LSTS(1) FORCE_LSTS(2) INTO_LSTS+
((3 'Fields to' 'Appear on' 'Entry P+
anel' *SEQUENCE *ALL)) HELPIDS(HELP0+
10 HELP020 HELP030 HELP040 HELP050)
/ ============================================== /
/ GET USER TO CHOOSE FIELDS TO WORK WITHIN /
/ PROGRAM AND PUT RESULTS INTO LIST 4 /
/ Note that this list only requires the user to /
/ enter anynon-blank character to select a field./
/ ===============================================/
@@CLR_LST NUMBER(4)
@@MAK_LSTS FROM_LSTS(1) INTO_LSTS((4 'Fields to ' '+
Work with ''in Program ' *YESNO *NO)) H+
ELPIDS(HELP010 HELP020 HELP030 HELP040 H+
ELP050)
/ =================================================== /
/ MERGE FIELDS IN LIST 4 INTO LIST 3 AS *HIDDEN /
/ The fields selected as fields to be worked with in /
/ the program are merged to list 3 with the *HIDDEN /
/ attribute if not already selected in list 3 by the /
/ previous @@MAK_LSTS command. /
/ =================================================== /
@@MRG_LSTS FROM_LSTS((4 *HIDDEN)) INTO_LST(3)
/ =============================================== /
/ ASK HOW THE PANEL IS TO BE DESIGNED /
/ =============================================== /
@@QUESTION PROMPT('Design fields on data entry+
panel DOWN the screen or ACROSS the+
screen') ANSWER(@@CANS002) EXTEND('+
Reply DOWN or ACROSS only.' 'If you+
r data entry panel contains 17 (or +
less) fields, DOWN is the ' 'reco+
mmended value. If your data entry p+
anel contains more than 17' 'fields+
, ACROSS is the recommended value.'+
'Use the HELP function key for more+
information and examples.') LOWER(*+
NO) VALUES(DOWN ACROSS) HELPIDS(HEL+
P010 HELP020 HELP030 HELP040 HELP05+
0)
/ ==================================================/
/ GENERATE THE RDML PROGRAM /
/ The following code consists only of RDML that /
/ will appear in the generated RDML program. /
/ Note the use of special @@ variables in the RDML /
/ commands--these are substituted when the template /
/ is executed. /
/ ================================================= /
@@COMMENT 'Function control options'
FUNCTION OPTIONS(*NOMESSAGES *DEFERWRITE)
@@COMMENT 'Group and field declarations'
/ /
/ The following command will not be accepted by the /
/ CL syntax checker, it must be forced to be accepted /
/ as it will be quite valid when the special variable /
/ @@LST03 is relaced by the list 3 elements when /
/ executing this template. Do not code /
/ FIELDS((#@@LST03))as this will generate /
/ an invalid RDML command. This error /
/ may also be true for other RDML commands. It /
/ will be necessary to force these errors to /
/ be accepted also (e.g. the DESIGN parameter of /
/ the REQUEST command) /
/ /
GROUP_BY NAME(#PANELDATA) FIELDS(@@LST03)
@@COMMENT 'Issue initial data entry message'
MESSAGE MSGID(DCU0010) MSGF(DC@M01) +
MSGDTA('''@@CANS001''')
@@COMMENT 'Do data entry until terminated by +
EXIT or CANCEL'
BEGIN_LOOP
@@COMMENT 'Request user inputs or corrects details'
REQUEST FIELDS(#PANELDATA) DESIGN(*@@CANS002)+
IDENTIFY(*LABEL)
@@COMMENT 'Perform any program level validation here'
BEGINCHECK
ENDCHECK
@@COMMENT 'Attempt to insert data into the data base'
INSERT FIELDS((#PANELDATA)) TO_FILE(@@FNAME01)
@@COMMENT 'If okay, reset fields and issue accepted +
message'
CHANGE FIELD(#PANELDATA) TO(*DEFAULT)
MESSAGE MSGID(DCU0011) MSGF(DC@M01) +
MSGDTA('''@@CANS001''')
END_LOOP
/ =============================================== /
/ CLEAR ALL LISTS USED /
/ At the end of all application templates, it /
/ is suggested that all work lists in the /
/ template are cleared to delete all work records /
/ from the database. /
/ =============================================== /
@@CLR_LST NUMBER(1)
LST NUMBER(2)
@@CLR_LST NUMBER(3)
@@CLR_LST NUMBER(4)
&<img src="../resources/images/opentoc-dark.png" title="Open Contents List" border="0"&>