ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Problems with binding and using a service program

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problems with binding and using a service program

    I am way behind the curve in learning to use procedures, modules, binding directories and service programs, but I'm committed to doing so. Sadly, I'm stalled in the starting box, so I'm here hoping for help.

    I have a tiny RPGLE program I'm trying to use to test my first procedure module & service program--just to prove the process for myself. This program abends when it tries to invoke the procedure and I receive the following message:
    Cannot resolve to object DATEINF1. Type and Subtype X'0201' Authority X'0000'.

    This is how I set things up:
    1) created a QCPYLESRC file, DATESRV, containing the prototype and field definitions (example 1 in the attachment)

    2) created a procedure, DATEINF1, and compiled it as a module (example 2):
    CRTRPGMOD MODULE(LXUSRO/DATEINF1) SRCFILE(LXUSROS/QMODSRC) SRCMBR(DATEINF1)

    3) created a service program called DATESRV the currently has only the DATEINF1 module:
    CRTSRVPGM SRVPGM(MYLIB/DATESRV) MODULE(MYLIB/DATEINF1) SRCFILE(MYLIB/Q
    BNDSRC) SRCMBR(*SRVPGM) BNDSRVPGM(*NONE) BNDDIR(MYLIB/TBNDDIR) ACTGRP(DAT
    ESRV)

    4) added service program DATESRV to our binding directory, TBNDDIR and created binding language (example 4)

    5) created the tiny test RPGLE program (example 3) :
    CRTPGM PGM(MYLIB/TESTPROC) BNDSRVPGM((MYLIB/DATESRV *DEFER)) BNDDIR(MYLIB/TBNDDIR) DETAIL(*FULL)

    Can anyone offer any help or insight into what I am doing wrong or missing in this process?
    Attached Files

  • #2
    The first thing you have to do is copy the prototype into both the source for the callers and the source with the procedure. If you only have the /copy in the caller source, the compiler won't be able to tell you that the prototype doesn't match the procedure. As a rule of thumb, if a procedure doesn't have the EXPORT keyword, it doesn't need a prototype. Otherwise, for a program or exported procedure, there should be a prototype in a copy file, AND the copy file must be copied into the source with the program or procedure, and into the source for all the callers.

    If you go ahead and the /COPY line to your nomain module, then when you compile the module, the compiler will tell you that a procedure cannot be defined when the prototype specifies EXTPGM.

    By putting EXTPGM on your prototype, you are telling the compiler that the call is to a program. But the prototype should be for a procedure, so you need the EXTPROC keyword for prototypes, although you can also just leave out both the EXTPGM and EXTPROC keywords, since a prototype defaults to being for a procedure.


    Comment


    • #3
      Yes! Barbara Morris, thank you! Those two changes fixed my problem. My little test program ran through like a breeze and the procedure returned the correct number of scheduled work days left in the month. I'm really quite excited now to move forward after being bogged down for several day, trying to figure out what I'd done wrong. I so appreciate your help.

      Comment


      • #4
        LucyB, here is an article that, among other things, discusses the concepts you're working with: https://db.tt/h5eXDPjC

        It will help you understand modules, procedures, service programs, binding directories, binder source, etc. Hope it helps you with your future development.

        Comment


        • #5
          Viking, thank you for sharing the link to your article. I am looking forward to reading and "digesting" the information in it.

          Comment

          Working...
          X