200 likes | 563 Views
RPG IV. Getting Started - Chapter 2. Objectives :. Describe the RPG Specification forms Create a simple read/write RPG program Explain how to include comment lines in a program Explain how to do output editing to control the appearance of a report. Specifications in RPG IV.
E N D
RPG IV Getting Started - Chapter 2
Objectives: • Describe the RPG Specification forms • Create a simple read/write RPG program • Explain how to include comment lines in a program • Explain how to do output editing to control the appearance of a report
Specifications in RPG IV • Different specifications for different purposes • File Description Specifications • Input Specifications • Definition Specifications • Calculation Specifications • Output Specifications
File Description Specifications • File Name • File Type • File Designation • File Format • Record Length • Device
Input Specifications • Record Identification Entries • File Name • Sequence • Field Description Entries • Field Location • Decimal Positions • Field Name
Output Specifications • Record Identification Entries • File Name • Type • Exception Name • Space and Skip Entries • Field Description Entries • Field Name • Constants • End Position in Output Record • Edit Codes
Calculation Specifications • Except • Read • Dow • Enddo • Eval • Return
Internal Documentation • Comment lines • * in position 7
Completed Program - F & I *..1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 F************************************************************************** F* This program produces a weekly sales report. The report data comes * F* directly from input file SalesMast. * F* Author: J. Yaeger Date Written: 12/10/94 * F************************************************************************** *..1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 F*ilename++IP FRlen+ Device FSalesMast IF F 63 DISK FQPRINT O F 132 PRINTER *..1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 I*ilename++Sq ISalesMast NS I* From+To+++DcField+++++++++ I 1 4 0SlspNumber I 5 34 SlspName I 35 50 ItemNumber I 51 56 0DateOfSale I 57 63 2Price
Completed Program - C Spec *..1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 C* Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++DcHiLoEq C EXCEPT Headings C READ SalesMast C DOW NOT %EOF C EXCEPT Detail C READ SalesMast C ENDDO C EVAL *INLR = *ON C RETURN
Completed Program - O Headings Spec *..1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 O*ilename++D ExceptnameB++A++Sb+Sa+ OQPRINT E Headings 2 2 *..1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 O* Field+++++++++Y End++ Constant/Editword+++++++++++ O 8 'PAGE' O PAGE 13 O 50 'WEEKLY SALES REPORT' O 64 'DATE' O UDATE Y 73 O E Headings 1 O 7 'SLSPSN.' O 48 'DATE OF' O 77 'SALE' O E Headings 2 O 3 'NO.' O 21 'NAME' O 46 'SALE' O 61 'ITEM SOLD' O 77 'PRICE'
Completed Program - O Detail Spec *..1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 O*ilename++D ExceptnameB++A++Sb+Sa+ O E Detail 1 *..1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 O* Field+++++++++Y End++ Constant/Editword+++++++++++ O SlspNumber 4 O SlspName 37 O DateOfSale Y 48 O ItemNumber 67 O Price 1 79
Points to Remember • RPG programs are written as fixed-form specifications. • Different specification forms convey different kinds of information to the RPG compiler • File Specifications contain descriptions of all files used within a program.
Points to Remember (cont) • Input Specifications provide detail information about each program described input file used by a program. • Calculation Specifications center on operations, or processing steps, to be accomplished by the computer. • Output Specifications provide details about each program-described output file.
Points to Remember (cont) • It generally is customary to edit numeric values that are printed. • Comment lines, signaled by an * in position 7 of a specification line, can appear anywhere within a program.