0% found this document useful (0 votes)
306 views

RPG Programming Notes

The document provides information about RPG (Report Program Generator) including its original purpose, trends that influenced enhancements in RPG III, criticisms that led to changes in RPG IV, and differences between source code and object code. Key points include: - Originally, RPG was used to generate business reports but later supported interactive applications, database usage, and structured programming. - RPG IV addressed criticisms of its rigid format and limited data types by allowing free formatting and extending data naming limits. - Source code is what programmers write while object code is the compiled source code. Maintaining and revising programs over time does not inherently mean poor initial design.

Uploaded by

Junior
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
306 views

RPG Programming Notes

The document provides information about RPG (Report Program Generator) including its original purpose, trends that influenced enhancements in RPG III, criticisms that led to changes in RPG IV, and differences between source code and object code. Key points include: - Originally, RPG was used to generate business reports but later supported interactive applications, database usage, and structured programming. - RPG IV addressed criticisms of its rigid format and limited data types by allowing free formatting and extending data naming limits. - Source code is what programmers write while object code is the compiled source code. Maintaining and revising programs over time does not inherently mean poor initial design.

Uploaded by

Junior
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 24

CHAPTER 1

1.What was the original purpose of RPG?


The purpose of RPG was to allow programmer to generate reports that were
needed within the business.

2. What is an indicator?
An indicator is a built-in variable that can have only one of two values: '1' or
'0'.

3. What trends emerged in the 1970s to influence the enhancements


included in RPG III?
The three main trends emerged in the 1970s that influenced the
enhancements included in RPG 111 were as follows:

1) customers interest began to move from traditional batch processing, in


which the computer process a batch of data without user intervention, to
interactive application processing, that allows a user to directly interact and
control the actions of the program via terminals or workstations as it is
running.

2) interest in a database approach to data management, emerged. this


allowed programmers to define data structure independently of the program
as opposed to having to explicitly define the data structure repeatedly within
the program.

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.

4. What criticisms influenced IBM’s enhancements to RPG in RPG IV?


What computer industry developments have contributed to the
evolution of RPG IV?

Criticisms that influenced the enhancements to RPG in RPG IV were as


follows:
1) critics accused RPG of being too difficult to understand due to it's short
data names, abbreviated operation codes, and rigidly fixed format.
2) critics also contended that RPG was showing its age in its limited choice
of data types (e.g. no direct support for date data types), its inability to
handle multidimensional arrays, and its patchwork approach to data
definition.

The computer industry developments that contributed to the evolution of


RPG IV were as follows:

1) code re-usability and system performance.

IBM responded by introducing the Integrated Language Environment (ILE).


this module allowed programmers to develop programs using modules
written in different computer languages and then bind these modules into a
single executable program.

2) No fixed-format requirements or data naming limits.

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

IBM introduced several new organizational constructs, including a central


data definition specification and procedure prototyping, which lets many
program modules efficiently share information with each other.

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.

5. Do you think that a programming language that requires revisions


over time is poorly designed in the first place? Why or why not?

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

6. Give an example of a syntax error and a logic error in your native


language (e.g., English).

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.

7. Would it make sense to describe a person’s complete address (street


address, city, state, and zip code) as one field? Why or why not?

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.

8. Would you define each letter in a person’s last name as a separate


field? Why or why not?

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?

10. Differentiate between source code and object code.

Source codes are the actual statements a programmer writes to execute a


specific task. The set of statements for one program module constitutes a
source member (aka compile unit), Object code is referred to the compiled
sourced code.

11. How many times do you need to compile a program?

Once, a program only needs to be compiled once, however, if changes were


subsequently made to the program, then the program will have to be
recompiled so as to reflect the changes.

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?

No, i won't build my house without a plan or blue-print and yes it is


analogous to writing a program without first designing it. Creating a
program design allows a programmer to work out the process and algorithm
that will be required to achieved the solution. This also helps to illustrate the
program's logic and much time should be spent at this stage.

13. Explain why the Integrated Language Environment is important to


RPG programmers.
The ILE is very important because it allows programmers to develop a
program using modules written in different computer languages and then
bind those modules into a single program.
14. Why is it important to use external documentation such as
flowcharts in developing your programs?

Because it help clarify and illustrate the program's logic.

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.

17. Explain the difference between length notation and positional


notation. Why is one preferred over the other?

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.

19. Describe the differences between CRTPGM and CRTBNDPRG .


Can you use these two commands interchangeably?

The CRTPGM command binds a module object to create an executable


program, the CRTBNDPRG command allows a programmer to perform a
compile, and bind operation in one step.

20. Why is program maintenance part of the program development


cycle? What portion of a programmer’s time is consumed performing
this function?

Because of changing needs of customers and users, the design of a program


may have to change accordingly over time. This therefore becomes part of
the programs development life cycle. A programmer spends most of his time
at the maintenance stage of a program.

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

An ILE RPG program has 4 sections as follows:


a. Control options section – this section provides default options
for the program, such as default date formats, special
instructions to the compiler, changes to normal processing
modes, etc
b. Declaration section –this section identifies and defines the
files, variables, and other data items a program is to use.
c. Main procedure section –this section details the processes,
calculations, and procedures the program is to perform.
d. Sub procedure section –this section includes declarations and
processes for optional distinct functions (sub procedures) of the
RPG program that either the main procedure section or other
sub procedures can execute once or many times.

3. Explain the use of the DCL-opt instruction.


The DCL-opt instructions were introduced to replace RPG’s fixed
format F-specs and D-specs. F-specs and D-specs were used to
declare a file and data item respectively using the fixed format. Using
the free format, however, DCL-F and DCL-S are used instead.
4. Which of the following are invalid RPG IV variable names? Why
a. X
b. @end
c. _YTD_SALES – a variable’s name can include an underscore
character, but it can’t begin it.
d. YR END – a variable’s name can’t include spaces
e. InvoiceNumber – a variable’s name can’t exceed 10 characters
f. 1STQTR –a variable’s name can’t begin with a number.
g. QTY-OH –a variable’s name can’t include dashes.
h. SALES
i. CUST#
j. YR_END
k. Avg.sales –a variable’s name can’t include a period
l. #3
m. CustNo
n. $AMT
o. Day1
p. Yearend
q. CusTnbR
5. What is an indicator? What specific methods of turning on
indicators were introduced in this chapter? How can you use
indicators to control processing? What alternative ILE RPG
feature can you use to reduce or eliminate indicators in a
program?
An indicator is a single byte variable that can only hold a value of 1 or
0. A method used in this chapter to turn on an indicator was *Inlr
=*On. *Inlr is referred to as LR or Last Record. Indicators can be
used to signal an end-of-page occurrence, an alternative to indicators
are figurative constants such as *On and *Off these constants signal a
true or false condition.
6. How can you obtain 5 blank lines between detail lines of a report?

7. RPG automatically initializes all the fields used in a program


when it starts. Why would the language need the initialize
keyword?

The initial keyword written as Inz, is used to supply an initial value


for a variable, instead of its default value, that is based in its datatype.

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:

 Usage option: This option specifies how the program is to use


the file. The two types are *input and *output, specifying a
file’s usage option as *input, signifies that the file contains
data to be read by the program. *output signifies that the file is
the destination for writing output results from the program.
 Device option: This option specifies the device associated with
the file. Input files or database files are associated with disk
storage while output files are associated with a printer.

12.What is LR? Why is it used


LR stands for Last Record, it is a reserved indicator variable which is
coded as *Inlr. It is used to signal the computer to close the files and
free the memory associated with the program, by setting it to on
(coded as *Inlr = *on;). If LR is not on, the program continues to tie
up some of the system’s resources even though the program is no
longer running.
13.What is maintenance programming? What programming
techniques can you adopt to facilitate maintenance programming?
 Maintenance programming is the act of modifying an existing
program to fix problems, address changing business needs or
satisfying user requests for modifications.
 The following techniques can be adopted to facilitate
maintenance programming:
 Creating a Program Overview documentation:-
This documentation, which is coded as a block of
comments, states the function or purpose of the
program, all special instructions or peculiarities of
the program that those working with it should
know, the program’s author, and the date the
program was written. If the program is revised or
amended, the author and the date of the revision
should be stated. An indicator dictionary must also
be included if multiple indicators were used in the
program.
 Inserting Comments: - Comments should be
included throughout the program to help explain
specific processing steps that are not obvious.
 Inserting Blank Lines: - Blank lines should be used
to break the code into logical units so that the
structure of the program may be easier to
understand.
14. Why does ILE RPG include both edit codes and edit words?
What exceptions are there to the rule that an edit code and an edit
word or constant should never appear together on the same
Output specification line?
Edit codes are used to format printed numeric field’s values, such as
formatting a numeric value to be printed with commas, dollar sign,
etc. Edit word was included to provide field format editing that can’t
be solved by the use of edit codes, such as telephone numbers.
15.What are the programming implications of the fact that ILE RPG
is not case sensitive?
This allows field names and variables names to include lower and
upper case letters which aid in the program’s readability.
16.Describe internal and external documentation. Why is so much
importance placed on correctly documenting a program?
Documentations such as system and program flow charts, user
manuals, and operator instructions are known as external
documentation. Internal documentation refers to comments included
within the code itself.
17.Research and list the advantages and disadvantages of using
Control specifications.

18. Research and list the data types that are supported in RPG.

Character Format

Numeric Data Type

Graphic Format

UCS-2 Format

Date Data Type

Time Data Type

Timestamp Data Type

Object Data Type

Basing Pointer Data Type

Procedure Pointer Data Type

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.

6. Why might you use UNIQUE as a keyword in the DDS for a


physical file? Would you use the UNIQUE constraint for the same
reason in an SQL defined table?
The UNIQUE keyword guarantees that every row in a table has a
unique value. This keyword is analogous to the “primary key”
keyword, the main difference, however, is the that the primary key of
SQL combines the NOT NULL and the UNIQUE constraints.
Therefore, a primary key does not allow NULLS but the UNIQUE
keyword does. So, no the unique keyword would not be used in an sql
table definition.
7. What area the naming rules when you create tables with SQL?
Table names must begin with one of the following: any letter of the
alphabet, $,#, or @. In addition to those characters, the remaining
characters can be numbers or an underscore ( _ ). A table name cannot
included blanks. Table names must be 10 characters in length, for
longer names, use the rename keyword.
8. List the commonly used constraints and their meaning.
 Not null : this constraint prevents from containing null
values
 Default: this constraint indicates that the column is to
contain a default value.
 Unique: this constraint guarantees that every row has a
unique value.
 Primary key: this constraint ensures that a column (or a
combination of two or more columns) contains a unique
value that identifies a specific row in the table.

9. Provide three practical examples of using logical files.


1. A logical file can be used to show a subset of data stored
in a physical file. Example, a logical file can be created
to show only the first name, last name, and department
number of employees listed in a physical file that has all
the personal of every employee.
2. LF can be used to change the view employee’s data in a
physical file by sorting all employees by last name.
3. LF can be used to display only active employees from a
physical file that contains both active and inactive
employees.
10.Explain the difference among keywords COMP,RANGE, and
VALUES.
 The COMP keyword allows you to filter a field based on a
single value. E.g. COMP(EQ ‘M’).
 The VALUES keyword allows you to filter the values in a field
based on multiple values.
 The RANGE keyword allows you to filter the values in a field
based on a range of values.
11.If select and omit specifications were not available in logical file
definitions, how could you produce a report that included only the
employees of the ACT and MIS departments and excluded other
employees?
An SQL statement with a WHERE clause can be used to filter the
employees table. Example: select * from employees where DEPT in
(‘ACT’,’MIS’)
12.What is join logical file? Why is it used?
A join logical file is a logical file that is based on multiple physical
files. These physical files are joined by a common field. It is used to
merge data from multiple physical files so that it can be viewed as one
data set or table.
13.Explain the difference between arrival sequence and key sequence
of sequential record retrieval.
Arrival sequence refers to the order in which data was stored in a
physical file. Arrival sequence causes records to be retrieved on a first
in, first out basis. However, when a field in a physical file is
designated as a key field, it allows records to be retrieved in key
sequence (any order) rather than arrival sequence.
14.Assume you want to write a program that uses an externally
described logical file that is based on a physical file. What order
would you use to create the three objects required to execute the
program? Why?

15.Some programmers argue that standards in file and field naming


and the use of features such as field reference files reduce their
opportunities to be creative and should not be enforced. How
would respond to these people?

Adherence to these standards and use of file reference features do not


limit creativity. But rather, it promotes good programming practice by
requiring the use of descriptive field names which aids in the
prevention of accidental use of wrong field names in code. Such
practices also helps clarify program’s processing to others who may
have to modify the program in the future.

16.Explain the difference between *SYS and *SQL naming


conventions
*SYS naming uses the library list
*SQL naming uses the user profile name.
17.Explain the difference between SKIPA, SKIPB, SPACEA, and
SPACEB.
SKIPA: allows you to set the number of spaces to skip after a
specified line was printed.
SKIPB: allows you to set the number of spaces to skip before a
specified line was printed before
SPACEA: allows you to set vertical spacing after a specified line was
printed.
SPACEB: allows you to set vertical spacing before a specified line
was printed before.
18.Explain the difference between an SQL index and SQL view.
An SQL is a database object used to improve the performance of sql
statements. It does not contain data.
SQL views, also does not contain data, but it provides an alternative
view of the data in physical file.
19.What is the purpose of the PFILE keyword in a logical file?
The PFILE keyword is used to specify the physical file on which the
logical file is based on.
20.What are the advantages of using field reference files? Are there
any disadvantages?
 It allows you to copy field definitions from one file to another.
 It eliminates the need to duplicate fields definitions in every
externally described file that has the same fields as another one.
 It enforces uniformity and consistency throughout an
application system that facilitates program development and
maintenance.
 The disadvantage, however, is that you have to determine you
data needs before file creation or application development.

21.Describe the difference between a skip entry and a space entry on


the output specifications.
 Space entries specify vertical printer positioning relative to the
current line, it is analogous to pressing the enter key on a pc
keyboard.

 Skip entries instruct the printer to skip to the designated line on


a page. It allows you to specify an absolute vertical position on
the page. E.g. skip 6 before printing causes the printer to
advance to the sixth line on a page before printing.

CHAPTER 4

1. What is the main purpose of the Declarations section of an RPG


program?
i. Its main purpose is to inform the compile of the files, variables,
and data items be used in the program.

2. List the types of declare instructions discussed in this chapter and


their uses.
i. Dcl-f: the Dcl-f instruction, describes each file the program
uses and how they are to be used.

ii. Dcl-c: the Dcl-c instruction declares a named constant that


contains a literal that will be used by the program, however, this
value can’t be changed during program execution.

iii. Dcl-s: This declaration defines a standalone variable aka work


field, that is not part of a database or any other kind of data
structure. Its value can be changed during the program’s
execution. It can be used to store temporary values it has many
other use cases.

iv. Dcl-ds: This declaration defines a data structure, which is a


means of organizing multiple variables within a single section
of contiguous memory.
3. What is a named constant?
i. A named constant is a data time that contains a fixed value, that
doesn’t change throughout a programs execution.
4. What are the advantages of using named constants in a program?
i. It allows you to define constants in one place in program, rather
than coding them as literals throughout your calculations.
ii. It makes it easier and less error prone to change a fixed value in
one place instead of having to make the same changes in
multiple places in you program.
5. Compare and contrast literals, named constants, and figurative
constants.
i. A literal is a means of noting a fixed value, if you define a
name for that literal, that name is referred to as a named
constant. Figurative constants are a set of reserved words.
These words, however, are implied literals that can be used
without a specified length.
6. What is the main difference between a constant and a variable?
i. The value of constant can’t be changed during the program’s
execution, but the value of a variable can be changed

7. When is it important to assign an initial value to a data item?


i. it is important to assign an initial value before calculations or
other operations are performed.

8. Which data types are appropriate for storing money-related data?


Why?
i. Packed data type aka decimal data type is more appropriate for
storing money-related data because it has the highest range and
precision.

9. When would you use an indicator data type?


i. An indicator is a single-byte character field that can have only
two possible values namely *ON (‘1’) or *OFF (‘0’). They can
be used as flags to signal true/false state.

10.What kinds of capabilities can you gain by using data structures?


i. Data structures provides flexibility in handling data by letting
you group variables into a logical structure, subdivide variables
into subfields, and redefine variables with different data types
or names.
11.What is a figurative constant? What are possible uses for
figurative constant? How does the figurative constant *ALL
work?
i. Figurative constant are implied literals that can be used without
a specified length. They can be used to fill a variable with a
desired value. The figurative constant *ALL allows you to
repeat a string cyclically through the entire length of the result
variable. E.g. assigning *ALL’Z’ to a character variable, fills
the variable with Zs.
12.List five uses for subfields in data structures.
i. They can be used to store different data types, they can be
initialized, they can be used to overlap each other.
13.What are the advantages of using externally described data
structure?
i. It allows you to use the data structure in several different
programs.
ii. It allows you to mimic the layout of an existing file’s record
format.
14.Why would you need to use the RENAME keyword when
declaring an SQL file by using the Dcl-f instruction?
i. When both the file and the record format has the same name.

15. Why would a programmer need to use the PREFIX keyword in


the Dcl-f instruction?
i. The PREFIX keyword is used to rename individual fields of an
externally described file.
16.Explain the difference between the EXTDESC and the EXTFILE
keywords of the Dcl-f instruction.
i. The EXTDESC keyword names a file that the compiler is to use
to retrieve the record layouts for the file named in the Dcl-f
instruction. This action occurs only when the program is
compiled, not when it is executed. The EXTFILE keyword is
similar to EXTDESC the only difference is, the actions of
EXTFILE occurs at run time, when the program executed.
17.Data structures are considered character variable by default.
When the program starts, what do all the fields contain?
i. All the fields will contain blanks.
18.Why would a programmer want to use the OVERLAY keyword
when defining a data structure? Code an example of using the
overlay keyword.
i. A programmer would want to use the OVERLAY keyword if
he wants to refer to parts of the data in a previously defined
subfield without having to create new subfields. E.g:
Dcl-ds *N;
Firstname char(15);
Initial Char(1) Overlay(Firstname)
The value of Initial is the first letter of Firstname and it also
occupy the same exact space as Firstname
19.Why would a programmer use an externally described data
structure?
i. So that he can be able to use that data structure in several
different programs.
ii. So that he won’t have to redefine a previously defined data
structure.
20. Define and describe the use of the LIKE, LIKEDS, and
LIKEREC keywords.
i. The LIKE keyword allows you to define a standalone variable
or data structure subfield that adopts the length and data type of
another data item.
ii. The LIKEDS keyword defines one data structure (or a data
structure subfield) to be like another data structure, with the
same subfields.
iii. The LIKEREC (like record format) keyword defines a data
structure (or a subfield) to be like a record defined in a Dcl-f
file declaration instruction.

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’

iii. The FICA cutoff income $76,400


1. Dcl-c FicaCutOoff 76400;
2. An edit word for editing Social Security numbers
a. Dcl-c SSN EDTWRD(‘ - - ‘);
3. The date January 1, 2000
a. Dcl-c Jan1-2000 D’2000-01-01’

3. Code a data structure for organizing information to be printed on


a label. The subfields should include name. Social Security
number, two address lines, city/state/province, postal code, and
country. Variable names and lengths should be appropriate to he
variables’s use.
i. Dcl-ds empdata;
Name CHAR(35);
SSN PACKED(9);
Phone PACKED(10);
City CHAR(35);
State CHAR(35);
Province CHAR(35);
Postcode CHAR (10);
Country CHAR(35);
END-DS;
4. With the data structure you created in exercise 3, redefine the
social security number phone number by using the overlay
keyword.
i. Dcl-ds empdata;
Name CHAR(35);
SSN PACKED(9);
Phone PACKED(10);
City CHAR(35);
State CHAR(35);
Province CHAR(35);
Postcode CHAR (10);
Country CHAR(35);
CharSSN ZONED(9) OVERLAY (SSN);
Char_PHONE ZONED(10) OVERLAY (Phone);
END-DS;
5. Code two qualified data structures (Student and employee). Give
each of these data structure the same named fields: ID, Firstname,
Lastname, StreetAddress, City, State, PhoneNumber, and Social
security number. Redefine the Social Security number and phone
number by using the Overlay keyword
i. Dcl-ds Student QUALIFIED;
ID PACKED(10);
FirstName CHAR(35);
LastName CHAR(35);
StreetAddress CHAR(25);
City CHAR(35);
State CHAR(35);
PhoneNumber PACKED(10);
SSN PACKED (9);
SSN_CHR CHAR(9) OVERLAY (SSN);
PhoneNum ZONED(10) OVERLAY (PhoneNumber);
END-DS;
ii. Dcl-ds Employee QUALIFIED;
ID PACKED(10);
FirstName CHAR(35);
LastName CHAR(35);
StreetAddress CHAR(25);
City CHAR(35);
State CHAR(35);
PhoneNumber PACKED(10);
SSN PACKED (9);
SSN_CHR CHAR(9) OVERLAY (SSN);
PhoneNum ZONED(10) OVERLAY (PhoneNumber);
END-DS;
6. How would you reference the area code in the Student data structure
from exercise 5? How would you reference the employee area code?
i. Dcl-ds Student QUALIFIED;
ID PACKED(10);
FirstName CHAR(35);
LastName CHAR(35);
StreetAddress CHAR(25);
City CHAR(35);
State CHAR(35);
PhoneNumber PACKED(10);
SSN PACKED (9);
AreaCode PACKED(3) OVERLAY (PhoneNumber);
END-DS;
ii. Dcl-ds Employee QUALIFIED;
ID PACKED(10);
FirstName CHAR(35);
LastName CHAR(35);
StreetAddress CHAR(25);
City CHAR(35);
State CHAR(35);
PhoneNumber PACKED(10);
SSN PACKED (9);
AreaCode PACKED(3) OVERLAY (PhoneNumber);

You might also like