
//****************************************************************
// PROGRAM NAME: SCHNAM *
// RELATED FILES: CUSMSTL3 (LOGICAL FILE) *
// SCHNAMD (WORKSTN FILE) *
// DESCRIPTION: This program shows a customer master search *
// program using workstn subfile processing. *
// This program prompts the user for the customer*
// name and uses it to position the cusmstl3 *
// file by the setll operation. Then it displays *
// the records using subfiles. *
// To fill another page, press the rollup key. *
// To display customer detail, enter 'X' beside *
// that customer and press enter. *
// To quit the program, press PF3. *
//****************************************************************
Fcusmstl3 if e k disk
Fschnamd cf e workstn sfile(subfile:recnum)
F indds(indicators)
// Field definitions:
D recnum s 5p 0
D indicators ds
D exitKey n overlay(indicators:3)
D restartKey n overlay(indicators:4)
D sflClear n overlay(indicators:55)
D rollupKey n overlay(indicators:95)
// Key list definitions:
C cstkey klist
C kfld srcnam
C namekey klist
C kfld name
//******************************************************************
// MAINLINE *
//******************************************************************
/free
write foot1;
write head;
exfmt prompt;
// loop until exit key is pressed
dow not exitKey;
setll cstkey cusrec;
exsr ProcessSubfile;
exsr DisplayCustomerDetail;
// If exit key pressed in subfile display, leave loop
if exitKey;
leave;
endif;
// If restart key pressed in subfile display, repeat loop
if restartKey;
iter;
endif;
write foot1;
write head;
exfmt prompt;
enddo;
*inlr = *on;
//*****************************************************************
// SUBROUTINE - ProcessSubfile *
// PURPOSE - Process subfile and display *
//*****************************************************************
begsr ProcessSubfile;
// Keep looping while roll up key is pressed
dou not rollupKey;
// Do we have more information to add to subfile?
if not %eof(cusmstl3);
// Clear and fill subfile with customer data
exsr ClearSubfile;
exsr FillSubfile;
endif;
// Write out subfile and wait for response
write foot2;
exfmt subctl;
enddo;
endsr; // end of subroutine ProcessSubfile
//******************************************************************
// SUBROUTINE - FillSubfile *
// PURPOSE - Fill subfile *
//******************************************************************
begsr FillSubfile;
// Loop through all customer records
recnum = 0;
dou %eof(schnamd);
// Read next record
read cusrec;
if %eof(cusmstl3);
// If no more records, we're done
leavesr;
endif;
// Add information about this record to the subfile
recnum = recnum + 1;
sel = *blank;
write subfile;
enddo;
endsr; // end of subroutine FillSubfile;
//****************************************************************
// SUBROUTINE - ClearSubfile *
// PURPOSE - Clear subfile records *
//****************************************************************
begsr ClearSubfile;
sflClear = *on;
write subctl;
sflClear = *off;
endsr; // end of subroutine ClearSubfile
//*****************************************************************
// SUBROUTINE - DisplayCustomerDetail *
// PURPOSE - Display selected customer records *
//*****************************************************************
begsr DisplayCustomerDetail;
// Loop through all changed record in subfile
readc subfile;
dow not %eof(schnamd);
// Restart the display of requested customer records
restartKey = *on;
// Lookup customer record and display it
chain namekey cusrec;
exfmt cusdsp;
// If exit key pressed, exit loop
if exitKey;
leave;
endif;
readc subfile;
enddo;
endsr; // end of subroutine ChangeSubfile
/end-free
The file description specifications identify the disk file to be searched
and the display device file to be used (SCHNAMD). The SFILE keyword for the
WORKSTN file identifies the record format (SUBFILE) to be used as a subfile.
The relative-record-number field (RECNUM) specifies which record within the
subfile is being accessed.
The program displays the PROMPT record format and waits for the workstation user's response. F3 sets on indicator 03, which controls the end of the program. The name (NAME) is used as the key to position the CUSMSTL3 file by the SETLL operation. Notice that the record format name CUSREC is used in the SETLL operation instead of the file name CUSMSTL3.
In Figure 2, the user responds to the initial prompt by entering a customer name.
22:35:26 CUSTOMER SEARCH & INQUIRY BY NAME 9/30/94
Enter Search Name JUDAH GOULD
ENTER - Continue F3 - End Job
The user requests more information by entering an X as shown in Figure 3.
22:35:43 CUSTOMER SEARCH & INQUIRY BY NAME 9/30/94
Search Name JUDAH GOULD
Select
"X" Customer Name Number Zip Code
X JUDAH GOULD 00012 70068
JUDAH GOULD 00209 31088
ENTER - Continue F3 - End Job F4 - Restart Name
The detailed information for the customer selected is shown in Figure 4. At this point the user selects the appropriate function key to continue or end the inquiry.
23:39:48 CUSTOMER SEARCH & INQUIRY BY NAME 9/30/94
Customer 00012
Name JUDAH GOULD
Address 2074 BATHURST AVENUE
City YORKTOWN
State NY Zip Code 70068
A/R Balance .00
ENTER - Continue F3 - End Job F4 - Restart Name