Presentation is loading. Please wait.

Presentation is loading. Please wait.

Getting Started Chapter 2 Presentation © Copyright 2002, Bryan Meyers

Similar presentations


Presentation on theme: "Getting Started Chapter 2 Presentation © Copyright 2002, Bryan Meyers"— Presentation transcript:

1 Getting Started Chapter 2 Presentation © Copyright 2002, Bryan Meyers
4/21/2017 Getting Started Chapter 2 Presentation © Copyright 2002, Bryan Meyers

2 Objectives Describe the RPG Specification forms
4/21/2017 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 Programming in RPG IV Third Edition

3 Specifications in RPG IV
4/21/2017 Specifications in RPG IV Different specifications for different purposes File Description Specifications Describe files used by program Definition Specifications Describe working variables, structures Input Specifications Describe input fields in files Calculation Specifications Processing instructions Output Specifications Describe program output (reports, files, etc.) Programming in RPG IV Third Edition

4 File Description Specifications
4/21/2017 File Description Specifications File Name File Type File Designation File Format Record Length Device * FFilename++IPEASFRlen+LKlen+AIDevice+.Keywords FSalesMast IF F DISK FQPRINT O F PRINTER Programming in RPG IV Third Edition

5 Input Specifications Record Identification Entries
4/21/2017 Input Specifications Record Identification Entries File Name Sequence Field Description Entries Field Location Decimal Positions Field Name * IFilename++SqNORiPos1+NCCPos2+NCCPos3+NCC I Fmt+SPFrom+To+++DcField L1M1FrP1MnZr...... ISalesMast NS I SlspNumber I SlspName I ItemNumber I DateOfSale I Price Programming in RPG IV Third Edition

6 Output Specifications
4/21/2017 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 * OFilename++DF..N01N02N03Excnam++++B++A++Sb+Sa O N01N02N03Field YB.End++PConstant/editword/DTformat++ OQPRINT E Headings O ‘PAGE ’ O PAGE O ‘WEEKLY SALES REPORT ’ O ‘DATE ’ O *DATE Y Programming in RPG IV Third Edition

7 Pseudocode for Program
4/21/2017 Pseudocode for Program WRITE report headings READ a record WHILE there are more records WRITE a detail line READ the next record ENDWHILE END Program Programming in RPG IV Third Edition

8 Calculation Specifications
4/21/2017 Calculation Specifications Except Read Dow Enddo Eval Return * /FREE EXCEPT Headings; READ SalesMast; DOW NOT %EOF; EXCEPT Detail; ENDDO; EVAL *INLR =*ON; RETURN; /END-FREE Programming in RPG IV Third Edition

9 Fixed-Format C-Specifications
4/21/2017 Fixed-Format C-Specifications Before Version 5, compiler did not support free-format calculations Fixed-format C spec required * CL0N01Factor Opcode(E)+Factor Result Len++D+HiLoEq.... CL0N01Factor Opcode(E)+Extended-factor C EXCEPT Headings C READ SalesMast C DOW NOT %EOF C EXCEPT Detail C ENDDO C EVAL *INLR =*ON C RETURN Programming in RPG IV Third Edition

10 Internal Documentation
4/21/2017 Internal Documentation Comment lines begin with // Starting at Version 5 Free format specifications Comment can make up entire line or a portion of the line, after the code // can be anywhere from 8-80 Fixed format specifications Comment must make up entire line // Can be anywhere from 7-80 Fixed format also supports comments that start with * in column 7 Used exclusively before Version 5 Blank lines are also allowed Programming in RPG IV Third Edition

11 Completed Program - F & I
4/21/2017 Completed Program - F & I * // *********************************************************************** // This program produces a weekly sales report. The report data comes // directly from input file SalesMast. // Author: J.Yaeger Date Written: 12/10/1994. // Date Modified: 12/20/2001. FSalesMast IF F DISK FQPRINT O F PRINTER ISalesMast NS I SlspNumber I SlspName I ItemNumber I DateOfSale I Price Programming in RPG IV Third Edition

12 Completed Program - C Spec
4/21/2017 Completed Program - C Spec * /FREE EXCEPT Headings; READ SalesMast; DOW NOT %EOF; EXCEPT Detail; ENDDO; EVAL *INLR =*ON; RETURN; /END-FREE * C EXCEPT Headings C READ SalesMast C DOW NOT %EOF C EXCEPT Detail C ENDDO C EVAL *INLR =*ON C RETURN (Before V5) Programming in RPG IV Third Edition

13 Completed Program - O Spec
4/21/2017 Completed Program - O Spec * OQPRINT E Headings O 'PAGE' O PAGE O 'WEEKLY SALES REPORT' O 'DATE' O *DATE Y O E Headings O 'SLSPSN.' O 'DATE OF' O 'SALE' O E Headings O 'NO.' O 'NAME' O 'SALE' O 'ITEM SOLD' O 'PRICE' Programming in RPG IV Third Edition

14 Completed Program - O Spec
4/21/2017 Completed Program - O Spec * O E Detail O SlspNumber O SlspName O DateOfSale Y O ItemNumber O Price Programming in RPG IV Third Edition

15 Edit Codes Commas Print Zero No Sign CR Right - Floating - Yes 1 A J N
4/21/2017 Edit Codes Commas Print Zero No Sign CR Right - Floating - Yes 1 A J N No 2 B K O 3 C L P 4 D M Q Programming in RPG IV Third Edition

16 Edit Words Value Edit Word Prints 999999999 ‘bbb-bb-bbbb’ 999-99-9999
4/21/2017 Edit Words Value Edit Word Prints ‘bbb-bb-bbbb’ ‘bbb&bb&bbbb’ ‘0(bbb)bbb-bbbb’ (123) 00012^14 ‘bbb$0.bb’ $12.14 ‘$bbbb0.bb’ $ 05612^14 ‘$bb,bb0.bb’ $ 5,612.14 Programming in RPG IV Third Edition

17 4/21/2017 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 Programming in RPG IV Third Edition

18 4/21/2017 Points to Remember 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 Programming in RPG IV Third Edition

19 4/21/2017 Points to Remember It generally is customary to edit numeric values that are printed Comment lines, which begin with //, can appear almost anywhere within a program Programming in RPG IV Third Edition


Download ppt "Getting Started Chapter 2 Presentation © Copyright 2002, Bryan Meyers"

Similar presentations


Ads by Google