ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Cannot call a subprogram from main

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

  • Cannot call a subprogram from main

    I am in the middle of trying to create a subfile to have the ability to scroll through a bunch of medical procedures on one of our green screens. This is a work in progress. for now I have the old screen with its limited number of input procedures. I will change this once I get the subfile screen to talk to the main program. Currently , I am trying to call the subprogram (JOHNEX05C) with a Call xxxxx Returning bbbbbbb. I think everything is coded where it is supposed to be, but when I execute ti I get this message: ILE COBOL program 'HAY550CCRC' cannot call program object 'JOHNEX05C'. ,+, Unmonitored exception at statement 3906 of procedure HAY550CCRC.
    I've attached compiled listing of both programs. Be nice as it's my first attempt at a subfile or scrolling. I've read the IBM manuals and think I put the data in working storage as it should be and not in linkage.
    Any help would be much appreciated. Spool files were big so I zipped them.
    Thanks,
    John
    Attached Files
    John M. Mauro
    Software Engineer
    nThrive

  • #2
    It took some searching to find what the error message was because a message ID wasn't included. It seems to be LNR7040. It doesn't seem to make sense, but I'm not quite getting the sense of the coding anyway.

    Why use CALL ... RETURNING? It should be much more straightforward to use CALL ... USING.

    I've never had a need to use the method you're trying. And I don't know if any examples even exist. I seem to recall, though, seeing a possibly related example where the "subprogram" source was in the same source member as the "main" program.

    The only clue that I saw is in the CALL statement GIVING/RETURNING phrase documentation: "The GIVING/RETURNING phrase is not allowed for programs called with a linkage type of program." And that makes sense since generally only procedures can 'return' values. You don't have a LINKAGE TYPE specified, but that should mean a program object by default. It almost seems as if there should have been one or more compile errors that don't show up.

    Sorry I can't think of much more. I'd go to IBM Support next... unless a real COBOL expert shows up.
    Tom

    There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

    Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

    Comment


    • #3
      Thanks Tom. I used "Call Returning" as I am passing nothing to the subfile program but want it to return me the values entered in the subfile which I will then transfer to the original program, pass the values to the existing variables in the original program, and allow it to perform the validity checking for the fields passed back. I coded the program according to the IBM manuals where population of the fields is in working storage and not in linkage.
      I appreciate your input.
      Again Thanks,
      John
      John M. Mauro
      Software Engineer
      nThrive

      Comment


      • #4
        I'd almost certainly use simple program linkage with the structure declared in the JOHNEX05C Linkage Section. It would physically exist in the HAY550CCRC Working-Storage, and simply be pointed to by JOHNEX05C. Only thing actually passed should be the address via the parm list. Very few changes to source, but more straightforward and easier to understand (even for RPG coders looking at COBOL).
        Tom

        There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

        Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

        Comment

        Working...
        X