0% found this document useful (0 votes)
64 views38 pages

OL4B1 Student Exercise

Uploaded by

sergio Avalos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views38 pages

OL4B1 Student Exercise

Uploaded by

sergio Avalos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

V9.

cover

IBM Training Front cover


Instructor Exercises Guide

ILE Foundation for IBM i


Course code OL4B ERC 1.0
Instructor Exercises Guide

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.

January 2015 edition


The information contained in this document has not been submitted to any formal IBM test and is distributed on an “as is” basis without
any warranty either express or implied. The use of this information or the implementation of any of these techniques is a customer
responsibility and depends on the customer’s ability to evaluate and integrate them into the customer’s operational environment. While
each item may have been reviewed by IBM for accuracy in a specific situation, there is no guarantee that the same or similar results will
result elsewhere. Customers attempting to adapt these techniques to their own environments do so at their own risk.

© Copyright International Business Machines Corporation 2015.


This document may not be reproduced in whole or in part without the prior written permission of IBM.
US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
V9.0
Instructor Exercises Guide

TOC Contents
Trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v

Instructor exercises overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii

Exercises configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix

Exercises description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi

Exercise 1. Bind by copy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1

Exercise 2. Bind by reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1

Exercise 3. Enhancing a NOMAIN service program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1

Exercise 4. Using binding directories and binder language . . . . . . . . . . . . . . . . . . . . . . . . . 4-1

© Copyright IBM Corp. 2015 Contents iii


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide

iv ILE Foundation for IBM i © Copyright IBM Corp. 2015


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
V9.0
Instructor Exercises Guide

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.

© Copyright IBM Corp. 2015 Trademarks v


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide

vi ILE Foundation for IBM i © Copyright IBM Corp. 2015


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
V9.0
Instructor Exercises Guide

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.

© Copyright IBM Corp. 2015 Instructor exercises overview vii


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide

viii ILE Foundation for IBM i © Copyright IBM Corp. 2015


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
V9.0
Instructor Exercises Guide

pref
Exercises configuration
Please review the lab setup guide included with the instructor materials
carefully.

© Copyright IBM Corp. 2015 Exercises configuration ix


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide

x ILE Foundation for IBM i © Copyright IBM Corp. 2015


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
V9.0
Instructor Exercises Guide

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.

© Copyright IBM Corp. 2015 Exercises description xi


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide

xii ILE Foundation for IBM i © Copyright IBM Corp. 2015


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
V9.0
Instructor Exercises Guide

EXempty
Exercise 1. Bind by copy

Estimated time
01:00

What this exercise is about


This exercise provides an opportunity to use static binding. Specifically bind
by copy, wherein needed procedures are bound into an ILE program by
copying the executable code from the modules containing the procedures to
a program object.

What you should be able to do


At the end of the lab, you should be able to:
• Edit an RPG IV source member to change a dynamic call to a static call
in the prototype
• Create RPG IV modules
• Create a multi-module ILE program using bind by copy
• Reuse existing tested modules in multiple ILE programs using bind by
copy

Introduction
In this exercise, you modify a copy of VNRDLTS and VNRSCHSPRS to use a
bound call rather than a dynamic call.

© Copyright IBM Corp. 2015 Exercise 1. Bind by copy 1-1


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide

Exercise instructions

Step 1. Make copies of your existing source members


__ 1. Make copies of the VnrDlts and VnrSchSPRS source members, naming them
VNRDLTPROC and VNRSCHMAIN. Already provided is the source for the Display file:
Display file (DDS): OL4Bnnn/QDDSSRC(VNDSCHS5S)
RPG IV Programs: OL4Bnnn/QRPGLESRC(VNRSCHSPRS) copy to
OL4Bnnn/QRPGLESRC(VNRSCHMAIN) and OL4Bnnn/QRPGLESRC(VNRDLTS) copy to
OL4Bnnn/QRPGLESRC(VNRDLTPROC)
__ 2. Previously, each was compiled as an individual program. VnrSchSPRS calls VnrDlt using
a dynamic call to the DLTPROGRAM *PGM.
__ 3. What in the code of each program makes this a dynamic call?
______________________________________________
______________________________________________
__ 4. List the changes that you must make to each program:
In procedure VNRDLTPROC:
______________________________________________
______________________________________________
In procedure VNRSCHMAIN:
______________________________________________
______________________________________________

Step 2. Modify VNRDLTPROC and VNRSCHMAIN


__ 5. Using your documented changes above, modify the source members so that VNRSCHMAIN
uses a bound call to call VNRDLTPROC.

Step 3. Create modules VNRDLTPROC and VNRSCHMAIN


__ 6. Compile each source member, creating modules.
__ 7. When your program has compiled successfully, confirm that the two modules, VNRDLTPROC
and VNRSCHMAIN were created.
__ 8. Display the module information for each module. Does either module know about the other
yet? __________________________________________________

Step 4. Create VNRSCHMAIN *PGM


__ 9. Run the ILE CRTPGM command and prompt it. If you use LPEX, you should click Actions
from the editor menu and select Create Program.

1-2 ILE Foundation for IBM i © Copyright IBM Corp. 2015


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
V9.0
Instructor Exercises Guide

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.

Step 5. Test the program, VNRSCHMAIN


__ 15. As before, test that a delete option works.
__ 16. Remember to refresh your copy of the Vendor_PF file after testing, copying from the
master copy in OL4BXXX.

Step 6. Explore the *PGM, VNRSCHMAIN


__ 17. Find your new VNRSCHMAIN program.
__ 18. Use the DSPPGM command and prompt with F4. For the DETAIL parameter, specify *ALL.
Press Enter.
Notice that the phrase More appears near the lower right corner of the panel, but you are also
prompted to Press Enter to continue. To avoid missing any information, scroll your display
forward through each section until More is replaced by Bottom. Then press Enter to advance to
the next display to view other information.
__ 19. What is the program entry procedure module?
__________________________________________________________
__ 20. What is the program attribute?
___________________________________________________________
__ 21. What is the type of program?
__________________________________________________________
__ 22. Press Enter to go to the display that lists modules. How many modules are bound into this
program?
__________________________________________________________
__ 23. The service programs are listed next. Explore the remaining information. How many service
programs are bound to this program?
___________________________________________________________

End of exercise

© Copyright IBM Corp. 2015 Exercise 1. Bind by copy 1-3


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 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

1-4 ILE Foundation for IBM i © Copyright IBM Corp. 2015


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
V9.0
Instructor Exercises Guide

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

© Copyright IBM Corp. 2015 Exercise 1. Bind by copy 1-5


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide

1-6 ILE Foundation for IBM i © Copyright IBM Corp. 2015


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
V9.0
Instructor Exercises Guide

EXempty
Exercise 2. Bind by reference

Estimated time
00:45

What this exercise is about


This exercise provides an opportunity to use static binding. Specifically bind
by reference, wherein one or more procedures needed by an ILE program
are centrally contained in a service program, and bound by reference to the
ILE program during the CRTPGM binding process.

What you should be able to do


At the end of the lab, you should be able to:
• Create a service program
• Bind by reference to modules in a service program object

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.

© Copyright IBM Corp. 2015 Exercise 2. Bind by reference 2-1


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide

Instructor exercise overview


Students must complete the previous exercise before they can begin this exercise.

2-2 ILE Foundation for IBM i © Copyright IBM Corp. 2015


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
V9.0
Instructor Exercises Guide

EXempty Exercise instructions

Step 1. Create service program, MySrvPgm


__ 1. Use the CRTSRVPGM command to create a service program that contains the module
VNRDLTPROC. Specify the parameter EXPORT(*ALL):
CRTSRVPGM SRVPGM(MYSRVPGM)
MODULE(VNRDLTPROC)
EXPORT(*ALL)
Export indicates that all export capable symbols can be referenced beyond the scope of the
object.
__ 2. What type of object did you create?
__________________________________________________________
Service programs usually contain more than one module. You just created a service program
with only one module.
__ 3. What happens if you try to execute the command:
CALL MYSRVPGM
__________________________________________________________
A stand-alone service program cannot be called dynamically.

Step 2. Create and test a new program, VNRSCHREF


__ 4. Now create a new program that functions like VNRSCHMAIN in the Bind by copy exercise.
Instead of binding the VNRDLTPROC module as we did in the bind by copy, all you need to do
is bind the service programs that you just created. When you run CRTPGM, specify the
program name as VNRSCHREF and bind the VNRSCHMAIN as you did before. You need to
press F10 to see the parameter for binding of the service program.
__ 5. Test VNRSCHREF as you have before.

Step 3. Explore your service program and program object


__ 6. Run the DSPPGM command to explore the information available for the VNRSCHREF. Press
the Enter key to move from display to display.
Which module is the program entry procedure? Why?
___________________________________________________________
__ 7. Press Enter and stop when you reach the Modules display. VNRDLTPROC was not specified
in the CRTPGM command prompt. Rather, it was bound by reference to a service program.
__ 8. Press Enter and stop at the screen that displays information about service programs. Enter
a 5 beside your MYSRVPGM and press Enter until you see the module VNRDLTPROC.

© Copyright IBM Corp. 2015 Exercise 2. Bind by reference 2-3


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide

__ 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

2-4 ILE Foundation for IBM i © Copyright IBM Corp. 2015


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
V9.0
Instructor Exercises Guide

EXempty Exercise review/wrapup


Lead a discussion on modernization principles and the benefit of modularizing your code.
Step 1:
2. What type of object did you create?
*SRVPGM
Service programs usually contain more than one module. You just created a service program
with only one module
3. What happens if you try to execute the command?
Program MYSRVPGM in library *LIBL not found.
A stand-alone service program cannot be called dynamically
Step 3:
6. Which module is the program entry procedure? Why?
VNRSCHMAIN
ENTMOD(*FIRST) is the default, and there is only 1 module bound to the program.

© Copyright IBM Corp. 2015 Exercise 2. Bind by reference 2-5


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Instructor Exercises Guide

2-6 ILE Foundation for IBM i © Copyright IBM Corp. 2015


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
V9.0
Instructor Exercises Guide

EXempty
Exercise 3. Enhancing a NOMAIN service program

Estimated time
01:00

What this exercise is about


In the exercise, you continue the process that we have been showing in the
lecture unit. You add more subprocedures to the service program, re-create
all impacted objects, and test the application, which is much more modular.

What you should be able to do


At the end of the lab, you should be able to:
• Create a service program containing NOMAIN procedures
• Create modules and ILE programs that use bind by reference to handle
calls to subprocedures in a service program

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

Step 1: Explore the code that is provided


__ 1. In your QDDSSRC file, you should find:
__ a. AGEINQ DSPF Age demo and NbrDays
__ b. ITEMINQ2 DSPF Item inquiry with NbrDays
__ 2. In your QRPGLESRC file, you should find:
__ a. AGEDEMOMN RPGLE Ex 3- Age demo with subprocs in NOMAIN proc
__ b. ITEMINQ2 RPGLE Ex 3- Item inquiry with call to NbrDays
__ c. SUBPROCSNM RPGLE Ex 3- Subprocs in NOMAIN proc
__ 3. You also use other source members that you created in earlier exercises.

Step 2: Create the objects


__ 4. Compile the QDDSSRC members above.
__ 5. Create the AGEDEMOMN module (this member calls NbrDays but the subprocedure is in a
NOMAIN procedure).
__ 6. Create the SubProcsNM module.
__ 7. Create a service program that is named OL4Bnnn, where nnn is your team number. Specify
SubProcsNM for the module and *ALL for the export parameter.
__ 8. Create a program, AgeInqPGM, that contains the AgeDemoMN module and binds by
reference to your service program, OL4Bnnn.
__ 9. Explore the objects that you have created. If you are using the Programming Development
Manager (PDM), put the number 5 beside a module, program, or service program object in
order to display the details. As an alternative, you could use the DSPMOD, DSPPGM, and
DSPSRVPGM commands respectively. When you use these commands, you can scroll for
more information and press Enter to see different information. Use both. For the service
program, specifically look for procedure exports and the service program signature. Make a
note of the procedures exported:
_______________________________________________________________
_______________________________________________________________
_______________________________________________________________

Step 3: Test the application


__ 10. Call the AgeInqPGM. You should see something similar to this display:

3-2 ILE Foundation for IBM i © Copyright IBM Corp. 2015


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
V9.0
Instructor Exercises Guide

EXempty

__ 11. If you see different results, you should check for any errors you made in binding.

Step 4: Create more objects and test


__ 12. Create the module ItemInq2 that also calls NbrDays.
__ 13. Create a program, ItemInq2 from the module and bind it to your service program,
OL4Bnnn.
__ 14. Call the ItemInq2 program. You should see a display similar to this:

© 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

Valid item numbers are 20001 - 20050.


__ 15. If you have different results, check your module creation and binding parameters.

Step 5: Add more subprocedures to SubProcsNM module


We decided to place all subprocedures in the SubProcsNM module. We will then organize
NOMAIN modules by application. For now, we start with some of the subprocedures that were
written to date and put them into a single module.
__ 16. In your QRPGLESRC file, find your copies of RATPER and PAYMNT subprocedures and copy
them into the SubProcsNM NOMAIN source member.
__ 17. Remember to include prototypes for these subprocedures.
__ 18. Re-create the SubProcsNM module and then re-create your service program to contain this
new module.
__ 19. Re-create the two programs that you created in the previous step to reference this new copy
of your service program.
__ 20. Test the two programs that you have re-created. They should behave as they did before.

3-4 ILE Foundation for IBM i © Copyright IBM Corp. 2015


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
V9.0
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:
_______________________________________________________________
_______________________________________________________________
_______________________________________________________________

Step 6: Modify prototypes


At this point, you reorganized the NOMAIN subprocedure. In exercise 2, you used conditional
directives to /COPY prototypes into calling programs. You used a member that is named
PROTOTYPES.
__ 22. Modify your Prototypes source member to include the NbrDays prototype.
__ 23. Modify the procedures that call NBRDAYS, ItemInq2, and AgeDemoMN such that they copy
from the Prototypes member only the prototype definitions that are required.
__ 24. Re-create all objects in the application that are impacted by this change. These are the
AgeDemoMn and ItemINQ2 objects.
__ 25. Modify the source member SUBPROCSNM to use compiler directives and /COPY for its
PROTOTYPES. Then recreate the *MODULE and finally the *SRVPGM OL4Bnnn.

Step 7: Modify LOANPAY


__ 26. Edit your copy of LOANPAY. Modify it so that it uses conditional directives and the
PROTOTYPES source member.
__ 27. Remember that RATPER and PAYMNT are now included in the SUBPROCSNM module that is
included in your OL4Bnnn service program.
__ 28. Create your LOANPAY module and a new *PGM, LOANPAYPGM, that binds the service
program.
__ 29. Test your LOANPAYPGM to make sure that it behaves as it did earlier.

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.

3-6 ILE Foundation for IBM i © Copyright IBM Corp. 2015


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
V9.0
Instructor Exercises Guide

EXempty
Exercise 4. Using binding directories and binder
language

Estimated time
00:45

What this exercise is about


This exercise provides an opportunity to create and use a binding directory.
You create a binding directory and add entries for your modules and service
program.
Subsequently, you reference your binding directory when creating ILE
programs to simplify the number of modules that must be specified on the
CRTPGM command.
Then, you use the binder language to handle exports of data and
procedures.

What you should be able to do


At the end of the lab, you should be able to:
• Create a binding directory
• Reference a binding directory on the CRTPGM command to simplify ILE
program creation and maintenance
• Add and remove binding directory entries
• Create and use the binder language

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

Step 1: Create a binding directory


__ 1. Create a new binding directory MYBNDDIR in your library:
CRTBNDDIR BNDDIR(OL4Bnnn/Mybnddir)
__ 2. Inspect your binding directory to confirm that it contains no entries:
WRKBNDDIRE BNDDIR(OL4Bnnn/Mybnddir)

Step 2: Add entries to a binding directory


Modules and service programs need not exist before adding their names to a binding directory.
You can add individual module names and service program names to a binding directory, or you
can do a global add of either all module names or all service program names.
__ 3. Add entries for the names of all modules in your team library to your binding directory:
On the Work with Binding Directory Entries panel, type these entries on the top entry line:

[CA1]
OR key the following command:
ADDBNDDIRE BNDDIR(MYBNDDIR) OBJ((OL4Bnnn/*ALL *MODULE))

4-2 ILE Foundation for IBM i © Copyright IBM Corp. 2015


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
V9.0
Instructor Exercises Guide

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.

Step 3: Use your binding directory to create ILE programs


In the previous exercise, you created an ILE program, LOANPAYPGM. Now, you create a new
ILE program that performs the same functions as LOANPAYPGM, but you use a binding
directory to create a new ILE program, LOANBD.
__ 5. In the previous step, you added all modules in your library to your MYBNDDIR. Verify that
your binding directory contains the modules that are needed by LOANPAY, RATPER, and
PAYMNT. Remember that RATPER and PAYMNT are now included in the SUBPROCSNM
module.
__ 6. Create a new program, LOANBD, specifying the LOANPAY module and your binding
directory.
__ 7. When you try to execute the CRTPGM command, you may see a message that the program
was not created. Do not worry if you do not see:
Message . . . . : Definition supplied multiple times for symbol
'NBRDAYS'.
Cause . . . . . : Definition NBRDAYS was found to be exported from
both
*MODULE object AGEDEMO in library AS10nnn and *MODULE object SUBPROCSNM in
library AS10nnn.
Recovery . . . : Try the Create Program (CRTPGM) or Create Service
Program
(CRTSRVPGM) command again, supplying only one of these objects, or try
the
CRTPGM or CRTSRVPGM command again, specifying one or both of
OPTION(*DUPVAR)
and OPTION(*DUPPROC).
__ 8. If you see the message, you need to take appropriate action to create the program
successfully. The purpose of this part of the exercise is not only to use a binding directory,
but also to learn about additional features such as the duplicate export problem above.

Step 4: Test your program, LOANBD


__ 9. Test your program to make sure that it still runs as it did in the first exercise.

© 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

Step 5: Using the binder language for exports


You recall that you built a service program, OL4Bnnn, in a previous exercise. You modify the
service program using the binder language to export the procedure and data items needed
rather than specifying *ALL for the EXPORT parameter of CRTSRVPGM.
__ 10. First, display your OL4Bnnn service program to determine what items need to be exported.
What symbols need to be exported?
______________________________________________________________
__ 11. Create a new source member, NOMAINBD, in your source file, QSRVSRC.
__ 12. Code the binder source necessary to export the symbols you noted in the first part of this
step.

Step 6: Create objects


__ 13. Create a new service program, NOMAINBD. Make sure that you include the SUBPROCSNM
module and reference your binder language for any exports.
__ 14. Create a program, AGEBIND, that includes the main module, AGEDEMOMN and the service
program you created.

Step 7: Test your program


__ 15. Test the program AGEBIND that you just created.

Step 8: Create objects for LOANPAY program


__ 16. Create a program, LOANBIND, that includes the main module, LOANPAY and the service
program NOMAINBD that you created.
__ 17. If your program does not bind because all imports are not satisfied, check your binder
language member, NOMAINBD.
__ 18. Try to create LOANBIND using the module LOANPAYAPI (LOANPAYAPI *MODULE exists in
*LIBL, referencing service program NOMAINBD). Is it created successfully?
What happened? Why? What would you have to do to solve any problems that you
encountered? Be prepared to discuss your observations with the class.
_____________________________________________________________
_____________________________________________________________
_____________________________________________________________
_____________________________________________________________
_____________________________________________________________
_____________________________________________________________
_____________________________________________________________
_____________________________________________________________

4-4 ILE Foundation for IBM i © Copyright IBM Corp. 2015


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
V9.0
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.

4-6 ILE Foundation for IBM i © Copyright IBM Corp. 2015


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
V9.0

backpg
Back page

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy