× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




Dave,

You want to look at an intense binding directory?
WRKBNDDIRE BNDDIR(QC2LE)
This is the key to numerous cool functions like system(), etc.  And some
ones I don't often see in RPG like arctangent.  I did some brief scanning
for the documentation on QC2LE but can't really find it.  If you want you
can do the following for every service program in the binding directory:
DSPSRVPGM SRVPGM(...) DETAIL(*PROCEXP *DTAEXP)


You can do the following to specify multiple binding directories:
     H Bnddir('ROUTINES/SRVPGM':'QC2LE')

In fact my typical H spec in my programs has the following:
      /DEFINE HSpec
      /INCLUDE ROUTINES/QRPGLESRC,HSPEC
      /UNDEFINE HSpec

and ROUTINES/QRPGLESRC,HSPEC has
      /DEFINE HSpec
      /COPY ROUTINES/QRPGLESRC,HSPEC2
      /COPY ROUTINES/QRPGLESRC,HSPEC1
      /UNDEFINE HSpec

and ROUTINES/QRPGLESRC,HSPEC1 has
      /DEFINE HSpec
     H Bnddir('ROUTINES/SRVPGM':'QC2LE')
     H ActGrp(*CALLER)
     H DftActGrp(*NO)
      /UNDEFINE HSpec

and ROUTINES/QRPGLESRC,HSPEC2 has
     H Datfmt(*USA)
     H Copyright('(C) Copyright Group Dekko Services, LLC')
     H ExprOpts(*RESDECPOS)
     H* EXTBININT will change (B)inary to (I)nteger.
     H EXTBININT(*YES)

Why did I break apart HSPEC1 and HSPEC2?  Because in my service programs I
do not use HSPEC.  I only use HSPEC2.

Hey, who was it that asked about the eval statement crashing about the
variable size recently?  Would ExprOpts(*RESDECPOS) have been applicable to
them?

Rob Berendt
--
Group Dekko Services, LLC
Dept 01.073
PO Box 2000
Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com


|-----------------------------+-------------------------------------------|
|   daparnin@xxxxxxxxxxxxxxxxx|                                           |
|   m                         |                                           |
|   Sent by:                  |                                         To|
|   rpg400-l-bounces@midrange.| rpg400-l@xxxxxxxxxxxx                     |
|   com                       |                                         cc|
|                             |                                           |
|   07/22/2004 04:00 PM       |                                    Subject|
|                             | Re: Service Programs 101                  |
|         Please respond to   |                                           |
|      RPG programming on the |                                           |
|          AS400 / iSeries    |                                           |
|      <rpg400-l@xxxxxxxxxxxx>|                                           |
|                             |                                           |
|                             |                                           |
|-----------------------------+-------------------------------------------|










Rob, Buck, Joel, & Scott,

Wow.  Thanks for the education and encouragement.  The good news is that I
created a binding directory, did a ADDBNDDIRE to it for the service
program, added an BNDDIR ('BNDNISCO') H-spec to my RPG, and it compiled!!!
I'm almost afraid to say that it made sense.  This might be a low-wattage
lightbulb moment.  Right now I'm at only about 15 watts but I'll try to get
to 60.  I agree that this would be a good topic for a FAQ (and I did look
for an explanation in the FAQ's before I posted).

Buck suggested creating a single binding directory for all of the
developers here to use (that would be me).  Since the system allows you to
create multiple binding directories will it cause problems to have more
than one or is it that there's no real need to have more than one?  It
looks to me like it's an index that tells where to find service programs.
If that's the case then it wouldn't hurt to have multiple binding
directories that could possibly have the same service program listed in
them, it would just be confusing and you might have to search a bit to find
the correct one.  (And trust me--I have enough confusion in my life
already.)

I started to look at your tutorials Joel.  It looks like there's good stuff
there.  I will definitely read them as you suggested.  I've been reading
Scott's IFS and Sockets tutorials and have learned a lot with them.  In the
past year I've made the jump to RPG IV, and /Free, so I might as well keep
on going with modules and service programs.  I'm learning the stuff now
partially because I'm working on projects that involve sockets and the IFS
although those could have been accomplished without service programs.  I've
learned RPG IV, /Free, and now service programs because they have been used
in IBM manuals, posted examples, and tutorials.  If they hadn't been there
where I could start examining them I probably wouldn't have bothered.  But
that's a topic outside of this list...

Thanks!

Dave Parnin
Nishikawa Standard Company
Topeka, IN  46571
daparnin@xxxxxxxxxxxxxxxxxx





Buck Calabro
<buck.calabro@comm        To:       rpg400-l@xxxxxxxxxxxx@SMTP@CTB
soft.net>                 cc:       (bcc: David A Parnin/Topeka/NISCO/SPCO)
Sent by:                  Subject:  Re: Service Programs 101
rpg400-l-bounces@m
idrange.com


07/22/2004 02:35
PM
Please respond to
RPG programming on
the AS400 /
iSeries
<rpg400-l@midrange
.com>





Dave wrote:

> This should be a quick one for most of you.

On the contrary.  Often, the easiest questions to ask are the hardest
to answer.

> What exactly is a service program,

A service program is a collection of procedures intended to be used by
(mainline) programs.

> I am familiar with creating RPG modules
> and then binding them into a executable program.

That may be the same thing depending on how you then call the code in
the bound modules.  If you use eval [as in eval
myResult=someFunction(aParameter)] or callp [as in callp
someFunction(aParameter: aNotherParameter)], then changing the bound
module to a service program is a pretty easy step to take.

> The service program was successfully created in QGPL.
> I'm using a /COPY member of Scott's to define the procedure.
> I get the following error when I try to do a CRTBNDRPG
> on my program.  Do I need to create my program as a module
> and then bind it to the service program?
>
> MY ERROR MESSAGE:
> Message . . . . :   Definition not found for symbol 'READLINE'.

You're close...  Let me start at the error and work backwards.
"Definition not found' means that the binder (the BND part of
crtBNDrpg) cannot find any PI reference in your (single) module.  The
compiler part (CRTbndRPG) didn't have a problem because the /COPY
defined what the prototype looks like.  The reference to READLINE in
the mainline was understood by the compiler because it had seen a
prototype for READLINE.

Why did the binder not find the PI?  Because no where on CRTBNDRPG is
there a way to specify the location of the PI - the actual procedure
definition.  That's in the service program.  You should double check
that by doing a DSPSRVPGM and making sure the READLINE procedure is
exported.  You can tell the binder how to find the service program
(and therefore the PI) in several ways.

One way is to do a two-step compile & bind, similar to what you do
when you bind two modules together.  CRTRPGMOD on your mainline, and
then CRTPGM and instead of specifying the service program in the
MODULE parameter, you specify it in the BNDSRVPGM parameter.  This
will work for the moment, but I think that many people find it
inconvenient to do two steps to make a program.

Another way is to use an object called a binding directory.  If you go
back and look at the CRTBNDRPG command, you'll see that there's a
parameter called BNDDIR.  You specify the name of the binding
directory you're about to create on that parameter and you can compile
in one step - the familiar PDM option 14.

What's a binding directory?  Oops... guess I should detour a moment to
describe it.  A binding directory is a search path for procedures.
Like a library list or classpath or DOS PATH.  When the binder can't
find a PI (like READLINE) it looks at the first entry in the binding
directory.  Say the first entry is a service program: the binder looks
at all the exports for that service program and sees if any are
READLINE.  If so, it binds to that service program and goes on to the
next 'definition not found.'

Create a binding directory - as a beginner, may I suggest that you
create one single *BNDDIR for your whole company?  Let's call it
NISHIKAWA.  Put it in a library where every developer can use it, say
QGPL or QUSRSYS.  All you need to do now is to add a binding directory
entry, something like ADDBNDDIRE BNDDIR(NISHIKAWA) OBJ((SCOTTSRVPG
*SRVPGM))  Your needs may differ, but you probably want the service
program to be *LIBL and not qualified...  Now you have a way for the
binder to search for READLINE.

So you can now compile with option 14 and BNDDIR(NISHIKAWA), but
that's a pain, isn't it?  You can make it even easier, because the
compiler recognises the H specification keyword BNDDIR!  So you can
put H bnddir('NISHIKAWA') at the top of your program, compile with PDM
14 and never bother with prompting the command.

Give it a whirl, see how it feels and let us know if any of this
advice was worth reading.  We can try to make a FAQ entry out of it to
help others who are just starting out with this stuff.  In this
regard, your feedback is crucial, because you're just stepping on that
first stair.  Some of us are already standing on that stair and have
forgotten what was so new and different about service programs.
--buck



--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.


--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.