S6198XINST Ejercicios
S6198XINST Ejercicios
cover
Trademarks
IBM® is a registered trademark of International Business Machines Corporation.
The following are trademarks of International Business Machines Corporation in the United
States, or other countries, or both:
Approach® AS/400® AS/400e™
Balance® DB2® Integrated Language
Environment®
iSeries™ Language Environment® Monday™
Notes® OS/400® Perform™
Redbooks™ RPG/400® System/36™
WebSphere® 400®
Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the
United States, other countries, or both.
Windows is a trademark of Microsoft Corporation in the United States, other countries, or
both.
Pentium is a trademark of Intel Corporation in the United States, other countries, or both.
UNIX is a registered trademark of The Open Group in the United States and other
countries.
Other company, product and service names may be trademarks or service marks of others.
The information contained in this document has not been submitted to any formal IBM test and is distributed on an “as is” basis without
any warranty either express or implied. The use of this information or the implementation of any of these techniques is a customer
responsibility and depends on the customer’s ability to evaluate and integrate them into the customer’s operational environment. While
each item may have been reviewed by IBM for accuracy in a specific situation, there is no guarantee that the same or similar results will
result elsewhere. Customers attempting to adapt these techniques to their own environments do so at their own risk. The original
repository material for this course has been certified as being Year 2000 compliant.
© Copyright International Business Machines Corporation 2002, 2003. All rights reserved.
This document may not be reproduced in whole or in part without the prior written permission of IBM.
Note to U.S. Government Users — Documentation related to restricted rights — Use, duplication or disclosure is subject to restrictions
set forth in GSA ADP Schedule Contract with IBM Corp.
V3.0
Instructor Exercises Guide
TOC Contents
Trademarks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v
Exercises Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Exercises Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
TMK Trademarks
The reader should recognize that the following terms, which appear in the content of this
training document, are official trademarks of IBM or other companies:
IBM® is a registered trademark of International Business Machines Corporation.
The following are trademarks of International Business Machines Corporation in the United
States, or other countries, or both:
Approach® AS/400® AS/400e™
Balance® DB2® Integrated Language
Environment®
iSeries™ Language Environment® Monday™
Notes® OS/400® Perform™
Redbooks™ RPG/400® System/36™
WebSphere® 400®
Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the
United States, other countries, or both.
Windows is a trademark of Microsoft Corporation in the United States, other countries, or
both.
Pentium is a trademark of Intel Corporation in the United States, other countries, or both.
UNIX is a registered trademark of The Open Group in the United States and other
countries.
Other company, product and service names may be trademarks or service marks of others.
Introduction
In this exercise, you will modify a program that displays information
from the Vendor file. You will be given a working program, including
the display file.
You will notice that certain information in the two display file formats is
redundant.
You will include the common information in separate formats and use
the OVERLAY keyword to display the common information and the
variable information.
The display formats, PROMPT_FMT and DSPLY_FMT, will be
modified so they are coresident on the display. Both formats will be
present at the same time, as well as adding the new formats
HEADER_FMT and FKEYS_FMT. The reasons for doing this, and
making the application more complicated, are to:
• Provide a more user-friendly screen interaction. It will not be
necessary to toggle between the two formats, as the program
currently does.
• Facilitate improved screen response, especially noticeable when
the workstations are connected remotely, resulting in reduced
traffic between the system and workstation.
© Copyright IBM Corp. 2002, 2003 Exercise 1. Using OVERLAY and PUTOVR in Display Files 1-1
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
Required Materials
• Student Notebook
• Userid (AS07nnn) and password AS07.
A REF(*LIBL/VENDOR_PF)
A INDARA
A CA03(03 'End Program')
A R PROMPT_FMT
A 1 2USER
A 1 30'Vendor Inquiry'
A COLOR(WHT)
A 1 71SYSNAME
A 2 61DATE
A EDTCDE(Y)
A 2 71TIME
A 3 3'Vendor number. . . . :'
A VNDNBR_INQR D I 3 28COLOR(WHT)
A REFFLD(VNDNBR DICTIONARY)
A 96 ERRMSG('Invalid vendor number - pre -
A ss reset and re-enter' 96)
A 22 3'Please press enter to continue'
A COLOR(BLU)
A R DSPLY_FMT
A CA12(12 'Return to previous display-
A ')
A 1 2USER
A 1 30'Vendor Inquiry'
A COLOR(WHT)
A 1 71SYSNAME
A 2 61DATE
A EDTCDE(Y)
A 2 71TIME
A 7 3'Vendor number . .:'
© Copyright IBM Corp. 2002, 2003 Exercise 1. Using OVERLAY and PUTOVR in Display Files 1-3
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
A VNDNBR R O 7 24
A 8 3'Name . . . . . . :'
A 9 3'Address . . . . :'
A VNDNAME R O 8 24
A VNDSTREET R O 9 24
A VNDCITY R O 10 24
A VNDSTATE R O 10 49
A VNDZIPCODER O 10 53
A 11 3'Telephone. . . . :'
A VNDAREACD R O 11 26
A 11 24'('
A 11 30')'
A VNDTELNO R O 11 33
A EDTWRD('0 - ')
A 12 3'Sales Person . . :'
A VNDSALES R O 12 24
A 13 3'Purchases YTD . :'
A VNDPRCHYTDR 13 24EDTCDE(J)
A 14 3'Balance Owed . . :'
A VNDBALANCER 14 26EDTCDE(J)
A 60 DSPATR(HI)
A 60 COLOR(RED)
A 23 4'F3 = Exit F12 = Return to previou-
A s Display'
A COLOR(BLU)
If %found(Vendor_PF);
If Exit; // F3 pressed
*InLR = *ON;
Return;
Endif;
Uempty
EndDo;
Else;
NotFound = *on;
endif;
enddo;
*InLR = *ON;
//
/END-FREE
© Copyright IBM Corp. 2002, 2003 Exercise 1. Using OVERLAY and PUTOVR in Display Files 1-5
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
__ 3. Use your student notebook to help you to modify the logic of your program using
similar techniques as discussed in the lecture.
END OF LAB
Introduction
In this exercise, you will modify the program and display file from the
first exercise to display a pop up window over the existing window on
the display.
Required Materials
• Student Notebook
• Userid (AS07nnn) and password AS07.
© Copyright IBM Corp. 2002, 2003 Exercise 2. Using DDS Windows 2-1
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
Exercise Instructions
The management team was impressed with the work you did with OVERLAY and
PUTOVR. Response time has improved. One of the sales representatives has requested a
change. Please add a pop up window using the same techniques shown in the lecture. This
pop up window should display the vendor name and the MTD Purchases by that vendor.
Use either the CODE editor or the SEU editor for your coding.
****************Vendor Detail********************
* *
* Vendor Name: Federal Paper *
* MTD Purchased: 60,600.00 *
* *
* *
* Press F12 to Return *
* *
*************************************************
You can make the border any character you like. Center the title as shown. The
information shown on the format is available from the database record that you have
already read. Allocate enough space to hold the data above.
If necessary, review the field definitions in the DICTIONARY Field Reference file.
This member is in your QDDSSRC file, and, is also listed in the appendix.
Enable CA12 in the window and use it to return to the main application display.
__ 5. Compile the DSPF, VNDINQPU and make any necessary corrections.
Uempty __ 4. In your calculations, you will need to test for the user’s having pressing F4. This
should be performed as part of processing a record that was found. When F4 is
pressed, you should display the popup window. Be sure that you only do this for a
valid vendor number.
__ 5. Compile your VNRINQPU program. Correct any compilation errors. Ask your
instructor for assistance as needed.
__ 6. Test your popup window by calling your main program, VNRINQPU. Enter a valid
vendor number; then, press F4 to display details (MTD purchase data) for this
vendor. Exit your window by pressing F12. Your original screen from VNRINQPU
should be restored.
__ 7. Further test your popup window by entering an invalid vendor number. When you
get the error message, reset the display and press F4. The popup should not be
displayed. Enter a valid number and F4; your popup should display.
Instructor note:
The students will discover that both the F12 and the enter key are active in the DDS Popup
window. If some ask about this, you may explain that we chose to simplify the exercise and
not cover the addition keywords and techniques to disable the enter key. Ask the students
to explore the DDS DSPF manual and try different keywords. Discuss this issue as
required following completion of the exercise. A better way to handle windows is to code
the supporting program as a separate module and call it. In this way, you avoid this
particular problem.
In addition, the students may encounter an error that an ‘invalid vendor number was
entered’ when they press F4. The fix is to code the PUTOVR keyword at the record level
for the Prompt_Fmt.
END OF LAB
© Copyright IBM Corp. 2002, 2003 Exercise 2. Using DDS Windows 2-3
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
Introduction
In this exercise, you will modify the display file and the program you
wrote in the OVERLAY/PUTOVR exercise. Rather than displaying the
date in edited numeric format, you will display the character value of
the month and edit the rest of the date value.
To do this, you will make changes to your display file as well as your
RPG IV program.
Required Materials
• Student Notebook
• Userid (AS07nnn) and password
Exercise Instructions
Step 1 Understand the requirement
__ 1. Review the Display formats below. Notice the format of the date. The month is
displayed as a character value. Trailing blanks of the value of month are removed.
The day and year are separated by a comma and a space.
EXempty
RJSLANEY Vendor Inquiry AECAUX
March 29, 2002 10:50:11
Vendor number. . . . : 10050
END OF LAB
Add the logic to include the suffix in the TODAY field on the display.
__ 5. Perform another test. Run the CHGJOB command and change the job date. Call
your program again. The date should be the same as the one you entered and the
date suffix should be correct for that date.
END OF LAB
Introduction
In this lab, you will use your results from the Array Processing lab.
You will modify the display file VNDINQAR to include our company
name and tax rate. You will modify the RPG program VNRINQAR to
fetch the company name and tax rate from the data area.
© Copyright IBM Corp. 2002, 2003 Exercise 4. Data Structures / Data Areas 4-1
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
Exercise Instructions
Step 1 Display Output
__ 1. Review this sample display. Your output should be similar to it. Notice the company
name in the display.
EXempty
© Copyright IBM Corp. 2002, 2003 Exercise 4. Data Structures / Data Areas 4-3
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
In addition, the VP of Finance has requested that we display the tax owed on any
outstanding balance. In speaking with the VP, we learn that the current tax rate is 6.5% and
that the rate is expected to change sometime this year.
__ 1. Create a data area, COMPANY, of 50 characters in length and place Programming
Supplies, International in it as well as the 6.5% tax rate. The tax rate should be
specified as 065 in the first three positions of the data area.
We are making the data area 50 bytes long just in case corporate decides to place
more information in it.
When you run CRTDTAARA, you will need to use F4 to prompt. You should specify
& in the CRTDTAARA VALUE keyword (initial value) when prompting in order to
extend the entry area for complete input of the contents required.
END OF LAB
Introduction
The purchasing agents in the RPG Office Supply Company want a
simple display of all vendors. They need it today!
You are given screen design information and a description of the
program logic.
You will code and compile a subfile display file and an RPG IV
program.
Use the example in your student notebook as a guide to coding your
program.
Exercise Instructions
Step 1 Analyze the requirements
__ 1. The purchasing department wants the vendors displayed in Vendor Name
sequence. There is a file, Vndnam_LF, in your library that you will use for this
exercise.
__ 2. You will produce output similar to the sample below:
EXempty indicator is on for the data file, all records have been read, and the subfile has been
filled and is ready to display.
__ 6. Use the documentation in the appendix for the vendor files Vendor_PF and the
Dictionary file to get the information you need for the fields.
__ 7. Review the DDS for logical file VNDNAM_LF below:
A ALTSEQ(QSYSTRNTBL)
A R VENDOR_FMT PFILE(VENDOR_PF)
A K VNDNAME
NEWOBJ(VENDOR_PFD)
DATA(*YES)
__ b. Clear the data from your VENDOR_PF using the following command:
CLRPFM FILE(AS07nnn/vendor_pf)
__ 4. Call your program. Do you get an error? Can you understand why?
__ 5. Save a copy of your work so far. Make a new copy of the DDS (VNDSUBNR) and
the RPG program (VNRSUBNR) if you decide to modify both. Modify your program
to handle the situation where the subfile is empty and thus avoid the error. What in
your program would tell you that the subfile is empty? For now, simply issue a
message to your message queue that states, ‘No records to display’.
__ 6. Compile and test your modified program.
__ 7. Once your program is working, restore the data to your copy of Vendor_PF using the
following command:
CPYF FROMFILE(AS07nnn/VENDOR_PFD)
TOFILE(AS07nnn/VENDOR_PF)
MBROPT(*REPLACE)
END OF LAB
Introduction
The purchasing agents in the RPG Office Supply Company liked the
work you did in the previous exercise. They want you to enhance the
program by allowing them to search using a partial vendor name. For
example, if a ‘C’ is entered by the user as a search argument, your
program should load the subfile and then display it beginning with the
first vendor name beginning with a ‘C’, Clifford Distribution.
You are provided with information to assist you to design the display
file formats and with a description of the program logic.
You may use, modify and enhance the display file and RPG IV
program that you coded in the previous exercise if you prefer. Do not
be concerned if the test against an empty data file did not work. You
can use the version of the program you saved before you tried this
test.
© Copyright IBM Corp. 2002, 2003 Exercise 6. Inquiry Subfile with Search 6-1
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
Exercise Instructions
Step 1 Analyze the requirements
__ 1. You will modify the DDS and the RPG program from the previous exercise to prompt
for the vendor name and enable F3 key as the exit option. Review the sample that
follows. First, you can see that we now prompt for a search key (partial vendor
name):
F3 = Exit
__ 2. The program should use the partial vendor name to set the file cursor and to load
the subfile. Display those vendors starting at the first one that satisfies the search
argument.
EXempty
RJSLANEY Vendor Name Display AECAUX
8/22/03 13:49:15
© Copyright IBM Corp. 2002, 2003 Exercise 6. Inquiry Subfile with Search 6-3
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
__ 6. Use the documentation in the appendix for the vendor files VndNam_LF and
Vendor_PF and the Dictionary file to obtain any additional information you need for
naming any fields.
END OF LAB
Introduction
In this exercise, you will make your vendor subfile search program that
you wrote in the previous exercise modular by changing the code to
use subroutines.
You will make a copy of the DDS and RPG IV program from the
previous exercise and will modify them.
© Copyright IBM Corp. 2002, 2003 Exercise 7. Modularize Vendor Subfile Search 7-1
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
Exercise Instructions
Step 1 Make copies of your existing DDS
__ 1. Make sure that you successfully completed the previous exercise. If you were not
successful, please ask your instructor for assistance.
__ 2. Make a copy of your DDS, VndSearch, naming it VndSchS1.
EXempty __ 2. Since SFLSIZ > SFLPAG in the DSPF, the system will handle scrolling
automatically. But, you can only scroll up to the top of the subfile. The record
displayed at the top of the subfile varies depending on the value you enter for the
SEARCH (search argument) field. In a later exercise, you will learn how to scroll
above the top and will not be limited by the value of the SEARCH field.
END OF LAB
© Copyright IBM Corp. 2002, 2003 Exercise 7. Modularize Vendor Subfile Search 7-3
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
Introduction
In this lab exercise, you will modify your program and DDS from the
previous lab to add Page + 1 and PageDown processing.
© Copyright IBM Corp. 2002, 2003 Exercise 8. Page + 1 and Pagedown 8-1
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
Exercise Instructions
Step 1 Make Copies of your Previous Exercise DDS and Program
__ 1. Make copies of your DDS, VndSchS1, and your RPG IV program, VnrSchS1, from
your previous exercise, naming the copies VndSchS2 and VnrSchS2 respectively.
EXempty __ g. Also in the Fill subroutine, add logic after the loop to set your indicators whether
you have loaded any records in the subfile. Set your SflEnd indicator and your
EmptySfl indicator.
__ h. Initialize the variable, SflSize, defined in the DSPF in your *InzSR subroutine. It
should be set to a value of your SflPag + 1.
__ i. Write a subroutine to perform PageDown. Name the subroutine NextPage.
When the user presses PageDown, you should fill and display the subfile. Make
sure that the user is prompted for a new search code.
END OF LAB
© Copyright IBM Corp. 2002, 2003 Exercise 8. Page + 1 and Pagedown 8-3
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
Introduction
You will copy your DDS and RPG IV program and then modify them to
support PageUp processing.
Exercise Instructions
Step 1 Make Copies of Your DDS and RPG IV Source
__ 1. Copy VndSchS2 and VnrSchS2 and name them VndSchS3 and VnrSchS3
respectively.
END OF LAB
Introduction
You will copy your DDS and RPG IV program and then modify them to
support SFLPAG = SFLSIZ processing.
© Copyright IBM Corp. 2002, 2003 Exercise 10. Add SFLPAG = SFLSIZ 10-1
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
Exercise Instructions
Step 1 Make Copies of Your DDS and RPG IV Program
__ 1. Copy VndSchS3 and VnrSchS3 and name them VndSchS4 and VnrSchS4
respectively.
__ 2. Your DDS will not be changed as you already have a variable defined (&SFLSIZE)
to get the value of SLFSIZ set by RPG IV program.
END OF LAB
Introduction
You may use any of the subfile search exercises as a basis for adding
maintenance. You may find it easiest to use the first search exercise
as it does not have all the formats broken up into smaller formats.
In this exercise, you will change the DDS and the program from the
previous exercise. You will add an input field in the subfile record that
will be used to indicate what type of transaction the user wants to
perform. You will not write all the code to perform the specific
transaction. As we did in the lecture example, you will code calls to
programs that will perform the specific maintenance tasks.
© Copyright IBM Corp. 2002, 2003 Exercise 11. Add Maintenance 11-1
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
their subfile programs to work should use their first search program,
VnrSchS1.
Point out to the students that they should use the maintenance code in
the lecture as a basis. The code they need to write will be very similar
but they will need to used the key for the Vendor_PF physical file
rather than the key for the Item_PF physical file.
Also emphasize that while there are many lines of code for the
maintenance, that once they have coded the logic to handle one value
for the field, Option, they can copy and modify that code for the other
valid options.
© Copyright IBM Corp. 2002, 2003 Exercise 11. Add Maintenance 11-3
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
EXempty __ i. The DLTPROGRAM has been written and a *PGM object exists in the course
master library. Include the error handling using the E opcode extender and use
the %error BIF as we did in the lecture example.
__ j. Now that you have processed the transactions, code a ReadC just before the
EndDo. We are in a DoW loop testing for EOF. The ReadC will read the next
changed subfile record or set an EOF condition. This is exactly like a normal
read loop. If EOF is encountered, the subfile will be displayed and repositioned if
the user has changed the search key.
END OF LAB
© Copyright IBM Corp. 2002, 2003 Exercise 11. Add Maintenance 11-5
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
Introduction
You will work with your subfile maintenance program and modify it to
study how the default error handler behaves compared to coding
Built-in-Functions.
© Copyright IBM Corp. 2002, 2003 Exercise 12. Error Handling BIFs 12-1
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
Exercise Instructions
Step 1 Understand the Task
__ 1. Make a copy of your subfile maintenance program from the previous exercise.
Name your copy VnrSchSErr. You will not be required to modify this program but
you will use it to call a new maintenance program, AddProgram. This program will
be called by VnrSchSErr to perform the task of adding a new vendor to the
Vendor_PF file.
__ 2. Compile your program, VnrSchSErr.
__ 3. In your library, you will find a DDS member, VndAdd. Review this member, included
below. This member uses DDS windows to prompt for the vendor number to add to
the Vendor_PF file:
A REF(VENDOR_PF)
A R ADDWIN
A WINDOW(07 4 10 70)
A WDWTITLE((*TEXT 'Add Program') +
A (*COLOR BLU) (*DSPATR RI) +
A *LEFT *TOP)
A WDWBORDER((*COLOR BLU))
A 3 2'Enter vendor number:'
A VNDNBR R D I 3 31
A R MSGWIN
A WINDOW(07 4 10 70)
A WDWTITLE((*TEXT 'Add Program') +
A (*COLOR BLU) (*DSPATR RI) +
A *LEFT *TOP)
A WDWBORDER((*COLOR BLU))
A MESSAGE 50 3 2
/FREE
ExFmt AddWin; // Prompt for the vendor number to add
Write Vendor_Fmt;
Message = 'Vendor number ' + %char(VndNbr) +
' added successfully';
EXempty
ExFmt MsgWin;
*inLR = *on;
/End-free
END OF LAB
© Copyright IBM Corp. 2002, 2003 Exercise 12. Error Handling BIFs 12-3
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
Introduction
You will modify your subfile maintenance program again and
experiment with monitor groups.
A second program will be provided to give you more opportunity to try
monitor groups.
© Copyright IBM Corp. 2002, 2003 Exercise 13. Using Monitor Groups 13-1
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
Exercise Instructions
Step 1 Copy your program, VnrSchSErr
__ 1. Make a copy of your program, VnrSchSErr. Name it VnrSchSMon.
F3=Exit
__ 5. Next, leave all fields as they are except the annual interest rate field. Enter zeros for
the interest rate. Press enter.
__ 6. What error message do you see? ___________________________________
__ 7. Modify your source code to monitor for this error. How is this error code supported in
RPG IV? _______(Look up the status code?)
__ 8. Define the field, ErrMsg, in your DDS source as a 40-character field. Place the error
anywhere below the existing information on the display.
__ 9. Modify your RPG IV source to assign a value to the field, Message, that is to be
displayed when the error occurs. The RPG program should assign the following
value to the ErrMsg field:
Incorrect value for Annual Interest
© Copyright IBM Corp. 2002, 2003 Exercise 13. Using Monitor Groups 13-3
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
END OF LAB
© Copyright IBM Corp. 2002, 2003 Exercise 13. Using Monitor Groups 13-5
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
Introduction
You are given the DSPF DDS and will write a date program that will
use date processing BIFs.
© Copyright IBM Corp. 2002, 2003 Exercise 14. Using Dates 14-1
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
Exercise Instructions
Step 1 Review the DDS, DATEDSPF
__ 1. In your library, you will find the DDS for the display file. A copy follows:
A REF(*LIBL/ITEM_PF)
A INDARA
A CA03(03 'Exit')
**
A R HEADER
A 3 35'Date Exercise' COLOR(WHT)
A 3 55'Today''s Date'
A TODAY L O 3 70DATFMT(*ISO)
**
A R PROMPT OVERLAY
A 8 10'Enter any date as YYYY-MM-DD:'
A CHARDATE 10A B 8 45
A 40 ERRMSG('Invalid date entered' 40)
**
A R DETAIL OVERLAY
A 10 20'The year entered was. .:'
A YEAR 4 0O 10 46EDTCDE(L)
A 11 20'The month entered was .:'
A MONTH 2 0O 11 48EDTCDE(L)
A 12 20'The day entered was . .:'
A DAY 2 0O 12 48EDTCDE(L)
A 14 20'The date entered is . .:'
A DAYS 5 0O 14 45EDTCDE(Z)
A 50 14 51'days from now'
A N50 14 51'days ago'
**
A R FOOTER OVERLAY
A 20 7'Press Enter to continue'
A 21 7'F3=Exit'
A COLOR(BLU)
__ 2. Notice that the fields to be entered and displayed are defined in the DDS.
__ 3. Compile and create the Display File, DATEDSPF.
EXempty
__ 2. The user can enter a date that, when it is valid, is separated into the year, month,
and day components. Also, the duration between the date entered and the job date
is calculated in days and displayed as in the future days from now or in the past
days ago.
__ 3. If the date is invalid the message Invalid date entered is displayed.
© Copyright IBM Corp. 2002, 2003 Exercise 14. Using Dates 14-3
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
__ 4. Determine the difference in days between the date entered and the job date. If the
date is in the future, you should set the indicator appropriately (see your display file).
Also handle the opposite situation.
END OF LAB
Introduction
In this exercise, you will modify your subfile maintenance program so
that it uses CALLP and a prototype to call one of the maintenance
programs, that you will also write, including the procedure interface
(PI).
Exercise Instructions
In this exercise, you will modify a program that you have already written, VNRSCHSMON.
You recall that there are CALLs (dynamic calls) to several programs that can add a new
record, change an existing record, or delete an existing record from the Vendor_PF file.
We are using a logical view by vendor name in the subfile maintenance program. At this
point the called programs do not really exist.
You will write the program that will delete a record based on an option code of 4. As you
recall, the subfile maintenance program reads the subfile record where you enter the option
and knows the record key (VnrNbr) for that record. You will pass this key as a parameter to
your VNRDLT. You will write the prototype and the CALLP to the VNRDLT in your
VNRSCHSPR program, a copy of VNRSCHSMON.
A R MSGWIN
A WINDOW(07 4 10 70)
A WDWBORDER((*COLOR BLU))
A MESSAGE 50 3 2
__ 6. To exit the window, press enter. You will be returned to the subfile display and should
see that Federal Paper is no longer displayed (it has been deleted!)
__ 7. Exit your program.
__ 8. Refresh your copy of the Vendor_PF file by copying the data from the student
master library, AS07XXX.
END OF LAB
Introduction
Given a complete loan payment calculator application, your task is to
modify certain inline calculations to create subprocedures that will
return a value to the caller.
You will not be required to write any new logic. All you will be required
to do is to move existing calculations to subprocedures. Then you will
modify the current procedure so that it calls the subprocedures.
Exercise Instructions
Step 1 Code a Local Subprocedure
In this portion of the exercise, you will modify an existing program by moving some inline
calculations into two subprocedures and writing the code necessary to call them. You will
code the procedure interfaces to define the parameters that are passed to the
subprocedures.
__ 1. Create a new QRPGLESRC source member, RATPER. RATPER, a subprocedure,
will receive as parameters, the annual interest rate and number of payments per
year, returning the periodic interest rate.
__ 2. You do not have to code the prototype (PR) at this time. It will be coded in a
separate source member in a later step.
__ 3. Code the procedure interface (PI) for RATPER on D specs. At some point your
complete subprocedure will be an independent compile unit. The PI must precisely
define all parameter attributes in the expected sequence that they will be passed
from the caller.
Use the display file below to help you to define your fields correctly:
A INDARA
A CA03(03)
A R PAYFMT
A 1 2DATE
A EDTCDE(Y)
A 1 29'Loan Payment Calculator'
A DSPATR(HI)
A 1 61'System:'
A 1 70SYSNAME
A 2 2TIME
A 2 61'User:'
A 2 70USER
A 4 2'Type values, press Enter.'
A COLOR(BLU)
A 6 18'Loan amount . . . . . . . . . .'
A PRINCIPAL 9Y 2B 6 50EDTWRD(' , , 0 . ')
A TEXT('LOAN AMOUNT')
A DSPATR(MDT)
A COMP(GT .00)
A CHECK(FE)
A 8 18'Annual interest % . . . . . . .'
A RATEPCANN 5Y 3B 8 50EDTWRD('0 . ')
A TEXT('ANNUAL INTEREST %')
A DSPATR(MDT)
A RANGE(.000 50.000)
A CHECK(FE)
A 10 18'Payments per year . . . . . . .'
A NBRPAYYR 2Y 0B 10 50EDTWRD(' 0')
A TEXT('NUMBER OF PAYMENTS PER YEA-
A R')
EXempty A DSPATR(MDT)
A RANGE(1 52)
A CHECK(FE)
A 12 18'Number of payments . . . . . .'
A NBRPAYTOT 4Y 0B 12 50EDTWRD(' , ')
A TEXT('TOTAL NUMBER OF PAYMENTS')
A DSPATR(MDT)
A RANGE(1 1600)
A CHECK(FE)
A 14 18'Periodic interest . . . . . . .'
A RATEPERIOD 13Y11O 14 50EDTCDE(4)
A TEXT('DECIMAL INTEREST RATE PER-
A IOD')
A 16 18'Periodic payment amount . . . .'
A PAYMENTAMT 13Y 2O 16 50EDTWRD(' , , , 0. ')
A TEXT('PAYMENT AMOUNT')
A DSPATR(HI)
A ERRMSG 40 21 35
A 22 2'F3=Exit'
A COLOR(BLU)
__ 4. Create the DSPF, LOANPAYD.
__ 5. Review LOANPAYSP below. You will find a copy in your library.
/free
ExFmt PayFmt;
*InLR = *On;
Return;
/End-free
__ 6. Code the calculations for the RATPER subprocedure that calculate the periodic
interest rate for a loan. If you like, you may simply copy the calculation from your
copy of LOANPAYSP to RATPER.
__ 7. Code the P specifications for your RATPER subprocedure.
__ 8. Code the PI for your RATPER subprocedure.
__ 9. Code a RETURN operation in your RATPER subprocedure.
__ 10. Exit and add an appropriate text description before saving your new source member.
EXempty __ 4. Code the necessary /COPY statements to include both prototype and subprocedure
source members at the appropriate places in LOANPAYSP. This will include your
prototypes and subprocedures in the compile unit.
__ 5. Exit and add appropriate descriptive text before saving your new source member.
__ 6. You should now have five new source members. LOANPAYSP is the member to be
compiled. Using the /COPY compiler directive, it directs the compiler to include the
other four source members at the appropriate points.
__ 7. Compiling program LOANPAYSP will be a slightly different process. Compile your
program specifying that the DFTACTGRP = *NO. If you do not specify this
parameter as *NO, your compilation will fail.
__ 8. Test LOANPAYSP. Notice that this copy of the program does not have a monitor
group in it so you may experience an error if you do not enter a valid interest rate. If
you like, add a monitor group to check for an interest rate error as you did earlier for
LOANPAYLP. You will need to include the monitor group in the appropriate
subprocedure.
__ 9. If it operates correctly, you have created an RPG IV program using local
subprocedures.
END OF LAB
Introduction
You are given the source code of an RPG IV procedure and a display
file. You will create a module and a program object from this source
member.
© Copyright IBM Corp. 2002, 2003 Exercise 17. Creating ILE Objects 17-1
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
Exercise Instructions
Step 1 Using CODE to Create ILE Objects
In this exercise you can use CODE or PDM to create the objects. As always, you can
switch between CODE and 5250 emulation easily.
In your library, you will notice several data files, EMPMST, PRJMST and RSNMST. You will
also notice a display file, MSTDSP. These files are used by the RPG IV procedure,
PAYROLLG.
If you choose to use 5250 emulation for the exercise, skip to the step, Using 5250
Emulation.
__ 1. Open an edit session for your RPGLE source member PAYROLLG. We will use this
member to reacquaint you with the various commands that can be executed from
CODE.
__ 2. From the editor's Actions menu, select Compile and then select Prompt.... The
CODE Program Generator window appears.
__ 3. Use the CODE Program Generator to select compile options. To start, you have to
specify some settings and the program that you will compile.
__ 4. Select the CRTRPGMOD command.
__ 5. Click the Options button and Create RPG Module Options dialog appears.
__ 6. On the Module tab, notice the generation level check box. This box is checked to
set the generation level at 10. If you uncheck it, you will set the generation level at 0.
__ 7. Check the options available on each tab of the Create RPG Module Options
dialog. Specifically, notice the Debugging Views parameter under the Compile tab.
You may need to set this to the level of debugging you need, for example *ALL.
__ 8. Click the OK push button to save your settings and close the dialog.
__ 9. Click the Submit button to submit your compile.
__ 10. You should see a window that notifies you that the compile was successful.
__ 11. Switch to 5250 emulation. Look in your library for an object named PAYROLLG . Do
you see an object type *Module?
__ 12. Enter option 5 next to the module to display module information. You can scroll
down to view additional information for a specific item and press Enter to see
different data. If you press Enter several times, for example, you will notice that
PAYROLLG is a procedure.
__ 13. Create a program from this module. Take option 26 in PDM and press Enter to view
the CRTPGM command. Enter PAYROLLG as the program name. Notice that you
can enter a + if this program will contain more than a single module. The
PAYROLLG program will contain only one module, PAYROLLG.
EXempty __ 14. Check your messages that the command executed successfully.
__ 15. You should see your new *PGM object, PAYROLLG. You have just created an ILE
module and an ILE program.
END OF LAB
© Copyright IBM Corp. 2002, 2003 Exercise 17. Creating ILE Objects 17-3
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
Introduction
In this exercise, you will modify your copy of VNRDLT and
VNRSCHSPR to use a bound call rather than a dynamic call.
© Copyright IBM Corp. 2002, 2003 Exercise 18. Bind by Copy 18-1
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
Exercise Instructions
Step 1 Make Copies of Your Existing Source Members
__ 1. Make copies of your VNRDLT and VNRSUBSPR, naming them VNRDLTPROC and
VNRSCHMAIN.
__ 2. Previously, each was compiled as an individual program. VNRSUBSPR calls
VNRDLT using a dynamic call.
__ 3. What in the code of each program makes this a dynamic call?
_______________________________________________
_______________________________________________
List the changes that you will have to make to each program below:
In procedure VNRDLTPROC:
_______________________________________________
_______________________________________________
In procedure VNRSCHMAIN:
_______________________________________________
_______________________________________________
EXempty __ 4. Enter VNRDLTPROC and your library for the second module. Notice that more
modules could be entered to be included in the VNRSCHMAIN program.
__ 5. Press F10 or in CODE, look for the entry module box. In PDM, you will see that the
default is *FIRST. This means that the first module in the list is the PEP for the
program. Which module is this? __________________________________
__ 6. Press Enter to create the program.
END OF LAB
© Copyright IBM Corp. 2002, 2003 Exercise 18. Bind by Copy 18-3
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
Introduction
In the Bind by Copy exercise, module VNRDLTPROC was bound by
copy into ILE program, VNRSCHMAIN.
It is often desirable to make commonly used modules available to the
application by including them in a service program object. You will now
bind the VNRDLTPROC module into a new service program object,
and then bind by reference to your new service program from the ILE
procedure VNRSCHMAIN.
You will reuse the modules from the Bind by Copy exercise, and bind
them together differently.
© Copyright IBM Corp. 2002, 2003 Exercise 19. Bind by Reference 19-1
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
Exercise Instructions
Step 1 Create Service Program, MySrvPgm
__ 1. Use the CRTSRVPGM command to create a service program that contains the
module VNRDLTPROC. Specify the parameter EXPORT(*ALL):
CRTSRVPGM SRVPGM(MYSRVPGM)
MODULE(VNRDLTPROC)
EXPORT(*ALL)
Export indicates that all export capable symbols can be referenced beyond the
scope of the object.
__ 2. What type of object did you create?
___________________________________________________________
Service programs usually contain more than one module. You just created a service
program with only one module.
__ 3. What happens if you try to execute the command:
CALL MYSRVPGM
___________________________________________________________
A stand-alone service program cannot be called dynamically.
EXempty __ 3. Press Enter and stop at the screen that displays information about service
programs. Enter a 5 beside your MYSRVPGM and press Enter until you see the
module VNRDLTPROC.
__ 4. Explore more. Make a note of any points of interest (Signature, Exports, and so on).
Make a note of any questions and review them with the instructor and the rest of the
class at the end of the exercise.
END OF LAB
© Copyright IBM Corp. 2002, 2003 Exercise 19. Bind by Reference 19-3
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
A*****************************************************************
A** Field Reference PF: DICTIONARY
A*****************************************************************
A R REFFMT TEXT('Field Reference File')
A*
A** Fields Used in Vendor Mastor File, VENDOR_PF
A*
A VNDNBR 5 0 TEXT('Vendor Number')
A COLHDG('Vend' 'Num')
A VNDNAME 25 TEXT('Vendor Name')
A COLHDG('Vendor' 'Name')
A VNDSTREET 25 TEXT('Vendor Street')
A COLHDG('Vendor Street')
A VNDCITY 23 TEXT('Vendor City')
A COLHDG('Vendor City')
A VNDSTATE 2 TEXT('Vendor State')
A COLHDG('Vnd' 'ST')
A VNDADDR3 25 TEXT('Address Line 3')
A COLHDG('Address Line 3')
A VNDZIPCODE 5 0 TEXT('Zip Code')
A COLHDG('Zip' 'Code')
A VNDAREACD 3 0 TEXT('Vendor Area Code')
A COLHDG('Vend' 'Area' 'Code')
A VNDTELNO 7 0 TEXT('Vendor Telephone Number')
A COLHDG('Vendor' 'Tel' 'No' )
A VNDDISCPCT 3 3 TEXT('Discount % For Prompt Pymt')
A COLHDG('Disc' 'Per' 'Cent')
A VNDDUEDAYS 2 0 TEXT('Days Until Payment is Due')
A COLHDG('Terms' 'Days')
A VNDCLASS 2 0 TEXT('Vendor Class')
A COLHDG('Vnd' 'Cls')
A VNDACTIVE 1 TEXT('A=Active D=Delete S=Suspend')
A COLHDG('Act' 'Rec' 'CD')
A VNDSALES 25 TEXT('Vendor Salesperson')
A COLHDG('Vendor' 'Sales' 'Person')
A VNDDISCMTD 7 2 TEXT('Discount Taken This Month')
A COLHDG('Vend' 'Disc' 'MTD')
A VNDDISCYTD 9 2 TEXT('Discount Taken This Year')
© Copyright IBM Corp. 2002, 2003 Appendix A. Physical and Logical Files DDS A-1
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
Uempty A*
A** Fields Used in Purchase Order Line Item File, POLINE_PF
A*
A POLQTYOO 5 0 TEXT('PO Item Quantity On Order')
A COLHDG('Qty' 'Ord')
A POLITMCOST 5 2 TEXT('Item Unit Cost')
A COLHDG('Item' 'Unit' 'Cost')
A POLDATREC 8 0 TEXT('Date Received')
A COLHDG('Date' 'Rec' 'YYYYMMDD')
A POLQTYREC 5 0 TEXT('Item Quantity Received')
A COLHDG('Qty' 'Rec')
A POLSTATUS 1 TEXT('Blank=On Order, C=Complete +
A D=Delete I=Incomplete')
A COLHDG('PO' 'Ln' 'Sts')
A VALUES(' ' 'C' 'D' 'I')
A*
A** Fields Used in Accounts Payable Open Invoice File, APINV_PF
A*
A APINVNBR 8 TEXT('Vendor Invoice Number')
A COLHDG('Vendor' 'Invoice' 'Number')
A APDATE 8 0 TEXT('Date Order Complete')
A COLHDG('Date' 'Compl' 'YYYYMMDD')
A APDISCOUNT 5 2 TEXT('Vendor Invoice Discount +
A Available')
A EDTCDE(3)
A COLHDG('Inv' 'Disc' 'Avail')
A APNETPAID 7 2 TEXT('Net Amount Paid')
A EDTCDE(3)
A COLHDG('Net' 'Amount' 'Paid')
A APSTATUS 1 TEXT('Blank=No Action D=Delete +
A T=To Pay P=Paid')
A COLHDG('AP' 'Sts')
A VALUES(' ' 'D' 'T' 'P')
A APDATEPAID 8 0 TEXT('Date Paid')
A COLHDG('Date' 'Paid' 'YYYYMMDD')
A APCHECK# 6 0 TEXT('Check Number')
A COLHDG('Check' 'Number')
A APDUEDATE 8 0 TEXT('Vendor Invoice Due Date +
A YYYYMMDD')
A COLHDG('Due' 'Date' 'YYYYMMDD')
© Copyright IBM Corp. 2002, 2003 Appendix A. Physical and Logical Files DDS A-3
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
A*****************************************************************
A* Accounts Payable Invoice PF: APINV_PF
A*****************************************************************
A REF(DICTIONARY)
A UNIQUE
A R APINV_FMT TEXT('Open Payables Record')
A PONBR R
A VNDNBR R
A APINVNBR R
A APDATE R
A POTOTAMT R
A APDISCOUNTR
A APNETPAID R
A APSTATUS R
A APDATEPAIDR
A APCHECK# R
A APDUEDATE R
A K PONBR
A*****************************************************************
A* Item Master PF: ITEM_PF
A*****************************************************************
A REF(DICTIONARY)
A UNIQUE
A R ITEM_FMT TEXT('Item Master Record')
A ITMNBR R
A ITMDESCR R
A ITMQTYOH R
A ITMQTYOO R
A ITMCOST R
A ITMPRICE R
A VNDNBR R
A ITMVNDCAT#R
A K ITMNBR
A*****************************************************************
A* Join LF for delinquency notices: PODLNQ_LF
A*****************************************************************
A R PODLNQ_FMT JFILE(POSUM_PF POLINE_PF VENDOR_PF)
A J JOIN(1 2)
A JFLD(PONBR PONBR)
A JDUPSEQ(ITMNBR)
A J JOIN(1 3)
A JFLD(VNDNBR VNDNBR)
A* Fields from POSUM_PF:
A PONBR JREF(1)
A VNDNBR JREF(1)
A PODATE
A* Fields from POLINE_PF
A ITMNBR
A POLQTYOO
A POLITMCOST
A POLQTYREC
A* Fields from VENDOR_PF:
A VNDNAME
A VNDAREACD
A VNDTELNO
A VNDSALES
A*
A K VNDNBR
A K PONBR
A*****************************************************************
A* PO line item LF: POITEM_LF
A*****************************************************************
A
A R POLINE_FMT TEXT('PO Line Item Record')
A PFILE(POLINE_PF)
A K ITMNBR
A O POLSTATUS CMP(EQ 'D')
© Copyright IBM Corp. 2002, 2003 Appendix A. Physical and Logical Files DDS A-5
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
A*****************************************************************
A* PO line item PF: POLINE_PF
A*****************************************************************
A REF(DICTIONARY)
A UNIQUE
A R POLINE_FMT TEXT('PO Line Item Record')
A PONBR R
A ITMNBR R
A POLQTYOO R
A POLITMCOSTR
A POLDATREC R
A POLQTYREC R
A POLSTATUS R
A K PONBR
A K ITMNBR
A*****************************************************************
A* PO Open Line Item LF: POOPNLI_LF
A*****************************************************************
A
A R POLINE_FMT TEXT('PO Line Item Record')
A PFILE(POLINE_PF)
A K PONBR
A K ITMNBR
A*****************************************************************
A* PO Summary PF: POSUM_PF
A*****************************************************************
A REF(DICTIONARY)
A UNIQUE
A R POSUM_FMT TEXT('PO Summary Record')
A PONBR R
A VNDNBR R
Uempty A POTOTAMT R
A PODATE R
A POSTATUS R
A K PONBR
A*****************************************************************
A* Vendor master PF: VENDOR_PF
A*****************************************************************
A REF(DICTIONARY)
A UNIQUE
A R VENDOR_FMT TEXT('Vendor Master File Record')
A VNDNBR R
A VNDNAME R
A VNDSTREET R
A VNDCITY R
A VNDSTATE R
A VNDZIPCODER
A VNDAREACD R
A VNDTELNO R
A VNDDISCPCTR
A VNDDUEDAYSR
A VNDCLASS R
A VNDACTIVE R
A VNDSALES R
A VNDDISCMTDR
A VNDDISCYTDR
A VNDPRCHMTDR
A VNDPRCHYTDR
A VNDBALANCER
A VNDSERVRTGR
A VNDDLVRTG R
A VNDCOMMENTR
A K VNDNBR
A*****************************************************************
A* Vendors by Name LF: VNDNAM_LF
© Copyright IBM Corp. 2002, 2003 Appendix A. Physical and Logical Files DDS A-7
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
A*****************************************************************
A ALTSEQ(QSYSTRNTBL)
A R VENDOR_FMT PFILE(VENDOR_PF)
A K VNDNAME
A REF(*LIBL/VENDOR_PF)
A INDARA
A R HEADER_FMT
A 1 2USER
A 1 30'Vendor Inquiry'
A COLOR(WHT)
A 1 71SYSNAME
A 2 61DATE
A EDTCDE(Y)
A 2 71TIME
A R PROMPT_FMT PUTOVR
A OVERLAY
A CA03(03 'End Program')
A 3 3'Vendor number. . . . :'
A VNDNBR_INQR D B 3 28COLOR(WHT) OVRDTA
A REFFLD(VNDNBR DICTIONARY)
A 96 ERRMSG('Invalid vendor number' 96)
A R DSPLY_FMT PUTOVR
A OVERLAY
A 8 3'Name . . . . . . :'
A 9 3'Address . . . . :'
A VNDNAME R O 8 24OVRDTA
A VNDSTREET R O 9 24OVRDTA
A VNDCITY R O 10 24OVRDTA
A VNDSTATE R O 10 49OVRDTA
A VNDZIPCODER O 10 53OVRDTA
A 11 3'Telephone. . . . :'
A VNDAREACD R O 11 26OVRDTA
A 11 24'('
A 11 30')'
A VNDTELNO R O 11 33OVRDTA
A EDTWRD('0 - ')
A 12 3'Sales Person . . :'
A VNDSALES R O 12 24OVRDTA
A 13 3'Purchases YTD . :'
A VNDPRCHYTDR 13 24EDTCDE(J) OVRDTA
A 14 3'Balance Owed . . :'
A VNDBALANCER 14 26EDTCDE(J) OVRDTA
A 60 DSPATR(HI)
A 60 COLOR(RED)
A R FKEYS_FMT
A OVERLAY
A 22 3'Please press enter to continue'
A 23 4'F3 = Exit'
A COLOR(BLU)
Write Header_Fmt;
Write Fkeys_Fmt;
If %found(Vendor_PF);
Else;
NotFound = *on;
endif;
enddo;
*InLR = *ON;
/END-FREE
AP
A WDWBORDER((*COLOR WHT) (*DSPATR RI)-
A (*CHAR ' '))
A 2 2'Vendor Name:'
A 3 2'MTD Purchased:'
A VNDNAME R 2 17
A VNDPRCHMTDR 3 17EDTCDE(J)
A 6 2'Press F12 to Return'
A COLOR(BLU)
Write Header_Fmt;
Write Fkeys_Fmt;
If %found(Vendor_PF);
If Details;
EndIf;
Else;
NotFound = *on;
endif;
enddo;
*InLR = *ON;
/END-FREE
Write Header_Fmt;
Write Fkeys_Fmt;
If %found(Vendor_PF);
Else;
NotFound = *on;
endif;
enddo;
*InLR = *ON;
/END-FREE
**ctdata months
January February March April
May June July August
SeptemberOctober November December
A REF(*LIBL/VENDOR_PF)
A INDARA
A R HEADER_FMT
A 1 2USER
A 1 30'Vendor Inquiry'
A COLOR(WHT)
AP A 1 71SYSNAME
A TODAY 20 O 2 45
A* 2 61DATE
A* EDTCDE(Y)
A 2 71TIME
A R PROMPT_FMT PUTOVR
A OVERLAY
A CA03(03 'End Program')
A 3 3'Vendor number. . . . :'
A VNDNBR_INQR D B 3 28COLOR(WHT) OVRDTA
A REFFLD(VNDNBR DICTIONARY)
A 96 ERRMSG('Invalid vendor number' 96)
A R DSPLY_FMT PUTOVR
A OVERLAY
A 8 3'Name . . . . . . :'
A 9 3'Address . . . . :'
A VNDNAME R O 8 24OVRDTA
A VNDSTREET R O 9 24OVRDTA
A VNDCITY R O 10 24OVRDTA
A VNDSTATE R O 10 49OVRDTA
A VNDZIPCODER O 10 53OVRDTA
A 11 3'Telephone. . . . :'
A VNDAREACD R O 11 26OVRDTA
A 11 24'('
A 11 30')'
A VNDTELNO R O 11 33OVRDTA
A EDTWRD('0 - ')
A 12 3'Sales Person . . :'
A VNDSALES R O 12 24OVRDTA
A 13 3'Purchases YTD . :'
A VNDPRCHYTDR 13 24EDTCDE(J) OVRDTA
A 14 3'Balance Owed . . :'
A VNDBALANCER 14 26EDTCDE(J) OVRDTA
A 60 DSPATR(HI)
A 60 COLOR(RED)
A R FKEYS_FMT
A OVERLAY
A 22 3'Please press enter to continue'
A 23 4'F3 = Exit'
A COLOR(BLU)
/FREE
// Determine the suffix of the day
Index = %Div(*Day:21) + (%Rem(*Day:21));
// special handling for the 31st
If *day = 31;
Index = Index - 10;
EndIf;
// Convert month number to month name and format date
Today = %trimr(months(*month)) + ' '
+ %char(*day) + DaySuff(Index)
+ ', ' + %char(*year);
Write Header_Fmt;
Write Fkeys_Fmt;
If %found(Vendor_PF);
Else;
NotFound = *on;
endif;
enddo;
*InLR = *ON;
/END-FREE
**ctdata months
January February March April
May June July August
SeptemberOctober November December
**CtData DaySuff
stndrdththththththth
thththththththththth
A REF(*LIBL/VENDOR_PF)
A INDARA
A R HEADER_FMT
A CONAME 40 O 1 25
A 3 2USER
A 3 30'Vendor Inquiry'
A COLOR(WHT)
A 3 71SYSNAME
A TODAY 18 O 4 50
A* 4 61DATE
A* EDTCDE(Y)
A 4 71TIME
A R PROMPT_FMT PUTOVR
A OVERLAY
A CA03(03 'End Program')
A 6 3'Vendor number. . . . :'
A VNDNBR_INQR D B 6 28COLOR(WHT) OVRDTA
A REFFLD(VNDNBR DICTIONARY)
A 96 ERRMSG('Invalid vendor number' 96)
A R DSPLY_FMT PUTOVR
A OVERLAY
A 8 3'Name . . . . . . :'
A 9 3'Address . . . . :'
A VNDNAME R O 8 24OVRDTA
A VNDSTREET R O 9 24OVRDTA
A VNDCITY R O 10 24OVRDTA
A VNDSTATE R O 10 49OVRDTA
A VNDZIPCODER O 10 53OVRDTA
A 11 3'Telephone. . . . :'
A VNDAREACD R O 11 26OVRDTA
A 11 24'('
A 11 30')'
A VNDTELNO R O 11 33OVRDTA
A EDTWRD('0 - ')
A 12 3'Sales Person . . :'
A VNDSALES R O 12 24OVRDTA
A 13 3'Purchases YTD . :'
A VNDPRCHYTDR 13 24EDTCDE(J) OVRDTA
A 14 3'Balance Owed . . :'
A VNDBALANCER 14 26EDTCDE(J) OVRDTA
A 60 DSPATR(HI)
A 60 COLOR(RED)
A 16 3'Tax Owed . . . . :'
A TAX 7 2O 16 29EDTCDE(J) OVRDTA
A R FKEYS_FMT
A OVERLAY
A 22 3'Please press enter to continue'
A 23 4'F3 = Exit'
A COLOR(BLU)
H ExPrOpts(*ResDecpos)
// Vendor master File
FVendor_PF IF E K Disk
// Display File
FVndinqDT CF E Workstn IndDS(WkIndicators)
// Indicator Data Structure
D WkIndicators DS
D Exit 3 3N
D Cancel 12 12N
D HighBalance 60 60N
D NotFound 96 96N
/FREE
// get company name from Data area
// Write headings on first page of report
In Company;
// Convert month number to month name and format date
Today = %trimr(months(*month)) + ' '
+ %char(*day) + ', ' + %char(*year);
Write Header_Fmt;
Write Fkeys_Fmt;
If %found(Vendor_PF);
Else;
NotFound = *on;
endif;
AP
enddo;
*InLR = *ON;
/END-FREE
**ctdata months
January February March April
May June July August
SeptemberOctober November December
A REF(*LIBL/DICTIONARY)
A CA03(03 'End Program')
A INDARA
** Prompt Format
A R PROMPT_FMT OVERLAY
A 1 2USER
A 1 30'Vendor Name Display'
A DSPATR(HI)
A COLOR(WHT)
A 1 71SYSNAME
A 2 61DATE
A EDTCDE(Y)
A 2 71TIME
** Data record
A R VSEARCHDTA SFL
A VNDNBR R O 9 2
A VNDNAME R O 9 8
A VNDAREACD R O 9 34
A VNDTELNO R O 9 38EDTWRD(' - ')
A VNDSALES R O 9 51
** Subfile Control Record
A R VSEARCHCTL SFLCTL(VSEARCHDTA)
A SFLDSPCTL
A SFLDSP
A SFLSIZ(0050)
A SFLPAG(0014)
A 40 SFLEND(*MORE)
A OVERLAY
** Heading Format
A R HEADER_FMT OVERLAY
A 7 2'Vend'
A 8 3'No'
A 7 11'Vendor Name'
A 7 34'Telephone'
A 7 56'Sales Person'
** Function Keys
A R FKEY_FMT
A 24 4'F3 = Exit'
A COLOR(BLU)
fVndnam_lf if e k disk
fVndsubfilecf e workstn Sfile(VSearchDta:RRN)
F IndDS(VndIndic)
D VndIndic DS
D Exit 3 3N
D SflEnd 40 40N
D RRN s 3 0
/FREE
Write FKey_Fmt;
Write Prompt_Fmt;
Read VndNam_LF;
Rrn = 1;
// Load Subfile
DoW NOT %eof(VndNam_LF);
Write VsearchDta;
Read VndNam_lf;
RRN=RRN+1;
EndDo;
// Display Subfile
Dow not Exit;
Write Header_Fmt;
SflEnd = %eof(VndNam_LF);
Exfmt VsearchCtl;
EndDo;
*inlr=*on;
Return;
/END-FREE
DDS:VNDSUBNR
A REF(*LIBL/DICTIONARY)
A CA03(03 'End Program')
A INDARA
** Prompt Format
A R PROMPT_FMT OVERLAY
A 1 2USER
A 1 30'Vendor Name Display'
A DSPATR(HI)
A COLOR(WHT)
A 1 71SYSNAME
A 2 61DATE
A EDTCDE(Y)
A 2 71TIME
** Data record
A R VSEARCHDTA SFL
A VNDNBR R O 9 2
A VNDNAME R O 9 8
A VNDAREACD R O 9 34
A VNDTELNO R O 9 38EDTWRD(' - ')
A VNDSALES R O 9 51
** Subfile Control Record
A R VSEARCHCTL SFLCTL(VSEARCHDTA)
A SFLDSPCTL
A SFLDSP
A SFLSIZ(0050)
A SFLPAG(0014)
A 40 SFLEND(*MORE)
A OVERLAY
** Heading Format
A R HEADER_FMT OVERLAY
A 7 2'Vend'
A 8 3'No'
A 7 11'Vendor Name'
A 7 34'Telephone'
A 7 56'Sales Person'
** Function Keys
A R FKEY_FMT
A 24 4'F3 = Exit'
A COLOR(BLU)
fVndnam_lf if e k disk
fVndsubnr cf e workstn Sfile(VSearchDta:RRN)
F IndDS(VndIndic)
D VndIndic DS
D Exit 3 3N
D SflEnd 40 40N
D RRN s 3 0
D EmptyMsg S 25A
/FREE
Write FKey_Fmt;
Write Prompt_Fmt;
Read VndNam_LF;
Rrn = 1;
// Load Subfile
DoW NOT %eof(VndNam_LF);
Write VsearchDta;
Read VndNam_lf;
RRN=RRN+1;
EndDo;
// Display Subfile
Dow not Exit;
Write Header_Fmt;
// Add logic to handle empty subfile
If Rrn = 1;
EmptyMsg = 'No records to display';
Dsply EmptyMsg '*REQUESTER¬';
Leave;
AP EndIf;
SflEnd = %eof(VndNam_LF);
Exfmt VsearchCtl;
EndDo;
*inlr=*on;
Return;
/END-FREE
DDS: VNDSEARCH
A REF(*LIBL/DICTIONARY)
A CA03(03 'End Program')
A INDARA
** Prompt Format
A R PROMPT_FMT OVERLAY
A 1 2USER
A 1 30'Vendor Name Search'
A DSPATR(HI)
A COLOR(WHT)
A 1 71SYSNAME
A 2 61DATE
A EDTCDE(Y)
A 2 71TIME
A 3 2'Enter partial vendor name: '
A SEARCH 25A I 3 31
A 96 ERRMSG('No vendors found' 96)
A 4 2'Press enter to continue'
A COLOR(BLU)
** Subfile data record
A R VSEARCHDTA SFL
A VNDNBR R O 9 2
A VNDNAME R O 9 8
A VNDAREACD R O 9 34
A VNDTELNO R O 9 38EDTWRD(' - ')
A VNDSALES R O 9 51
** Subfile Control Format
A R VSEARCHCTL SFLCTL(VSEARCHDTA)
A SFLSIZ(0050)
A SFLPAG(0014)
A 40 SFLEND(*MORE)
A 75 SFLCLR
A 85 SFLDSPCTL
A 95 SFLDSP
A OVERLAY
** Headings for Subfile
A R HEADER_FMT OVERLAY
A 7 2'Vend'
A 8 3'No'
A 7 11'Vendor Name'
A 7 34'Telephone'
A 7 56'Sales Person'
** Function Keys
A R FKEY_FMT
A 24 4'F3 = Exit'
A COLOR(BLU)
RPG IV Program: VNRSEARCH
fVndnam_lf if e k disk
D VndIndic DS
D Exit 03 03N
D SflEnd 40 40N
D SflClr 75 75N
D SflDspCtl 85 85N
D SflDsp 95 95N
D NotFound 96 96N
d RRN s 3 0 INZ
/FREE
DoW not Exit;
// Setup search key and position file cursor
Search = %TrimL(Search);
SetLL Search VndNam_lf;
Read VndNam_lf;
Rrn = 1;
// Load Subfile and read rest of records unless at End of File
DoW Not %Eof(VndNam_LF);
Write VsearchDta;
Read VndNam_lf;
Rrn = Rrn+1;
EndDo;
// Display Subfile - do we have any records to display?
If Rrn <= 1;
NotFound = *on;
Else;
SflDsp = *on;
EndIF;
// Display records in subfile
Write Header_Fmt;
SflDspCtl = *on;
Write VsearchCtl;
SflDspCtl = *off;
SflDsp = *off;
Exfmt Prompt_fmt;
NotFound = *off;
// Start a new search - clear subfile and reset RRN
SflClr = *on;
Write VSearchCtl;
SflClr = *off;
RRN = 0;
EndDo;
*inlr=*on;
Return;
BegSR *InzSR;
Write FKey_Fmt;
Exfmt Prompt_fmt;
// Set SFLEND indicator
SflEnd = *on;
Endsr;
/END-FREE
A REF(*LIBL/DICTIONARY)
A CA03(03 'End Program')
A INDARA
** Prompt Format
A R PROMPT_FMT OVERLAY
A 1 2USER
A 1 30'Vendor Name Search'
A DSPATR(HI)
A COLOR(WHT)
A 1 71SYSNAME
A 2 61DATE
A EDTCDE(Y)
A 2 71TIME
A 3 2'Enter partial vendor name: '
A SEARCH 25A I 3 31
A 4 2'Press enter to continue'
A COLOR(BLU)
** Subfile data record
A R VSEARCHDTA SFL
A VNDNBR R O 9 2
A VNDNAME R O 9 8
A VNDAREACD R O 9 34
A VNDTELNO R O 9 38EDTWRD(' - ')
A VNDSALES R O 9 51
** Subfile Control Format
A R VSEARCHCTL SFLCTL(VSEARCHDTA)
A SFLSIZ(0050)
A SFLPAG(0014)
A 40 SFLEND(*MORE)
A 75 SFLCLR
A 85 SFLDSPCTL
A 95 SFLDSP
A OVERLAY
** Headings for Subfile
A R HEADER_FMT OVERLAY
A 7 2'Vend'
A 8 3'No'
A 7 11'Vendor Name'
A 7 34'Telephone'
A 7 56'Sales Person'
** Function Keys
A R FKEY_FMT
A 24 4'F3 = Exit'
A COLOR(BLU)
** Message for empty subfile
A R MSG
A OVERLAY
A 12 32'No Records Found'
A DSPATR(HI)
FVndNam_LF IF E K Disk
FVndSchS1 CF E Workstn Sfile(VSearchDta:Rrn)
F IndDS(WkStnIndics)
D WkStnIndics DS
D Exit 3 3N
D SflEnd 40 40N
D SflDspCtl 85 85N
D SflDsp 95 95N
D SflClr 75 75N
D Rrn S 4 0 INZ
D EmptySfl S N
/FREE
*InLr = *on;
// subroutines
BegSR *InzSR; // Initialization subroutine
Write FKey_Fmt;
ExFmt Prompt_Fmt;
Endsr;
BegSR SearchRtn;
ExSr SFLClear; // Clear subfile for new search
Begsr Fill;
Endsr;
Begsr Prompt;
If NOT EmptySfl;
Else;
Write Header_Fmt;
Write VSearchCtl;
ExFmt Prompt_Fmt;
Endsr;
A REF(*LIBL/DICTIONARY)
A CA03(03 'End Program')
A INDARA
>> A N40 PAGEDOWN(30)
** Prompt Format
A R PROMPT_FMT OVERLAY
A 1 2USER
A 1 30'Vendor Name Search'
A DSPATR(HI)
A COLOR(WHT)
A 1 71SYSNAME
A 2 61DATE
A EDTCDE(Y)
A 2 71TIME
A 3 2'Enter partial vendor name: '
A SEARCH 25A I 3 31
A 4 2'Press enter to continue'
A COLOR(BLU)
** Subfile data record
A R VSEARCHDTA SFL
A VNDNBR R O 9 2
A VNDNAME R O 9 8
A VNDAREACD R O 9 34
A VNDTELNO R O 9 38EDTWRD(' - ')
A VNDSALES R O 9 51
** Subfile Control Format
A R VSEARCHCTL SFLCTL(VSEARCHDTA)
>> A SFLSIZ(&SFLSIZE)
A SFLPAG(0014)
A 40 SFLEND(*MORE)
A 75 SFLCLR
A 85 SFLDSPCTL
A 95 SFLDSP
A OVERLAY
>> A SFLSIZE 5S 0P
>> A SFLRRN 4S 0H SFLRCDNBR
** Headings for Subfile
A R HEADER_FMT OVERLAY
A 7 2'Vend'
A 8 3'No'
A 7 11'Vendor Name'
A 7 34'Telephone'
A 7 56'Sales Person'
** Function Keys
A R FKEY_FMT
A 24 4'F3 = Exit'
A COLOR(BLU)
** Message for empty subfile
A R MSG
A OVERLAY
A 12 32'No vendors Found'
A DSPATR(HI)
RPG IV: VNRSCHS2S
FVndNam_LF IF E K Disk
FVndSchS2 CF E Workstn Sfile(VSearchDta:Rrn)
F IndDS(WkStnIndics)
D WkStnIndics DS
D Exit 3 3N
>> D PageDown 30 30N
D SflEnd 40 40N
D SflDspCtl 85 85N
D SflDsp 95 95N
D SflClr 75 75N
D Rrn S 4 0 INZ
>> D RrnCount S Like(Rrn)
>> D EmptySfl S N
/FREE
DoW not Exit;
>> Select;
>> When PageDown;
>> Exsr NextPage;
>> Other;
ExSR SearchRtn;
>> Endsl;
EndDo;
*InLr = *on;
// subroutines
BegSR *InzSR; // Initialization subroutine
BegSR SearchRtn;
ExSr SFLClear; // Clear subfile for new search
Begsr Fill;
Endsr;
Begsr Prompt;
If NOT EmptySfl;
Else;
Write Header_Fmt;
Write VSearchCtl;
ExFmt Prompt_Fmt;
Endsr;
EndSR;
/END-FREE
A REF(*LIBL/DICTIONARY)
A CA03(03 'End Program')
A INDARA
A N40 PAGEDOWN(30)
A N41 PAGEUP(31)
** Prompt Format
A R PROMPT_FMT OVERLAY
A 1 2USER
A 1 30'Vendor Name Search'
A DSPATR(HI)
A COLOR(WHT)
A 1 71SYSNAME
A 2 61DATE
A EDTCDE(Y)
A 2 71TIME
A 3 2'Enter partial vendor name: '
A SEARCH 25A I 3 31
A 4 2'Press enter to continue'
A COLOR(BLU)
** Subfile data record
A R VSEARCHDTA SFL
A VNDNBR R O 9 2
A VNDNAME R O 9 8
A VNDAREACD R O 9 34
A VNDTELNO R O 9 38EDTWRD(' - ')
A VNDSALES R O 9 51
** Subfile Control Format
A R VSEARCHCTL SFLCTL(VSEARCHDTA)
>> A SFLSIZ(&SFLSIZE)
A SFLPAG(0014)
A 40 SFLEND(*MORE)
A 75 SFLCLR
A 85 SFLDSPCTL
A 95 SFLDSP
A OVERLAY
>> A SFLSIZE 5S 0P
>> A SFLRRN 4S 0H SFLRCDNBR
** Headings for Subfile
A R HEADER_FMT OVERLAY
A 7 2'Vend'
A 8 3'No'
A 7 11'Vendor Name'
A 7 34'Telephone'
A 7 56'Sales Person'
** Function Keys
A R FKEY_FMT
A 24 4'F3 = Exit'
A COLOR(BLU)
** Message for empty subfile
A R MSG
A OVERLAY
A 12 32'No vendors Found'
A DSPATR(HI)
RPG IV:VNRSCHS3
FVndNam_LF IF E K Disk
>> FVndSchS3 CF E Workstn Sfile(VSearchDta:Rrn)
F IndDS(WkStnIndics)
D WkStnIndics DS
D Exit 3 3N
D PageDown 30 30N
>> D PageUp 31 31N
D SflEnd 40 40N
>> D SflBegin 41 41N
D SflDspCtl 85 85N
D SflDsp 95 95N
D SflClr 75 75N
D Rrn S 4 0 INZ
D RrnCount S Like(Rrn)
D EmptySfl S N
/FREE
DoW not Exit;
Select;
When PageDown;
Exsr NextPage;
>> When PageUp;
>> Exsr PrevPage;
Other;
ExSR SearchRtn;
Endsl;
EndDo;
*InLr = *on;
// subroutines
BegSR *InzSR; // Initialization subroutine
SflSize = 15;
SflEnd = *On;
>> SflBegin = *ON;
Write FKey_Fmt;
ExFmt Prompt_Fmt;
Endsr;
BegSR SearchRtn;
ExSr SFLClear; // Clear subfile for new search
>> If %EOF(VndNam_LF);
>> Setll *Start VndNam_LF;
>> Endif;
Begsr Fill;
Rrn = Rrn + 1;
RrnCount = RrnCount + 1;
Enddo;
Endsr;
Begsr Prompt;
If NOT EmptySfl;
Else;
Write Msg;
Endif;
Write Header_Fmt;
Write VSearchCtl;
ExFmt Prompt_Fmt;
Endsr;
Begsr NextPage;
A REF(*LIBL/DICTIONARY)
A CA03(03 'End Program')
A INDARA
A N40 PAGEDOWN(30)
A N41 PAGEUP(31)
** Prompt Format
A R PROMPT_FMT OVERLAY
A 1 2USER
A 1 30'Vendor Name Search'
A DSPATR(HI)
A COLOR(WHT)
A 1 71SYSNAME
A 2 61DATE
A EDTCDE(Y)
A 2 71TIME
A 3 2'Enter partial vendor name: '
A SEARCH 25A I 3 31
A 4 2'Press enter to continue'
A COLOR(BLU)
** Subfile data record
A R VSEARCHDTA SFL
A VNDNBR R O 9 2
A VNDNAME R O 9 8
A VNDAREACD R O 9 34
A VNDTELNO R O 9 38EDTWRD(' - ')
A VNDSALES R O 9 51
** Subfile Control Format
A R VSEARCHCTL SFLCTL(VSEARCHDTA)
A SFLSIZ(&SFLSIZE)
A SFLPAG(0014)
A 40 SFLEND(*MORE)
A 75 SFLCLR
A 85 SFLDSPCTL
A 95 SFLDSP
A OVERLAY
A SFLSIZE 5S 0P
A SFLRRN 4S 0H SFLRCDNBR
** Headings for Subfile
A R HEADER_FMT OVERLAY
A 7 2'Vend'
A 8 3'No'
A 7 11'Vendor Name'
A 7 34'Telephone'
A 7 56'Sales Person'
** Function Keys
A R FKEY_FMT
A 24 4'F3 = Exit'
A COLOR(BLU)
** Message for empty subfile
A R MSG
A OVERLAY
A 12 32'No vendors Found'
A DSPATR(HI)
RPG IV: VNRSUBS4
FVndNam_LF IF E K Disk
>> FVndSchS4 CF E Workstn Sfile(VSearchDta:Rrn)
F IndDS(WkStnIndics)
D WkStnIndics DS
D Exit 3 3N
D PageDown 30 30N
D PageUp 31 31N
D SflEnd 40 40N
D SflBegin 41 41N
D SflDspCtl 85 85N
D SflDsp 95 95N
D SflClr 75 75N
D Rrn S 4 0 INZ
D RrnCount S Like(Rrn)
D EmptySfl S N
/FREE
DoW not Exit;
Select;
When PageDown;
Exsr NextPage;
When PageUp;
Exsr PrevPage;
Other;
ExSR SearchRtn;
Endsl;
EndDo;
*InLr = *on;
// subroutines
BegSR *InzSR; // Initialization subroutine
>> SflRrn = 1;
SflSize = 14;
SflEnd = *On;
SflBegin = *ON;
Write FKey_Fmt;
ExFmt Prompt_Fmt;
Endsr;
BegSR SearchRtn;
Begsr CheckBOF;
If %EOF(VndNam_LF);
Setll *Start VndNam_LF;
Endif;
Read VndNam_LF;
Endsr;
Begsr Fill;
Endsr;
Begsr Prompt;
If NOT EmptySfl;
Else;
Write Msg;
Endif;
Write Header_Fmt;
Write VSearchCtl;
ExFmt Prompt_Fmt;
Endsr;
Begsr NextPage;
Begsr PrevPage;
// Find out where I am now in the DB
Chain 1 VSearchDta; // Chain to first record in subfile
Exsr SflClear;
A REF(*LIBL/DICTIONARY)
A CA03(03 'End Program')
A INDARA
A N40 PAGEDOWN(30)
A N41 PAGEUP(31)
** Subfile data record
A R VSEARCHDTA SFL
>> A OPTION 1A I 9 2VALUES(' ' '1' '2' '4')
A VNDNBR R O 9 4
A VNDNAME R O 9 10
A VNDAREACD R O 9 36
A VNDTELNO R O 9 40EDTWRD(' - ')
A VNDSALES R O 9 53
** Subfile Control Format
A R VSEARCHCTL SFLCTL(VSEARCHDTA)
A SFLSIZ(&SFLSIZE)
A SFLPAG(0014)
A 40 SFLEND(*MORE)
A 75 SFLCLR
A 85 SFLDSPCTL
A 95 SFLDSP
A OVERLAY
A SFLSIZE 5S 0P
A SFLRRN 4S 0H SFLRCDNBR
>> ** Prompt Format
>> A* R PROMPT_FMT OVERLAY
A 1 2USER
A 1 30'Vendor Name Search'
A DSPATR(HI)
A COLOR(WHT)
A 1 71SYSNAME
A 2 61DATE
A EDTCDE(Y)
A 2 71TIME
A 3 2'Enter partial vendor name: '
A SEARCH 25A I 3 31
A 4 2'Press enter to continue'
A COLOR(BLU)
>> ** Headings for Subfile
>> A* R HEADER_FMT OVERLAY
>> A 6 1'Opt'
A 7 4'Vend'
A 8 5'No'
A 7 13'Vendor Name'
A 7 36'Telephone'
A 7 58'Sales Person'
** Function Keys
A R FKEY_FMT
A 24 4'F3 = Exit'
A COLOR(BLU)
** Message for empty subfile
A R MSG
A OVERLAY
>> A* 12 32'No vendors Found'
>> A MESSAGE 25 12 32
A DSPATR(HI)
RPG IV: VNRSCHS5
FVndNam_LF IF E K Disk
>> FVndSchS5 CF E Workstn Sfile(VSearchDta:Rrn)
F IndDS(WkStnIndics)
D WkStnIndics DS
D Exit 3 3N
D PageDown 30 30N
D PageUp 31 31N
D SflEnd 40 40N
D SflBegin 41 41N
D SflDspCtl 85 85N
D SflDsp 95 95N
D SflClr 75 75N
D Rrn S 4 0 INZ
D RrnCount S Like(Rrn)
D EmptySfl S N
/FREE
DoW not Exit;
Select;
When PageDown;
Exsr NextPage;
When PageUp;
Exsr PrevPage;
Other;
ExSR SearchRtn;
Endsl;
EndDo;
*InLr = *on;
// subroutines
BegSR *InzSR; // Initialization subroutine
SflRrn = 1;
SflSize = 14;
SflEnd = *On;
SflBegin = *ON;
SflDspCtl = *On;
Write FKey_Fmt;
BegSR SearchRtn;
ExSr SFLClear; // Clear subfile for new search
Begsr CheckBOF;
If %EOF(VndNam_LF);
Setll *Start VndNam_LF;
Endif;
Read VndNam_LF;
Endsr;
Begsr Fill;
Endsr;
Begsr Prompt;
If NOT EmptySfl;
Else;
Begsr NextPage;
Begsr PrevPage;
// Find out where I am now in the DB
Chain 1 VSearchDta; // Chain to first record in subfile
Exsr SflClear;
AP EndSR;
>> Enddo;
>> Endsr;
Write FKey_Fmt;
/END-FREE
The solution that follows is based on modifying the source of exercise 7 VNxSCHS1.
DDS:VNDSCHS5
A REF(*LIBL/DICTIONARY)
A CA03(03 'End Program')
A INDARA
** Subfile data record
A R VSEARCHDTA SFL
>> A OPTION 1A I 9 2VALUES(' ' '1' '2' '4')
A VNDNBR R O 9 4
A VNDNAME R O 9 10
A VNDAREACD R O 9 36
A VNDTELNO R O 9 40EDTWRD(' - ')
A VNDSALES R O 9 53
** Subfile Control Format
A R VSEARCHCTL SFLCTL(VSEARCHDTA)
A SFLSIZ(0050)
A SFLPAG(0014)
A 40 SFLEND(*MORE)
A 75 SFLCLR
A 85 SFLDSPCTL
A 95 SFLDSP
A OVERLAY
** Prompt Format
A* R PROMPT_FMT OVERLAY
A 1 2USER
A 1 30'Vendor Name Search'
A DSPATR(HI)
A COLOR(WHT)
A 1 71SYSNAME
A 2 61DATE
A EDTCDE(Y)
A 2 71TIME
A 3 2'Enter partial vendor name: '
A SEARCH 25A I 3 31
>> A* 96 ERRMSG('No vendors found' 9
A 4 2'Press enter to continue'
A COLOR(BLU)
>> ** Headings for Subfile
>> A* R HEADER_FMT OVERLAY
>> A 6 1'Opt'
A 7 4'Vend'
A 8 5'No'
A 7 13'Vendor Name'
A 7 36'Telephone'
AP A 7 58'Sales Person'
** Function Keys
A R FKEY_FMT
A 24 4'F3 = Exit'
A COLOR(BLU)
** Message for empty subfile
A R MSG
A OVERLAY
>> A* 12 32'No vendors Found'
>> A MESSAGE 25 12 32
A DSPATR(HI)
RPG IV: VNRSCHS5
FVndNam_LF IF E K Disk
>> FVndSchS5 CF E Workstn Sfile(VSearchDta:Rrn)
F IndDS(WkStnIndics)
D WkStnIndics DS
D Exit 3 3N
D SflEnd 40 40N
D SflDspCtl 85 85N
D SflDsp 95 95N
D SflClr 75 75N
D Rrn S 4 0 INZ
>> D EmptySfl S N
/FREE
DoW not Exit;
ExSR SearchRtn;
EndDo;
*InLr = *on;
// subroutines
BegSR *InzSR; // Initialization subroutine
Write FKey_Fmt;
// ExFmt Prompt_Fmt;
>> SflDspCtl = *On;
>> ExFmt VSearchCtl;
Endsr;
BegSR SearchRtn;
ExSr SFLClear; // Clear subfile for new search
EndSR;
Begsr Fill;
Endsr;
Begsr Prompt;
If NOT EmptySfl;
Else;
// Write Header_Fmt;
ExFmt VSearchCtl;
// ExFmt Prompt_Fmt;
If Rrn > 1; // Process changes only if subfile has records
>> Exsr Changes;
EndIf;
Endsr;
Begsr SFLCLear; // Subfile clear subroutine
SflClr = *on;
SflDsp = *OFF;
SflDspCtl = *OFF;
Write VSearchCtl; // New search - clear subfile
SflClr = *off;
EndSR;
>> Enddo;
Write FKey_Fmt;
>> Endsr;
/End-Free
/FREE
ExFmt AddWin;
Setll(E) VndNbr Vendor_PF;
If not %error;
If not %equal(Vendor_PF);
Write Vendor_Fmt;
Message = 'Vendor number ' + %char(VndNbr) +
' added successfully';
ExFmt MsgWin;
Else;
Message = 'Error - Vendor ' +
'(' + %char(VndNbr) + ')' +
' already exists in file';
ExFmt MsgWin;
EndIf;
EndIf;
*inLR = *on;
/End-free
FVndNam_LF IF E K Disk
FVndSchS5 CF E Workstn Sfile(VSearchDta:Rrn)
F IndDS(WkStnIndics)
D WkStnIndics DS
D Exit 3 3N
D PageDown 30 30N
D PageUp 31 31N
D SflEnd 40 40N
D SflBegin 41 41N
D SflDspCtl 85 85N
D SflDsp 95 95N
D SflClr 75 75N
D Rrn S 4 0 INZ
D RrnCount S Like(Rrn)
D EmptySfl S N
>> D ErrorMsg S 30A
/FREE
DoW not Exit;
Select;
When PageDown;
Exsr NextPage;
When PageUp;
Exsr PrevPage;
Other;
ExSR SearchRtn;
Endsl;
EndDo;
*InLr = *on;
// subroutines
BegSR *InzSR; // Initialization subroutine
SflRrn = 1;
SflSize = 14;
SflEnd = *On;
SflBegin = *ON;
SflDspCtl = *On;
Write FKey_Fmt;
ExFmt VSearchCtl;
Endsr;
BegSR SearchRtn;
ExSr SFLClear; // Clear subfile for new search
Begsr CheckBOF;
If %EOF(VndNam_LF);
Setll *Start VndNam_LF;
Endif;
Read VndNam_LF;
Endsr;
Begsr Fill;
Endsr;
Begsr Prompt;
If NOT EmptySfl;
Else;
AP Write Msg;
Endif;
// Write Header_Fmt;
ExFmt VSearchCtl;
// ExFmt Prompt_Fmt;
If Rrn > 1; // Process changes only if subfile has records
Exsr Changes;
EndIf;
Endsr;
Begsr NextPage;
Begsr PrevPage;
// Find out where I am now in the DB
Chain 1 VSearchDta; // Chain to first record in subfile
Exsr SflClear;
Begsr Changes;
ReadC VSearchDta;
AP ReadC VSearchDta;
Enddo;
Write FKey_Fmt;
Endsr;
/END-FREE
Step 3-2 You should see a message in your message queue informing you that there was
an error. The e-extender and %error method could have been coded to do this as well.
Which method you use depends on the situation, what will work best for you, and what
standards are in force in your organization.
/free
ExFmt PayFmt;
EndMon;
ExFmt PayFmt;
ErrMsg = *blank;
EndDo;
*InLR = *On;
Return;
/end-free
Write Detail;
EndIf;
// Display prompt
Exfmt Prompt;
Enddo;
*InLR = *On;
/End-free
FVndNam_LF IF E K Disk
FVndSchS5 CF E Workstn Sfile(VSearchDta:Rrn)
F IndDS(WkStnIndics)
D WkStnIndics DS
D Exit 3 3N
D PageDown 30 30N
D PageUp 31 31N
D SflEnd 40 40N
D SflBegin 41 41N
D SflDspCtl 85 85N
D SflDsp 95 95N
D SflClr 75 75N
D Rrn S 4 0 INZ
D RrnCount S Like(Rrn)
D EmptySfl S N
D ErrorMsg S 30A
Other;
ExSR SearchRtn;
Endsl;
EndDo;
*InLr = *on;
// subroutines
BegSR *InzSR; // Initialization subroutine
SflRrn = 1;
SflSize = 14;
SflEnd = *On;
SflBegin = *ON;
SflDspCtl = *On;
Write FKey_Fmt;
ExFmt VSearchCtl;
Endsr;
BegSR SearchRtn;
ExSr SFLClear; // Clear subfile for new search
Begsr CheckBOF;
If %EOF(VndNam_LF);
Setll *Start VndNam_LF;
Endif;
Read VndNam_LF;
Endsr;
Begsr Fill;
Endsr;
Begsr Prompt;
If NOT EmptySfl;
Else;
AP SflBegin = *On;
Message = 'No vendors found';
Write Msg;
Endif;
// Write Header_Fmt;
ExFmt VSearchCtl;
// ExFmt Prompt_Fmt;
If Rrn > 1; // Process changes only if subfile has records
Exsr Changes;
EndIf;
Endsr;
Begsr NextPage;
Begsr PrevPage;
// Find out where I am now in the DB
Chain 1 VSearchDta; // Chain to first record in subfile
Exsr SflClear;
Begsr Changes;
ReadC VSearchDta;
ReadC VSearchDta;
Enddo;
Write FKey_Fmt;
Endsr;
/END-FREE
RPG IV Program VNRDLT:
FVendor_PF UF E K Disk
FVndDlt CF E Workstn
D VnrDelete PR ExtPgm('VNRDLT')
D VndNbr 5 0
D VnrDelete PI
D VndNbr 5 0
/FREE
Setll(E) VndNbr Vendor_PF;
If not %error;
If %equal(Vendor_PF);
Delete VndNbr Vendor_PF;
Message = 'Vendor number ' + %char(VndNbr) +
' deleted successfully';
ExFmt MsgWin;
EndIF;
Else;
Message = 'Attempted to delete Vendor ' + %char(VndNbr) +
' that does not exist on file';
ExFmt MsgWin;
EndIf;
*inLR = *on;
/End-free
/free
ExFmt PayFmt;
ExFmt PayFmt;
EndDo;
*InLR = *On;
Return;
/end-free
/Copy RatPer
/Copy Paymnt
RPG IV: Paymnt
PPaymnt B
DPaymnt PI 9 2
DPrincipal 9 2
DRatePeriod 13 11
DNbrPayTot 4 0
/Free
Return (Principal*RatePeriod) /
(1-(1/((1+RatePeriod)**NbrPayTot)));
/End-free
PPaymnt E
RPG IV: Paymnt_PR
DPaymnt PR 9 2
DPrincipal 9 2
AP DRatePeriod 13 11
DNbrPayTot 4 0
RPG IV: Ratper
PRatPer B
D PI 13 11
DRatePCAnn 5 3
DNbrPayYr 2 0
/Free
/End-free
PRatPer E
RPG IV: RatPer_PR
DRatPer PR 13 11
DRatePCAnn 5 3
DNbrPayYr 2 0
Compilation Listing:
1 FLoanPayD CF E WorkStn IndDS(LoanPDS)
*---------------------------------------------------------------------
* RPG name External name
* File name. . . . . . . . . : LOANPAYD AS07V2LIB/LOANPAYD
* Record format(s) . . . . . : PAYFMT PAYFMT
*---------------------------------------------------------------------
2 D LoanPDS DS
3 D Exit 3 3N
4 /Copy RatPer_PR
*---------------------------------------------------------------------
* RPG member name . . . . . : RATPER_PR
* External name . . . . . . : AS07V2LIB/QRPGLESRC(RATPER_PR)
* Last change . . . . . . . : 07/31/03 14:58:09
* Text 'description' . . . . : Ex 15 - Calc periodic interest rate PR
*---------------------------------------------------------------------
5+
6+DRatPer PR 13 11
7+
8+** RATPER - Calc dec periodic interest rate PROTOTYPE
9+
10+DRatePCAnn 5 3
11+DNbrPayYr 2 0
12+
13 /Copy Paymnt_PR
*---------------------------------------------------------------------
* RPG member name . . . . . : PAYMNT_PR
* External name . . . . . . : AS07V2LIB/QRPGLESRC(PAYMNT_PR)
* Last change . . . . . . . : 07/31/03 14:58:09
* Text 'description' . . . . : Ex 16 - Calc loan payment PROTOTYPE
*---------------------------------------------------------------------
14+
15+DPaymnt PR 9 2
16+
17+ ** Calc loan payment PROTOTYPE
18+
19+DPrincipal 9 2
20+DRatePeriod 13 11
21+DNbrPayTot 4 0
22+
23
24 /free
25=IPAYFMT
*---------------------------------------------------------------------
* RPG record format . . . . : PAYFMT
* External format . . . . . : PAYFMT : AS07V2LIB/LOANPAYD
*---------------------------------------------------------------------
26=I S 1 9 2PRINCIPAL
27=I S 10 14 3RATEPCANN
28=I S 15 16 0NBRPAYYR
29=I S 17 20 0NBRPAYTOT
30 ExFmt PayFmt;
31
32 DoW NOT Exit;
33 RatePeriod = Ratper(RatePCAnn:NbrPayYr);
34 PaymentAmt = Paymnt(Principal:RatePeriod:NbrPayTot);
35
36 ExFmt PayFmt;
37 EndDo;
38
39 *InLR = *On;
40 Return;
41 /end-free
42 /Copy RatPer
*---------------------------------------------------------------------
* RPG member name . . . . . : RATPER
* External name . . . . . . : AS07V2LIB/QRPGLESRC(RATPER)
* Last change . . . . . . . : 07/31/03 14:58:09
* Text 'description' . . . . : Ex 15 - Calc periodic interest rate SU
*---------------------------------------------------------------------
43=OPAYFMT
*---------------------------------------------------------------------
* RPG record format . . . . : PAYFMT
* External format . . . . . : PAYFMT : AS07V2LIB/LOANPAYD
*---------------------------------------------------------------------
44=O PRINCIPAL 9S ZONE 9,2
45=O RATEPCANN 14S ZONE 5,3
46=O NBRPAYYR 16S ZONE 2,0
47=O NBRPAYTOT 20S ZONE 4,0
48=O RATEPERIOD 33S ZONE 13,11
Step 3-3 The VNRSCHMAIN procedure lists the VNRDLTPROC Module in the
Imported (unresolved) symbols display. The import request would be resolved
when we run CRTPGM.
D VnrDelete PR ExtProc('VNRDLTPROC')
D VndNbr 5 0
CRTPGM:
Create Program (CRTPGM)
Additional Parameters
Step 2 - 1
CRTPGM PGM(AS07nnLIB/VNRSCHREF)
MODULE(AS07nnLIB/VNRSCHMAIN)
BNDSRVPGM(AS07nnLIB/MYSRVPGM)
Step 3 - 1 VNRSCHMAIN is the PEP; it is the first (and only) module
referenced.
backpg
Back page
®