Professional Documents
Culture Documents
Laboratorios Estudiante Ile Rpgiv 3
Laboratorios Estudiante Ile Rpgiv 3
Laboratorios Estudiante Ile Rpgiv 3
to RPG IV
Student Exercises
Student Exercises
Exercise Description
You are given the opportunity to work through the exercises given
what was taught in lecture using your Student Notebook and the
reference materials.
In this class, you will be provided with working code that you must
update to include the version 5 features covered in the lecture unit
as well as features from previous units when they apply.
Passwords
Your password, OE85, is set to expire at initial signon. Please
change your password to something that you can easily
remember.
All objects that you require to solve the problems are included in
your student library. Should any object be accidentally deleted or
corrupted, you may refresh the appropriate object by copying the
original master files from the Student Master Library, OE85XXX.
Exercise Description v
Student Exercises
Should you have any problem that you cannot solve on your
own, please ask your instructor for assistance.
vi RPG/400 to RPG IV
Student Exercises
The program will list all the records in a supplied database file
(APPVEND) using an externally described printer file (APPLIST),
calculating some additional fields for the report.
Required Materials
Reference the record and file layouts in your appendix.
Exercise Instructions
1. Preparation
a. Verify that the source members APPFREF, APPVEND and APPLIST are in
QDDSSRC in your library. Review each of the source members, and
familiarize yourself with the field names used in APPVEND and APPLIST.
You will find the DDS in the appendix of this notebook.
APPLIST Printer File
A REF(APPFREF)
**
A R HEADFORMAT SKIPB(1) SPACEA(1)
A 5'Number'
A 12'Supplier Name'
A 39'Address'
A 67'Zip'
A 76'Purchases YTD'
A 97'Balance'
A 108'Monthly Amt'
**
A R LISTFORMAT SPACEB(1)
A VNDNBR R 5
A VNDNAM R +2
A VNDAD1 R +2
A VNDZIP R +2
A PCHYTD R +4EDTCDE(J)
A BALOWE R +2EDTCDE(J)
A MONTHLY R +2EDTCDE(J) REFFLD(BALOWE)
A LARGEBAL 2 +4
2. Code APPVENDPRT
a. Code a new RPG IV program APPVENDPRT in your QRPGLESRC source
file to produce a list of every record in APPVEND. Use the print formats
provided in APPLIST. Pay particular attention to the following:
1) The member type should be RPGLE.
2) the field MONTHLY which is to be calculated by dividing BALOWE by
the value 12
3) the field LARGEBAL which should contain two asterisks '**' if
BALOWE contains a value greater than 5000, (otherwise the field
should remain blank)
4) use SEU formatted prompting for the various specification types, and
review obvious changes
Number Supplier Name Address Zip Purchases YTD Balance Monthly Amt
00688 SHARON PHILIPS CORP. 3468 NETOWN RD. 01610 500,000.00 25,000.00 2,083.33 **
63218 ACE DISTRIBUTORS 461 DELMAR RD. N.E. 72183 20,000.00 .00 .00
13130 T.M.ELLIOT INC. 681 MAIN ST. 34216 25,000.00 17,500.00 1,458.33 **
00016 BRAND X BEER TALLMAN BLDG. 64538 70,000.00 30,000.00 2,500.00 **
01148 JOHNSON & SONS 45 PARKWAY SO. 94034 6,850,000.00 750,000.00 62,500.00 **
00021 MEMORIAL CARETAKERS LAWRENCEVILLE HWY. 20438 100,000.00 35,000.00 2,916.66 **
00221 GEORGE RUDOLPH INC. 3184 BLDG. 6 13645 2,500.00 500.00 41.66
05075 PETER VAN ROTH CORP. VAN ROTH BLDG. 71063 100,000.00 20,000.00 1,666.66 **
10504 THE DEANA AGENCY 280 PARK AVENUE 10017 5,000,000.00 750,000.00 62,500.00 **
11002 THE DISK RECORD SHOP 461 CONGRESS AVENUE 91462 20,000.00 5,000.00 416.66
00010 JOHN M. SMITH & SONS 2732 FOURTH AVENUE 10001 50,000.00 4,500.00 375.00
10502 HUGH WILLSON & SON 4583-10 LANDMARK TOWERS 32110 400,000.00 75,000.00 6,250.00 **
34681 THE BREAKERS INC. 41 MANSION DR. 02840 200,000.00 2,000.00 166.66
21178 THE FRAMING PLACE HUNTS RD. 02185 30,000.00 5,000.00 416.66
00145 T.H.BRAYTON JR. 3636 DEWEY AVENUE 56513 45,000.00 15,000.00 1,250.00 **
07733 SEAL PRODUCTS INC. 45 HARRIS AVE. 34840 150,000.00 50,000.00 4,166.66 **
00612 R.H.GROCERY STORE 34 COLLIER RD. 75021 3,000.00 250.00 20.83
00011 FETZNER & FETZNER 34 MILL BLUFF ROAD 17625 50,000.00 750.00 62.50
END OF LAB
Exercise Instructions
1. Preparation
a. Verify that the source member DISCSUMMRY is in QDDSSRC in your
library. Review the source member, and familiarize yourself with the
format and field names that are used.
b. Compile DISCSUMMRY to produce a printer file in your library.
A R HEADERFMT SKIPB(2)
A USERID 10 3
A 29'DISCOUNT SUMMARY REPORT'
A UNDERLINE
A 73DATE EDTCDE(Y) SPACEA(2)
A 3'Discount'
A 14'Purchases'
A 27'Discounts'
A 42'Purchases'
A 57'Discounts'
A 74'Balance' SPACEA(1)
A 3'Percent'
A 17'MTD'
A 30'MTD'
A 45'YTD'
A 60'YTD'
A 76'Due' SPACEA(1)
**
A R PRINTREC SPACEB(1)
A PROMPTDISC 3 2 3EDTCDE(J)
A PURCHMTD 11 2 9EDTCDE(J)
A DISCMTD 9 2 24EDTCDE(J)
A PURCHYTD 11 2 37EDTCDE(J)
A DISCYTD 11 2 52EDTCDE(J)
A BALANCEDUE 11 2 67EDTCDE(J)
à ð
OE85000 DISCOUNT SUMMARY REPORT 9/11/01
Discount Purchases Discounts Purchases Discounts Balance
Per Cent MTD MTD YTD YTD Due
.04 25,000.00 .00 400,000.00 .00 5,500.00
.05 1,277,200.00 2,660.00 32,710,355.00 41,375.00 1,705,500.00
.08 10,000.00 100.00 100,000.00 10,000.00 20,000.00
.10 474,420.00 1,145.00 7,324,000.00 24,335.00 1,830,750.00
.15 249,350.00 925.00 1,178,050.00 13,500.00 320,500.00
.20 450,000.00 400.00 6,850,000.00 40,000.00 750,000.00
á ñ
END OF LAB
The program will list all the records in the APPVEND physical file, using an externally
described display file (APPVENDSFL). You will also need to calculate the Sales Tax
and Net Balance owed.
Exercise Instructions
1. Preparation
a. Verify that the source member APPVENDSFL is in QDDSSRC in your
library. Review the source member, and familiarize yourself with the
format/field names used. Note, you will be using subfile processing.
c. Update the Local Data Area (LDA) to contain the current tax rate in the
first four (4) positions. In our exercise, we will use 17.50 percent. Enter
1750 (as a character value) in the LDA.
2. Code APPENDDSP
a. Code a new RPG IV program APPVENDDSP in your QRPGLESRC source
file to list APPVEND records on the display. Use the display formats
provided in APPVENDSFL. Pay particular attention to the following:
1) the Tax Rate (VATRATE) is to be extracted from the LDA
2) the Tax Amount (VATAMOUNT) and Net Amount (NETAMOUNT) fields
are to be calculated in your program
The government has provided you with the following information to
enable you to accurately calculate the tax:
Tax Due = Taxable Amount x (Tax Rate / (100 + Tax Rate))
b. Compile your program using PDM option 14.
c. Once your program has compiled, review the compiler listing.
d. Run your program to display APPVEND. Verify your results with the
sample provided below.
APPVENDSFL Display
04/30/98 SUPPLIER LIST NET TAX OE85000
The RPG program in this example calculates the weekly pay for hourly employees,
calculates the tax to be withheld and the net pay resulting from subtracting the tax
from the earnings.
Your task is to replace the existing calculations for the earnings and the tax
calculations. The program prints a report so you can check the accuracy of your
calculations.
Exercise Instructions
1. Preparation
a. Verify that the source member, RPGPAY, is in your source file.
b. Verify that the files PAYROLL and PRODFILE are in your library.
á ñ
C SETON LR Set LR
C RETURN Return
C PAYC BEGSR
C* Calculate payment - hours over 35 get additional 75%
C*
C HOURS IFLE 35 Hours <= 35
C HOURS MULT RATE PAY Total pay
C ELSE -else-
C RATE MULT 35 PAY 7 2 Full 35 hrs
C HOURS SUB 35 OTIME 3 0 Overtime hours
C RATE MULT 1.75 OTRATE 9 4 Find rate
C OTRATE MULT(H) OTIME OTPAY 7 2 Overtime pay
C ADD OTPAY PAY Total pay
C END
C ENDSR
C TAXC BEGSR
C* Calculate Tax - the first 200 dollars of earnings are tax free
C*
C PAY IFLE 200 Pay < 200
C Z-ADD 0 TAX 7 2 no tax
C ELSE -else-
C PAY SUB 200 TXABLE 7 2 200 tax free
C TXABLE MULT TAXD TXWRK 9 2 calc %
C TXWRK DIV(H) 100 TAX Tax to pay
C END
C ENDSR
OQPRINT E HDG 2 06
O 25 'Pay and tax calculation'
O UDATE Y 36
O E HDG 2
O 19 'First and Last name'
O 36 'Earned'
O 46 'Pay tax'
O 56 'Net pay'
O E DETAIL 1
O FNAME 10
O LNAME 26
O PAY 3 36
O TAX 3 46
O NET 3 56
3. Modify RPGPAY
a. Make the appropriate source code changes to rewrite the program to use
the following RPG IV features:
Define all variables on the D-spec rather than on the C-spec
Move the definition of the field Net to the D-spec
Make liberal use of mixed case to make your code more readable
Replace all arithmetic opcodes with Evals
á ñ
END OF LAB
Your task is to replace all existing indicators with BIFs and to add limited error
handling.
Exercise Instructions
1. Modify RPGPAY
a. Make a copy of your RPGPAY solution from the previous exercise. and
name it RPGPAYE.
b. Remove the indicator on the READ statements and replace all instances of
the indicator with a Built-in-Function.
c. Compile and test your program to confirm that it produces the same
output as your original solution.
Introduction
You are given the DSPF DDS and will write a date program that
will use date processing BIFs.
Exercise Instructions
à ð
Date Exercise Today's Date 2001-07-10
// End
C Write Header
C Write Footer
C Exfmt Prompt
// End
C If %error
C Eval BadDate = *On
C Else
// Display details
// Insert code to extract year, month, day from date entered
// End
// Insert code to
// determine number of days between job date and date entered
// End
// Is Days in the past or the future?
C If Days < 0
C Eval Future = *on
C Else
C Eval Future = *off
C EndIf
C Write Detail
C EndIf
// Display prompt
C Exfmt Prompt
C Enddo
e. The program determines the difference in days between the date entered
and the job date. If the date is in the future, it sets the indicator, Future,
on. The program also handles the opposite situation.
END OF LAB
Exercise Instructions
END OF LAB
Exercise Instructions
Step 1
a. Start PDM and work with the objects in your library.
b. Press Function key F23 and review the options available to you.
c. What option can be used to create a program ?
h. Is there a PDM option to create a program while in the Work with Member
screen?
In the following exercises you will be asked to enter commands like, CRTRPGMOD
and CRTPGM. Both of these have PDM options and F4 can be used to prompt. F5 is
used to refresh the screen. Use this function after you have created an object to
verify that the object is placed in your library.
END OF LAB
This application prints the days since an object was last used.
The calculations for determining the difference between two dates are located in a
separate source member, DAYSSINCE. This procedure accepts as a parameter a date
and returns in a second parameter the number of days between that date and today.
A CL program has also been created to duplicate the QADSPOBJ file and populate it
with the object descriptions. This source is found in member DSPOBJMOD.
Lastly, the RPG mainline program which reads the DSPOBJ file and prints the report
(modified to call DAYSSINCE) is found in member PRTOBJILE.
Your task in this machine exercise is to create all the modules needed from the
source code provided to you and to bind the modules together using Bind by Copy.
Exercise Instructions
1. Create Modules
a. Find and display the source member for the CL module, DSPOBJMOD in
your QCLSRC file. Note the statement that calls the RPG module,
PRTOBJILE. Note that it is a CALLPRC statement rather than a CALL.
This will be a bound call and the DSPOBJMOD module must be bound
with the PRTOBJILE module for it to work.
b. Compile the DSPOBJMOD member using the option 15 from PDM or the
CRTCLMOD command. Take the defaults for the compile.
c. Find and display the source member for the RPG module, PRTOBJILE.
Note the statement that calls the RPG module, DAYSSINCE. Note that it is
also a bound call (CALLB, rather than CALL). Therefore, the DAYSSINCE
module must also be bound with the previous two.
d. Compile the PRTOBJILE module using option 15 from PDM or the
CRTRPGMOD command. Take the defaults for the compile.
e. Find and display the source member for DAYSSINCE in your QRPGLESRC
source file. Compile it using option 15 from PDM or CRTRPGMOD, taking
the defaults.
f. After all modules have compiled successfully, create a bound program
using bind by copy. Use the PDM options for this and name the program
PRTOBJPGM. Include in these modules to be bound: DSPOBJMOD,
PRTOBJILE, and DAYSSINCE. Your finished command should look like
this:
CRTPGM PGM(PRTOBJPGM) MODULE(DSPOBJMOD PRTOBJILE DAYSSINCE)
ENTMOD(DSPOBJMOD)
g. How do you include multiple modules in a program other than keying in
each module name?
HDATEDIT(*YMD) DATFMT(*YMD)
DCurDate S D
DDateIn S D
DNoDays S 5 0
DError C 99999
C *Entry PList
C Parm DateIn
C Parm NoDays
C Test (E) DateIn
C If Not %Error
C Eval CurDate = %Date(*date)
C Eval NoDays = %Diff(CurDate:DateIn:*D)
C Else
C Eval NoDays = Error
C EndIf
C Return
PGM PARM(&LIB)
DCL VAR(&LIB) TYPE(*CHAR) LEN(10)
MONMSG MSGID(CPD2104 CPF2130)
DSPOBJD OBJ(&LIB/*ALL) OBJTYPE(*PGM) DETAIL(*BASIC) +
OUTPUT(*OUTFILE) +
OUTFILE(*CURLIB/DSPOBJ) /* CL Command +
to put all program objects from requested +
library into DSPOBJ for input to PRTOBJILE */
CALLPRC PRC(PRTOBJILE)
endpgm
Exercise Instructions
The DAYSSINCE module is called by the PRTOBJPGM module. You will create a
Service Program containing this module and re-create the programs to use this new
service program and a static bind by reference.
2. Modify DAYSSINCE
You will modify DAYSSINCE to EXPORT data item CURDATE and then recreate
the service program. This will cause errors in the programs using MYSRVPGM.
Re-binding of those programs will be required.
Defining CURDATE as an EXPORT data item from DAYSSINCE will prepare for the
following exercise.
a. Modify the source for DAYSSINCE so that CURDATE is EXPORTed and
recreate the module. To do this, add the EXPORT keyword in the D-spec
for CURDATE. Specifying EXPORT will make this variable available to be
used as a parameter to modules that call the DAYSSINCE procedure.
A source listing of DAYSSINCE is included.
The Debug data is created when a DBGVIEW option other than *NONE on the
CRTRPGMOD command is used. You will first re-create modules with parameter
DBGVIEW *ALL for program PRTOBJPGM2.
Exercise Instructions
l. At what line number did you set the breakpoint? Make any necessary
corrections.
m. Exit the debugger using F12. Your breakpoints are not removed.
n. CALL PGM(PRTOBJPGM2) PARM(OE85V4LIB).
When the conditional breakpoint is reached, the program will stop and the
module source will display.
o. Move the cursor to variable ODUDAT and press F11. The value for
ODUDAT should be ' ' which explains why *IN10 is set on.
p. Move the cursor to the line number with the conditional breakpoint and
use F6 to clear (remove) it.
q. Exit the debugger using F12.
r. Enter ENDDBG to exit the debug session.
END OF LAB
Exercise Instructions
1. Conversion
a. The RPG source code to be converted is in OE85nnn/RPG400SRC. There
is no need to copy this source into your library.
b. You will need a log file. Use the CPYF command. You have been given
the authority to access the log file during this lab. Notice the name of the
object and the new object name are different below:
CPYF FROMFILE(QRPGLE/QARNCVTLG)
TOFILE(OE85nnn/QRNCVTLG)
CRTFILE(*YES)
c. Convert all members in the source file RPG400SRC into your QRPGLESRC
source file. Submit the CVTRPGSRC command with CVTRPT *YES to
batch. Use the CVTRPT *YES parameter to print a conversion report.
d. Use PDM to browse some of the converted members. Use F15 to split the
screen and browse the corresponding source member from
OE85nnn/RPG400SRC. Can you detect the changes made?
e. Notice that non-RPG members were not converted. Review your job log
for further details.
f. Look at the conversion report in your output queue.
g. Review the Log File using the RUNQRY command. List audit information
paying particular attention to Convert Status Data.
END OF LAB
A*
A** FIELD REFERENCE FILE FOR ACCOUNTS PAYABLE
A** STUDENT EXERCISES
A*
A R REFFMT TEXT('FIELD REFERENCE FILE')
A*
A** FIELDS USED IN MULTIPLE RECORDS
A*
A VNDNBR 5 0 TEXT('VENDOR ID NUMBER')
A COLHDG('VENDOR' 'NUMBER')
A DEPTNO 3 0 TEXT('DEPARTMENT CHARGED')
A COLHDG('DEPARTMENT' 'NUMBER')
A ACTCD 1 TEXT('A=ACTIVE D=DELETE S=SUSPEND')
A COLHDG('ACTIVE' 'RECORD' 'CODE')
A*
A** FIELDS IN VENDOR MASTER RECORD
A*
A VNDNAM 25 TEXT('VENDOR NAME')
A COLHDG('VENDOR' 'NAME')
A VNDAD1 25 TEXT('ADDRESS LINE 1')
A COLHDG('ADDRESS LINE 1')
A VNDAD2 25 TEXT('ADDRESS LINE 2')
A COLHDG('ADDRESS LINE 2')
A VNDAD3 25 TEXT('ADDRESS LINE 3')
A COLHDG('ADDRESS LINE 3')
A VNDZIP 5 0 TEXT('ZIP CODE')
A COLHDG('ZIP' 'CODE')
A VNDACD 3 0 TEXT('AREA CODE')
A COLHDG('AREA' 'CODE')
A VNDPHN 7 0 TEXT('PHONE NUMBER')
A COLHDG('PHONE')
A VTRMPC 3 3 TEXT('NORMAL PROMPT PAY DISCOUNT%')
A COLHDG('TERMS' '%')
A VTRMDA 2 0 TEXT('NORMAL NO. OF DAYS FOR TERMS')
A COLHDG('TERMS' 'DAYS')
A VNDCLS 2 0 TEXT('VENDOR CLASS')
A COLHDG('CLASS')
A VNDSLS 25 TEXT('VENDOR SALESMAN')
A COLHDG('SALESPERSON')
A COLHDG('DISPERSED' 'MTD')
A DISYTD 11 2 TEXT('AMOUNT DISPERSED THIS YEAR')
A COLHDG('DISPERSED' 'YTD')
A GLACT 6 0 TEXT('GENERAL LEDGER ACCOUNT NBR')
A COLHDG('G/L' 'ACCOUNT' 'NUMBER')
A*
A** FIELDS USED IN ITEM MASTER FILE
A*
A ITMNBR 5 0 TEXT('ITEM NUMBER')
A COLHDG('ITEM' 'NUMBER')
A ITMDSC 25 TEXT('ITEM DESCRIPTION')
A COLHDG('ITEM' 'DESCRIPTION')
A ITMQOH 7 0 TEXT('QUANTITY ON HAND')
A COLHDG('QUANTITY' 'ON HAND')
A ITMQOO 7 0 TEXT('QUANTITY ON ORDER')
A COLHDG('QUANTITY' 'ON ORDER')
A ITMCST 5 2 TEXT('ITEM UNIT COST')
A COLHDG('ITEM' 'UNIT' 'COST')
A ITMPRC 5 2 TEXT('ITEM UNIT PRICE')
A COLHDG('ITEM' 'UNIT' 'PRICE')
A CATNBR 7 TEXT('VENDOR CATALOG NUMBER')
A COLHDG('VENDOR' 'CATALOG' 'NUMBER')
A*
A** FIELDS USED FOR PURCHASE ORDERS
A*
A PORNBR 6 0 TEXT('PURCHASE ORDER NUMBER')
A COLHDG('PURCHASE' 'ORDER' 'NUMBER')
A DATORD 6 0 TEXT('DATE ORDERED')
A COLHDG('DATE' 'ORDERED')
A ITMAMT 7 2 TEXT('ITEM EXTENDED AMOUNT')
A COLHDG('ITEM' 'EXTENDED' 'AMOUNT')
A QTYORD 5 0 TEXT('ITEM ORDERED QUANTITY')
A COLHDG('ITEM' 'ORDERED' 'QUANTITY')
A QTYREC 5 0 TEXT('ITEM QUANTITY RECEIVED')
A COLHDG('ITEM' 'QUANTITY' 'RECEIVED')
A DATDUE 6 0 TEXT('INVOICE DUE DATE')
A COLHDG('INVOICE' 'DUE' 'DATE')
A*
A** ADDITIONAL FIELDS
A*
A DUYR 2 0 TEXT('VENDOR INVOICE DUE DATE +
A - YEAR')
A COLHDG('INVOICE' 'DUE' 'DATE')
A DUMODY 4 0 TEXT('VENDOR INVOICE DUE DATE +
A - MONTH DAY')
A COLHDG('INVOICE' 'DUE' 'MONTH-DAY')
A DCTAVL 5 2 TEXT('VENDOR INVOICE DISCOUNT +
A AVAILABLE')
A EDTCDE(3)
A COLHDG('INVOICE' 'DISCOUNT' +
A 'AVAILABLE')
A DUDATE 6 0 TEXT('VENDOR INVOICE DUE DATE: +
A MONTH-DAY-YEAR')
A EDTCDE(Y)
A COLHDG('DISPLAY' 'DUE DATE' 'MO-DAY+
A -YR')
A REF(APPFREF)
A R VENDMAST
A VNDNBR R
A VNDNAM R
A VNDAD1 R
A VNDAD2 R
A VNDAD3 R
A VNDZIP R
A VNDACD R
A VNDPHN R
A VTRMPC R
A VTRMDA R
A VNDCLS R
A ACTCD R
A VNDSLS R
A DCTMTD R
A DCTYTD R
A PCHMTD R
A PCHYTD R
A BALOWE R
A SRVRTG R
A DELRTG R
A COMNTS R
A SCHCOD R
A COLHDG('Item' 'Num')
A ITMDESCR 25 TEXT('Item Description')
A COLHDG('Item' 'Description')
A ITMQTYOH 7 0 TEXT('Quantity on Hand')
A COLHDG('Qty' 'on' 'Hand')
A ITMQTYOO 7 0 TEXT('Quantity on Order')
A COLHDG('Qty' 'on' 'Order')
A ITMCOST 5 2 TEXT('Item Unit Cost')
A COLHDG('Item' 'Unit' 'Cost')
A ITMPRICE 5 2 TEXT('Item Unit Price')
A COLHDG('Item' 'Unit' 'Price')
A ITMVNDCAT# 7 TEXT('Vendor Catalog Number')
A COLHDG('Vendor' 'Catalog' 'Number')
A*
A** Fields Used For Purchase Order Summary File, POSUM_PF
A*
A PONBR 6 0 TEXT('Purchase Order Number')
A COLHDG('Purch' 'Order' 'Number')
A POTOTAMT 7 2 TEXT('Purchase Order Amount')
A EDTCDE(3)
A COLHDG('Purch' 'Order' 'Amount')
A PODATE 8 0 TEXT('PO Date: YYYYMMDD')
A COLHDG('PO' 'Date' 'YYYYMMD')
A POSTATUS 1 TEXT('O=On Order C=Complete +
A D=Delete')
A COLHDG('PO' 'Sts')
A VALUES(' ' 'O' 'C' 'D')
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 +
Our solutions represent only one way to solve the problem. You may develop a
different solution that produces the desired result. Our solutions were written to show
you various features of RPG IV. You will notice liberal use of expressions and upper /
lower case coding.
FAppVend IF E Disk
FAppList O E Printer
** Read first record
C Read AppVend LR LR
C Write HeadFormat
C *InLR DoWNE *on
** Set flag for BALOWE > 5000
C BalOwe IfGT 5000
C Move '**' LargeBal
C Else
C Move *blanks LargeBal
C EndIf
** Calculate monthly repayment
C Balowe Div (H) 12 Monthly
C Write ListFormat
C Read AppVend LR LR
C EndDo
** End of program
FAppVend IF E Disk
FDiscSummryO E Printer
** Arrays for summary totals
D PurchMtdAr S Dim(20) LIKE(PurchMtd)
D DiscMtdAr S Dim(20) LIKE(DiscMtd)
D PurchYtdAr S Dim(20) LIKE(PurchYtd)
D DiscYtdAr S Dim(20) LIKE(DiscYtd)
D BalanceAr S Dim(20) LIKE(BalanceDue)
D NoRecsAr S 3 0 Dim(20)
D Idx S 3 0
** Print Page Heading and Read first record
C Eval UserId = 'OE85000'
C Write HeaderFmt
C Read AppVend LR
** Read rest of file
C DoW *InLR = *Off
** Derive array index
C Eval Idx = VtrmPC * 100
C Eval PurchMtdAr(Idx) = PurchMtdAr(Idx) + PchMT
C Eval DiscMtdAr(Idx) = DiscMtdAr(Idx) + DctMTD
C Eval PurchYtdAr(Idx) = PurchYtdAr(Idx) + PchYT
C Eval DiscYtdAr(Idx) = DiscYtdAr(Idx) + DctYTD
C Eval BalanceAr(Idx) = BalanceAr(Idx) + BalOwe
C Eval NoRecsAr(Idx) = NoRecsAr(Idx) + 1
** Read next record
C Read Appvend LR
C EndDo
** Now print summary lines if all totals zero
C Do 20 Idx
C If NoRecsAr(Idx) > 0
C Eval PromptDisc = Idx / 100
C Eval PurchMtd = PurchMtdAr(Idx)
C Eval DiscMtd = DiscMtdAr(Idx)
C Eval PurchYtd = PurchYtdAr(Idx)
C Eval DiscYtd = DiscYtdAr(Idx)
C Eval BalanceDue = BalanceAr(Idx)
C Write PrintRec
C EndIf
C EndDo
H ExprOpts(*ResDecPos)
FAppVend IF E Disk
FAppVendSFLCF E WorkStn Sfile(FmtRec:RecNo)
** Define VAT rate; fetch from LDA
D UDS
D VatRate 4 2
** Define Subfile RRN; initialize to 1
D RecNo S 4 0 Inz(1)
C Read AppVend 90
C DoW Not *in90
** Calculate VAT amount and Net amount
C Eval(H) VatAmount = BalOwe * (VatRate /
C (100 + VatRate))
C Eval NetAmount = BalOwe - VatAmount
** Write Subfile record format
C Write FmtRec
C Read AppVend 90
C Eval RecNo = RecNo + 1
C EndDo
** Display Subfile
C Write FmtFtr
C ExFmt FmtCtl
** End program if F3 or ENTER pressed
C Eval *InLr = *On
C Return
H ExPrOpts(*ResDecPos)
F* RPGPAY - Pay check program
F*
FPayroll IF E Disk
** Define overflow named indicator
FQprint O F 132 Printer Oflind(Overflow)
* +++++ Define the Tax and Pay fields based on the database
D Pay S +2 Like(Rate)
D Tax S +2 Like(Rate)
D Net S +2 Like(Rate)
D FLname S 25
C*
C Except Hdg
C* Read a record
C DoW not(*in20)
C Read Payrec 20
C*
C If not(*in20)
C***
C* Calculate pay and tax
C ExSR PAYC
C ExSR TAXC
C Eval Net = Pay -Tax
C* +++++ Concatenate first and last name
C Eval FLName = %Trimr(LName) + ', '
C + %Trimr(FName)
C Except DETAIL
** Test for overflow
C If Overflow
C Except HDG
C Eval Overflow = *off
C Endif
C EndIf
C EndDo
C***
C Eval *InLR = *on
C Return
C********* Insert Payment calculation here ***********
C PayC BegSR
C*
C If Hours <= 35
C Eval Pay = Hours * Rate
C Else
C Eval(H) Pay = (35 * Rate)
C + ((Hours - 35) * (Rate * 1.75))
C EndIf
C EndSR
C********* Insert Tax calculation here *************
C TAXC BegSR
C*
C Eval Tax = 0
C If Pay > 200
C Eval(H) Tax = (Pay - 200) * (Taxd / 100)
C EndIf
C EndSR
OQPRINT E HDG 2 06
O 25 'Pay and tax calculation '
O UDATE Y 36
O E HDG 2
O 19 'First and Last name'
O 36 'Earned'
O 46 'Pay tax'
O 56 'Net pay'
O E DETAIL 1
O* FNAME 10
O* LNAME 26
* +++++ Delete the FNAME field and write FLname instead of LNAME
O FLname 26
O PAY 3 36
O TAX 3 46
O NET 3 56
H ExPrOpts(*ResDecPos)
F* RPGPAY - Pay check program
F*
FPayroll IF E Disk
** Define overflow named indicator
FQprint O F 132 Printer Oflind(Overflow)
* +++++ Define the Tax and Pay fields based on the database
D Pay S +2 Like(Rate)
D Tax S +2 Like(Rate)
D Net S +2 Like(Rate)
D FLname S 25
C*
C Except Hdg
C* Read a record
C DoW not %eof(Payroll)
** Force an error by closing file
C Close Payroll
**
C Read (E) Payrec
** Check for any problem and abort
C If %error
C Except Error
C Leave
C EndIf
C* Do we have EOF - checking all reads
C If not %eof(Payroll)
C***
C* Calculate pay and tax
C ExSR PAYC
C ExSR TAXC
C Eval Net = Pay -Tax
C* +++++ Concatenate first and last name
C Eval FLName = %Trimr(LName) + ', '
C + %Trimr(FName)
C Except DETAIL
** Test for overflow
C If Overflow
C Except HDG
C Eval Overflow = *off
C Endif
C EndIf
C EndDo
C***
C Eval *InLR = *on
C Return
C********* Insert Payment calculation here ***********
C PayC BegSR
C*
C If Hours <= 35
fVndnam_lf if e k disk
fVndsearch cf e workstn Sfile(VSearchDta:RRN)
f IndDS(SfileInd)
d RRN s 3 0 INZ
d SfileInd 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
**
/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;
SflDsp = *off;
SflDspCtl = *off;
Exfmt Prompt_fmt;
NotFound = *off;
// Start a new search - clear subfile and reset RRN
SflClr = *on;
Write VSearchCtl;
SflClr = *off;
Rrn = 0;
EndDo;
// Eoj
*inlr=*on;
Return;
// Perform once when program loaded
BegSR *inzSr;
Write FKey_Fmt;
Exfmt Prompt_fmt;
// Set SFLEND indicator
SflEnd = *on;
Endsr;
/end-free
How do you include multiple modules in a program other than keying in each
module name?
Use option 26 on multiple modules.
What is the program attribute?
CLLE
What is the number of modules?
3
How many service programs are there?
6
Is the object compressed?
NO
H DatEdit(*YMD) DatFmt(*YMD)
DCurDate S D Export
DDateIn S D
DNoDays S 5 0
DError C 99999
C *Entry PList
C Parm DateIn
C Parm NoDays
C Test (E) DateIn
C If Not %Error
C Eval CurDate = %Date(*date)
C Eval NoDays = %Diff(CurDate:DateIn:*D)
C Else
C Eval NoDays = Error
C EndIf
C Return
When you browse your converted members, you will see this.
OE85000 BOB
5716RG1 V3R7M0 961108 RN IBM ILE RPG/400
From file . . . . . . . . . . . : OE85000/RPG400SRC(RPG05)
To file. . . . . . . . . . . . . : OE85000/QRPGLESRC(RPG05)
Log file . . . . . . . . . . . . : *LIBL/QRNCVTLG(QARNCVTLG)
C o n v e r s i o n R e p o r t
Sequence <----------------------- Source Specifications ----------------
Number ....1....+....2....+....3....+....4....+....5....+....6....+...
002000 C CALL 'RPG05S' DLTPRM
*RNM0511 00 CALL operation code found.
004100 C DEBUG
*RNM0517 30 DEBUG operation code is not supported in RPG IV.
004700 C CALL 'RPG05S' DLTPRM
*RNM0511 00 CALL operation code found.
5716RG1 V3R7M0 961108 RN IBM ILE RPG/400
From file . . . . . . . . . . . : OE85000/RPG400SRC(RPG10)
To file. . . . . . . . . . . . . : OE85000/QRPGLESRC(RPG10)
Log file . . . . . . . . . . . . : *LIBL/QRNCVTLG(QARNCVTLG)
:
:
OE85000 BOB
5716RG1 V3R7M0 961108 RN IBM ILE RPG/400
From file . . . . . . . . . . . : OE85000/RPG400SRC(RPG10)
To file. . . . . . . . . . . . . : OE85000/QRPGLESRC(RPG10)
Log file . . . . . . . . . . . . : *LIBL/QRNCVTLG(QARNCVTLG)
C o n v e r s i o n R e p o r t
Sequence <----------------------- Source Specifications ----------------
Number ....1....+....2....+....3....+....4....+....5....+....6....+...
002500 C CALL 'RPG10S' DLTPRM
*RNM0511 00 CALL operation code found.
005100 C CALL 'RPG10S' DLTPRM
*RNM0511 00 CALL operation code found.
:
: