OL4B1 Student Exercise
OL4B1 Student Exercise
cover
Trademarks
IBM, the IBM logo, and ibm.com are trademarks or registered trademarks of International Business
Machines Corp., registered in many jurisdictions worldwide.
The following are trademarks of International Business Machines Corporation, registered in many
jurisdictions worldwide:
DB2® FileNet® HACMP™
Integrated Language iSeries® i5/OS™
Environment®
Language Environment® OS/400® PartnerWorld®
Power Systems™ Power Systems Software™ Power®
Rational® System i® WebSphere®
Adobe is either a registered trademark or a trademark of Adobe Systems Incorporated in the United
States, and/or other countries.
Pentium is a trademark or registered trademark of Intel Corporation or its subsidiaries in the United
States and other countries.
Lenovo and ThinkPad are trademarks or registered trademarks of Lenovo in the United States,
other countries, or both.
Linux is a registered trademark of Linus Torvalds in the United States, other countries, or both.
Microsoft and Windows are trademarks of Microsoft Corporation in the United States, other
countries, or both.
Java™ and all Java-based trademarks and logos are trademarks or registered trademarks of
Oracle and/or its affiliates.
UNIX is a registered trademark of The Open Group in the United States and other countries.
VMware and the VMware "boxes" logo and design, Virtual SMP and VMotion are registered
trademarks or trademarks (the "Marks") of VMware, Inc. in the United States and/or other
jurisdictions.
Other product and service names might be trademarks of IBM or other companies.
TOC Contents
Trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v
Exercises configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Exercises description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
TMK
Trademarks
The reader should recognize that the following terms, which appear in the content of this training
document, are official trademarks of IBM or other companies:
IBM, the IBM logo, and ibm.com are trademarks or registered trademarks of International Business
Machines Corp., registered in many jurisdictions worldwide.
The following are trademarks of International Business Machines Corporation, registered in many
jurisdictions worldwide:
DB2® FileNet® HACMP™
Integrated Language iSeries® i5/OS™
Environment®
Language Environment® OS/400® PartnerWorld®
Power Systems™ Power Systems Software™ Power®
Rational® System i® WebSphere®
Adobe is either a registered trademark or a trademark of Adobe Systems Incorporated in the United
States, and/or other countries.
Pentium is a trademark or registered trademark of Intel Corporation or its subsidiaries in the United
States and other countries.
Lenovo and ThinkPad are trademarks or registered trademarks of Lenovo in the United States,
other countries, or both.
Linux is a registered trademark of Linus Torvalds in the United States, other countries, or both.
Microsoft and Windows are trademarks of Microsoft Corporation in the United States, other
countries, or both.
Java™ and all Java-based trademarks and logos are trademarks or registered trademarks of
Oracle and/or its affiliates.
UNIX is a registered trademark of The Open Group in the United States and other countries.
VMware and the VMware "boxes" logo and design, Virtual SMP and VMotion are registered
trademarks or trademarks (the "Marks") of VMware, Inc. in the United States and/or other
jurisdictions.
Other product and service names might be trademarks of IBM or other companies.
pref
Instructor exercises overview
Please test all exercises prior to the class. If you experience any setup
problems, please check the lab setup guide that is included with the
instructor material.
At the beginning of each exercise, demonstrate the solution if you think it
helps the students to understand the problem. At the end of each exercise,
lead a lab review to discuss your observations, to handle any student
questions, and to put the exercise in perspective with the unit or topic.
Note: When you assign the first exercise, show the students how to start the
Remote Systems LPEX editor of IBM Rational Developer for i. Demonstrate
how to establish a new connection to the class server and how to create a
filter for their QRPGLESRC and QDDSSRC source files. You might want to
lead the students through the process and include a brief demonstration of
the editor itself and a compilation.
You will find the exercise solutions after each exercise.
pref
Exercises configuration
Please review the lab setup guide included with the instructor materials
carefully.
pref
Exercises description
This course includes the following exercises:
• Lab exercise 1: Bind by copy
• Lab exercise 2: Bind by reference
• Lab exercise 3: Enhancing a NOMAIN service program
• Lab exercise 4: Using binding directories and binder language
Exercise instructions: This section contains what it is you are to
accomplish. There are no definitive details on how to perform the tasks. You
are given the opportunity to work through the exercise given what you
learned in the unit presentation.
Your instructor assigns you a team number, nnn. This team number is used
for your userid, OL4Bnnn, and your library, OL4Bnnn. Your library contains all
the objects you need to perform the exercises. At times, you are asked to
copy objects from OL4BXXX, which is the student master library.
When you are prompted to sign on to the i server, your userid is OL4Bnnn
and your password is OL4B. The password is set to expire, so enter a new
one that you can remember easily. Please read the exercise instructions
carefully as you proceed through the exercise.
Which editor to use: You must be using the PC-based Remote Systems
LPEX editor of IBM Rational Developer for i as your editor. The Remote
Systems LPEX editor is the recommended editor and is needed for free form
RPG. It is straightforward and easy to use.
Your instructor can help you with any questions you have regarding the use
of the Remote Systems LPEX editor.
EXempty
Exercise 1. Bind by copy
Estimated time
01:00
Introduction
In this exercise, you modify a copy of VNRDLTS and VNRSCHSPRS to use a
bound call rather than a dynamic call.
Exercise instructions
EXempty __ 10. For the program name, we use the same name as the *MODULE, VNRSCHMAIN.
__ 11. Notice that the modules to be included can be expanded using the plus sign (+). Enter a
plus sign (+) and press Enter.
__ 12. Enter VNRDLTPROC and your library for the second module. Notice that more modules could
be entered to be included in the VNRSCHMAIN program.
__ 13. Press F10 or in LPEX, look for the entry module box. In 5250 emulation, you see that the
default is *FIRST. This means that the first module in the list is the PEP for the program.
Which module is this? __________________________________
__ 14. Press Enter to create the program.
End of exercise
Exercise review/wrapup
Lead a discussion on modernization principles and the benefit of modularizing your code.
Step 1:
3. What in the code of each program makes this a dynamic call?
Dcl-pr VnrDelete ExtPgm('DLTPROGRAM');
VndNbr zoned(5 : 0);
End-pr;
4. List the changes that you have to make to each program?
VNRDLTPROC:
Dcl-pr VnrDelete ExtProc('VNRDLTPROC');
VndNbr packed(5 : 0);
End-pr;
Dcl-Proc VnrDelete export;
Dcl-pi VnrDelete;
VndNbr packed(5 : 0);
End-pi;
End-Proc;
VNRSCHMAIN:
Dcl-pr VnrDelete ExtProc('VNRDLTPROC');
VndNbr packed(5 : 0);
End-pr;
Step 3:
8. Display the module information for each module. Does either module know about the other yet?
No
Step 4:
13. Which module is *first?
VNRSCHMAINStep 6:
19. What is the program entry procedure module?
VNRSCHMAIN
20. What is the program attribute?
RPGLE
21. What is the type of program?
ILE
EXempty 22. Press Enter to go to the display that lists modules. How many modules are bound into this
program?
2
23. The service programs are listed next. Explore the remaining information. How many service
programs are bound to this program?
4
EXempty
Exercise 2. Bind by reference
Estimated time
00:45
Introduction
In the Bind by Copy exercise, module VNRDLTPROC was bound by copy into
ILE program, VNRSCHMAIN.
It is often desirable to make commonly used modules available to the
application by including them in a service program object. You now bind the
VNRDLTPROC module into a new service program object, and then bind by
reference to your new service program from the ILE procedure
VNRSCHMAIN.
Reuse the modules from the Bind by copy exercise, and bind them together
differently.
__ 9. Explore more. Make a note of any points of interest (Signature, Exports, and so on). Make a
note of any questions and review them with the instructor and the rest of the class at the end
of the exercise.
End of exercise
EXempty
Exercise 3. Enhancing a NOMAIN service program
Estimated time
01:00
Introduction
You find copies of all the code that was demonstrated in class. In addition,
you add some existing subprocedures that were written.
You place all prototypes in a single copy member, and, using conditional
compiler directives, you copy only the prototypes referenced by your
procedures to each procedure as you compile the module.
You re-create all objects and test all applications to make sure that
everything still produces correct results.
© Copyright IBM Corp. 2015 Exercise 3. Enhancing a NOMAIN service program 3-1
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
Exercise instructions
EXempty
__ 11. If you see different results, you should check for any errors you made in binding.
© Copyright IBM Corp. 2015 Exercise 3. Enhancing a NOMAIN service program 3-3
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
EXempty __ 21. Explore the objects that you have created again. Use commands DSPMOD, DSPSRVPGM, and
DSPPGM. For the service program, specifically look for procedure exports and the service
program signature. Make a note of the procedures exported:
_______________________________________________________________
_______________________________________________________________
_______________________________________________________________
End of exercise
© Copyright IBM Corp. 2015 Exercise 3. Enhancing a NOMAIN service program 3-5
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
Exercise review/wrapup
This exercise deserves a review and discussion. This may be the first time that students exercise
their understanding of some of the ILE concepts. The main feature on which we have been focusing
is the packaging of multiple subprocedures in a NOMAIN procedure.
Discuss this feature with the students and where they would use a NOMAIN procedure.
Note that in step 6, the students are asked to include the /copy prototypes in the SUBPROCSNM
member. Although this is no longer necessary as of V7, this is a good practice to include the
prototype for verification of the copybook.
Also, many of the students may be exploring the DSPMOD, DSPPG, and DSPSRVPGM commands for
the first time. Ask them to explain what they discovered about these commands, focusing their
attention on things such as exports of subprocedure symbols. Perhaps you could ask them about
signatures and what they might do if they did not want to export all subprocedures from a service
program. This discussion leads into the lecture that follows which discuss binding directories and
binder language.
EXempty
Exercise 4. Using binding directories and binder
language
Estimated time
00:45
Introduction
Using a binding directory, you can reduce the number of modules that must
be specified on the CRTPGM command to just one. You can also eliminate the
requirement to specify any service programs.
Some programmers have compared a binding directory to a library search
list. Each clearly serves a different purpose, but they can both be used to
reduce keystrokes because their contents can be searched to help fill in the
blanks.
The binder language, as you have seen, helps to manage exports from a
service program. Not only that, it also helps simplify the process of
application releases by minimizing the impact of changes on existing code.
© Copyright IBM Corp. 2015 Exercise 4. Using binding directories and binder language 4-1
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
Exercise instructions
[CA1]
OR key the following command:
ADDBNDDIRE BNDDIR(MYBNDDIR) OBJ((OL4Bnnn/*ALL *MODULE))
EXempty __ 4. Inspect your binding directory to be sure that only the intended entries exist. If you added
entries via the Work with Binding Directory Entries display, the added entries appear
automatically. If you used the ADDBNDDIRE command to add entries, use the following
command to view them:
WRKBNDDIRE BNDDIR(MYBNDDIR)
Your binding directory should now contain one entry for each module in your library
(OL4Bnnn). If you find any other entries, remove them with option 4.
© Copyright IBM Corp. 2015 Exercise 4. Using binding directories and binder language 4-3
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
EXempty Instructor note: If the students have problems with binding, they see a message during program
creation:
CRTPGM PGM(LOANBIND) MODULE(LOANPAYAPI) BNDSRVPGM(NOMAINBD)
Definition not found for symbol 'PAYMNTAPI'.
Definition not found for symbol 'RATPERAPI'.
Program LOANBIND not created.
The problem occurs because the service program does not contain the PAYMNTAPI and
RATPERAPI subprocedures. The solution is to recreate the NOMAINBD service program to
incorporate the relevant additional modules. The binder language source requires modification
to export the appropriate procedures. The program LOANBIND can then be created.
End of exercise
© Copyright IBM Corp. 2015 Exercise 4. Using binding directories and binder language 4-5
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide
Exercise review/wrapup
Lead a discussion about binder language and any problems that they encountered in the final step.
They probably experienced the errors that you can see in your guide. The students should explain
that there are other procedures that are referenced by LOANPAYAPI. If we used LOANPAY, we
would have had no problems.
backpg
Back page