Now you will define process module XXXDUPD-ENTER for dialog XXXDUPD. This process module will be executed when the end user presses [Enter].
Process XXXDUPD-ENTER allows an end user to specify a department, verify that the correct department is specified, and then enter modification or deletion instructions by performing the following processing:
To enable process module XXXDUPD-ENTER to perform the above processing, commands in the process module store and evaluate a status value in element XXX-WK-FIRST-TIME:
Before redisplaying the screen to the end user, the response process changes the value in element XXX-WK-FIRST-TIME from Y to N.
After processing the department, the response process resets the value in element XXX-WK-FIRST-TIME from N to Y.
Process module XXXDUPD-ENTER is shown below. Statements that retrieve the specified department from the database, modify the department, and delete the department are organized into subroutines.
READY USAGE-MODE UPDATE.
-┐
IF AGR-CURRENT-RESPONSE NE SPACES │
AND NO FIELDS CHANGED │
AND XXX-WK-FIRST-TIME EQ 'Y' │ 1
THEN │
EXECUTE NEXT FUNCTION. -┘
IF XXX-WK-FIRST-TIME EQ 'Y' -┐
THEN │ 2
CALL FRSTRTN. -┘
IF AGR-CURRENT-FUNCTION EQ 'MODDEP' -┐
THEN │
CALL MODRTN. │ 3
ELSE │
CALL DELRTN. -┘
DEFINE FRSTRTN. -- 4
OBTAIN CALC DEPARTMENT. -- 5
IF DB-REC-NOT-FOUND -┐
THEN │
DISPLAY MSG TEXT │ 6
'DEPARTMENT DOES NOT EXIST--SPECIFY A DIFFERENT DEPARTMENT'.│
-┘
ELSE DO. -┐
MOVE 'N' TO XXX-WK-FIRST-TIME. │ 7
PROTECT FIELD DEPT-ID-0410 TEMPORARY. -┘
IF AGR-CURRENT-FUNCTION EQ 'MODDEP' -┐
THEN │
DISPLAY MSG TEXT │
'MODIFY DEPARTMENT AND PRESS ENTER (PA2 TO CANCEL)'. │
│ 8
ELSE │
DISPLAY MSG TEXT │
'PRESS ENTER TO DELETE THIS DEPARTMENT (PA2 TO CANCEL)'.│
-┘
END.
DEFINE MODRTN. -- 9
MODIFY DEPARTMENT. -- 10
INITIALIZE (DEPARTMENT). -┐
│
MOVE 'Y' TO XXX-WK-FIRST-TIME │ 11
DISPLAY MSG TEXT │
'DEPARTMENT MODIFIED--SPECIFY ANOTHER DEPARTMENT TO MODIFY'. -┘
DEFINE DELRTN. -- 12
ERASE DEPARTMENT ALLOWING ('0230'). -- 13
MOVE 'Y' TO XXX-WK-FIRST-TIME. -- 14
IF ERROR-STATUS EQ '0230' -┐
THEN │
DISPLAY MSG TEXT │ 15
'CANNOT DELETE THIS DEPARTMENT--SPECIFY ANOTHER DEPARTMENT'.│
-┘
ELSE DO. -┐
MOVE 'Y' TO XXX-WK-FIRST-TIME. │
INITIALIZE (DEPARTMENT). │ 16
│
DISPLAY MSG TEXT -┘
'DEPARTMENT DELETED--SPECIFY ANOTHER DEPARTMENT TO DELETE'.
END.
1 Transfers control to another application function when the user enters a valid application response and doesn't try to input other information on the screen.
2 The first time this process is executed for a given department. subroutine FRSTRTN is called.
3 The next time the process is executed for the department, the appropriate subroutine is called (MODRTN for function MODDEP or DELRTN for function DELDEP).
FRSTRTN subroutine
4 Subroutine FRSTRTN begins.
5 Uses the department ID supplied by the user to retrieve the department.
6 If the specified department does not exist in the database, the dialog's map is redisplayed with the DEPARTMENT DOES NOT EXIST error message.
7 If the department does exist, the flag in XXX-WK-FIRST-TIME is set to N (NO) and the map field that displays department ID numbers is temporarily protected from user input.
8 The retrieved department record is displayed on the dialog's map with an appropriate message.
MODRTN subroutine
9 Subroutine MODRTN begins.
10 The department is modified in the database based on the user's input.
11 After the department is modified, dialog buffers for DEPARTMENT data are initialized, the flag in XXX-WK-FIRST-TIME is reset to Y (YES), and the map is redisplayed with a confirming message.
DELRTN subroutine
12 Subroutine DELRTN begins.
13 The department is deleted from the database. Your code tests for errors that cause error code 0230 (see below).
14 Resets the flag in XXXWK-FIRST-TIME to Y (YES).
15 If status code 0230 is returned, the department cannot be deleted because it owns other records (for example, employee records). In this case, the map is redisplayed with a message and the department is not deleted.
16 After the department is deleted, dialog buffers are initialized and the dialog's map is redisplayed with a confirming message.
Specifying Basic Information for the Process Module
To specify basic information for process module XXXDUPD-ENTER, you use the IDD Process Entity screen:
-> proc
[Enter]
Enter the screen identifier (PROC) in the command area.
Enter the indicated specifications on the Process Entity screen. Don't forget to deselect the DISPLAY action.
IDD REL 15.0 *** PROCESS ENTITY *** PROC -> DICT=DEMO DISPLAY PROCESS NAME....: xxxdupd-enter _ MODIFY x ADD VERSION NUMBER..: 1 _ HIGHEST _ NEXT HIGHEST _ DELETE _ LOWEST _ NEXT LOWEST DESCRIPTION.....: retrieve dept and then mod/del dept
[Enter]
Entering Source Statements for the Process
To enter source commands for a process module, you display and use the Process Source screen, as shown below for process XXXDUPD-ENTER:
-> srcs
[Enter]
SRCE identifies the Process Source screen.
The Process Source screen is displayed. Enter a full screen of source statements. Enter keywords, periods, and quotes as shown below. Don't type characters beyond column 72.
For more information on entering, moving, and deleting text on the Process Source screen, refer to CA IDMS Common Facilities Guide
After you type the first page of source commands for the process module, open up new lines at the end of the Process Source screen by performing the following steps:
You can press [PF5] (default) at any time to apply the new lines to the work file maintained by the IDD menu facility.
For process module XXXDUPD-ENTER, you open up new lines at the end of the Process Source screen and enter more source commands. Place the cursor on the final line of text and press the control key that inserts new lines on IDD screens at your site.
IDD REL 15.0 *** PROCESS SOURCE *** SRCE -> NO DATA LINES CURRENTLY EXIST PROCESS 'XXXDUPD-PREMAP' VERSION 1 ---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+---- ready usage-mode update ! if agr-current-response ne spaces and no fields changed and xxx-wk-first-time eq 'y' then execute next function. ! if xxx-wk-first-time eq 'y' then call frstrtn. ! if agr-current-function eq 'moddep' then call modrtn. else call delrtn. ! define frstrtn.
[PF4]
Add source statements to the end of the process. Notice that the final line from the previous page of the Process Source screen is displayed as the first line of this screen.
IDD REL 15.0 *** PROCESS SOURCE *** SRCE -> INSERTING NEW DATA LINES PROCESS 'XXXDUPD-PREMAP' VERSION 1 ---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+---- DEFINE FRSTRTN. obtain calc department. if db-rec-not-found then display msg text 'department does not exist--specify a different department'. ! else do. move 'n' to xxx-wk-first-time protect field dept-id-0410 temporary. ! if agr-current-function eq 'moddep' then display msg text 'modify department and press enter (pa1 to cancel) '. ! else display msg text 'press enter to delete this department (pa1 to cancel) '.
[PF4]
Place the cursor on the final source line and use [PF4] to insert another page of source statements.
IDD REL 15.0 *** PROCESS SOURCE *** SRCE -> INSERTING NEW DATA LINES PROCESS 'XXXDUPD-PREMAP' VERSION 1 ---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+---- 'PRESS ENTER TO DELETE THIS DEPARTMENT (PA2 TO CANCEL)'. end ! define modrtn. modify department. ! initialize (department). ! move 'y' to xxx-wk-first-time display msg text 'department modified--specify another department to modify'. ! define delrtn. erase department allowing ('0230'). ! move 'y' to xxx-wk-first-time ! if error-status eq '0230' then
[PF4]
Entering the Final Page of Source Statements
Type source statements on the screen. Don't forget to place the periods outside of the single quote for DISPLAY commands.
IDD REL 15.0 *** PROCESS SOURCE *** SRCE -> INSERTING NEW DATA LINES PROCESS 'XXXDUPD-PREMAP' VERSION 1 ---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+---- THEN end display msg text 'cannot delete this department--specify another department'. ! else do. move 'y' to xxx-wk-first-time initialize (department). ! display msg text department deleted--specify another department to delete'. end.
[Enter]
After you press [Enter], IDD adds the process module source commands to the data dictionary, and then redisplays the Process Source screen with a message like:
PROCESS 'XXXDUPD-ENTER' VERSION 1 MODIFIED
It is a good idea at this stage to inspect the process module for any syntax errors (such as omitted single quotation marks or periods). You can page the Process Source screen forward and backward:
If you notice any errors, you can type over the errors to correct them. After you correct all errors, you can press [Enter] again.
After you finish defining process module XXXDUPD-ENTER, you can define process XXXDUPD-PA2.
|
Copyright © 2013 CA.
All rights reserved.
|
|