RPG Programming Notes
RPG Programming Notes
2. What is an indicator?
An indicator is a built-in variable that can have only one of two values: '1' or
'0'.
3) the need arose for a more structured approach to program design, that will
facilitate adequate and efficient revision and maintenance. the methodology
developed to achieve this was called the structured design.
To address these new developments, IBM relaxed many of the strict fixed-
format requirements that were previously imposed and allowed free-format
expressions and keyword notations in its specifications. Data naming limits
have also been extended.
3) structured design
4) interoperability
IBM enabled RPG IV to coexist with internet-based applications and object-
oreiented languages, such as Java and also maintained compatibility with
platforms and software using intel-based computers.
No. Programming languages that requires revisions over time may not be
due to poor design but rather due to changing customer needs and or changes
in industry standards
Syntax errors are errors that occurs when a programmer breaks one or more
rules of the programming language he or she is using. E.g. performing
mathematical operations on a string data type.
Logic errors are errors of design, These types of errors will not be detected
by the compiler. E.g. incorrectly multiplying 2 numbers.
No.. it would not make sense. Because it would be very difficult and time
consuming to make changes. It would be better to store the state, zip code,
city and street address in separate fields.
No... it would require too many field and what will happen with persons that
has the same name?
9. Keeping in mind the fact that all records within a file generally have
the same, fixed number of fields, how do you think your school
handles the problem of storing information about what courses you’ve
taken?
12. Would you build a house without a blueprint? Is this a good analogy
to writing a program without first designing it? Why or why not?
15. Why is it important for students of RPG to learn about the older
versions of RPG?
it is important for students to learn the older versions of RPG because most
companies still use programs that were written ten or more years ago.
Therefore, they must be able to understand the features of these language
versions so that they can maintain such programs which that were written in
RPG II or RPG III.
16. Why is the fixed logic cycle not used in RPG today
The Fixed logic cycle minimizes the need for programmers to write explicit
procedural instructions within their programs. However, as customer's needs
become more varied and complex, programmers required more
understandability and control over the processing and instructions within
their programs. This requirement therefore, led to the abandonment of the
fixed logic cycle.
Length notation is a method used to present the record layout of a file, fields
are listed in the order they appear in the file, along with the length of each
field. Positional notation, however, explicitly shows the beginning and
ending position of each field along with any decimal positon. Length
notation is preferred, because it is easier to specify.
18. What are the benefits of using IDEs such as Rational Developer for
i (RDi) instead of traditional development tools like SEU, SDA, and
PDM?
The main benefit of using RDI is that it has a familiar windows explorer-like
look and feel. It provides easy navigation and organization of libraries,
objects, and members. It has the LPEX editor, which has intelli-sense. Last
but not least, Ibm doesn’t plan on enhancing traditional development tools
in the future.
CHAPTER 2
1. Explain the use of the DCL-S instruction.
The DCL-S instruction is used to declare variables that does not
originate from a file or depend on a specific structure or format. Such
variables are called standalone variables.
2. List the sections of an RPG program and describe the use of these
sections
8. List some fields that ILE RPG automatically provides for your
use.
ILE RPG provides all the fields in a file that has been declared. As it
relates to the CUSTOMERS files, the following are some of the fields
that will be provided for use:
Customer number
Customer First name
Customer last name
Customer street address
9. Why do you often need to read statements within a program?
Because it makes all the field values in a record available to the
program for processing.
10. Explain the use of the Oflind keyword.
The Oflind (Overflow indicator) keyword is used to signal an “end-of-
page” condition. This condition occurs when a printed report reaches
the bottom of a page.
11.List and explain the different options available when using the
Dcl-f declaration
Some options available when using the DCL-F declaration are as
follows:
18. Research and list the data types that are supported in RPG.
Character Format
Graphic Format
UCS-2 Format
19.Explain what the RPG cycle is. Is the RPG cycle still in use today?
The RPG cycle is a set of procedures that are implicitly specified in
the main section of a program. The RPG cycle does not have a name,
it is the main procedure by virtue of its location in the program code.
The RPG cycle minimizes the need for programmers to write explicit
procedural instructions within their programs. However, as customer's
needs become more varied and complex, programmers required more
understandability and control over the processing and instructions
within their programs. This requirement therefore, led to the
abandonment of the fixed logic cycle.
CHAPTER 3
1. Explain the advantages of externally describing database files. Do
externally described printer files share the same advantages?
i. Externally described files saves a programmer from having to
duplicate the file’s definition every time it is used in a program.
Thereby increasing the programmer’s efficiency and reduce the
likelihood of errors.
ii. It also simplifies system maintenance, because changes only
have to be made in one place, instead of having to change every
program that uses the file.
iii. The advantages of externally described files also applies to
externally described printer files. Additionally, RDI’s Report
Designer can be used to design reports layout, and
automatically generate the resulting DDS code, thereby
preventing the programmer from having to figure out line
positions and line spacing.
2. Explain the differences between a logical file and a physical file.
Physical files stores data records. Logical files do not contain data
records, instead logical files stores access paths, or pointers to the
records in a physical file.
3. What is a composite key, and why is it used?
When two or more fields are defined as key fields, those fields are
referred to as composite keys, and are used to uniquely identify a
record. Composite keys allow records in a file to be accessed in key
sequence.
4. What are the advantages of logical files? Why not just create lots
of physical files to store records in different orders or to present
different combination of data fields?
Logical files provide alternative ways to look at data in a physical file.
Without having to create multiple physical files, and the need for
increased storage.
5. How does the system know whether you intend a keyword to be
file level, record level, or field level?
The system determines this by checking both the line and
positon of the keyword defined. If the keyword is in position
45-80 and it is placed at the beginning of the DDS, before any
record format specification line, then it is a file level keyword.
If the keyword is in position 45-80 and is on the same line
where the name of a record format was specified, then it is a
record level keyword.
If the keyword is in position 45-80 and is on the same line
where the name of a field is specified, then it is a field level
keyword.
CHAPTER 4
4.13. Exercise
1. Code the following standalone variables by using declarations (use
variable names, lengths, and data types appropriate to the
variable’s use):
1. Total sales, with 11 digits precision
a. Dcl-s TotalSales packed (11:0);
2. Product description, 30bytes long
a. Dcl-s ProductDescription Char(30);
3. Sales tax rate percent
a. Dcl-s SalesTaxRate Packed(2:1);
4. Transaction date
a. Dcl-s TransactionDate Date;
2. Code the following values as named constants
i. A commission rate of 2.5 percent
a. Dcl-c CommissionRate 0.025;
ii. The company name Acme Explosives Company
1. Dcl-c CompanyName ‘Acme Explosives Company’