Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Any brave souls?

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

  • Any brave souls?

    I don't know if there's a way to solve the problem directly in COBOL, but you could easily write a C or RPG function for your COBOL programs to call, that would return the value of _EXCP_MSGID.

  • #2
    Any brave souls?

    Thanks Barbara, I would love to write the entire thing in RPG, but my requirement is to do everything in COBOL. I'll just use the ol' QCMDEXC instead. My conclusion has been that there's no way to do this in ILE COBOL (so much for the ILE part of it). I always been a believer (and probably not the only one) that has said at one time "anything that can be done in RPG can be done in COBOL just as well or even better", I was just hoping that another gifted COBOL/RPG programmer would prove this one wrong.

    Comment


    • #3
      Any brave souls?

      Seems like a daft requirement. Not even any CL? Anyway, the bit of C or RPG would be tiny. The whole point of ILE is not to be able to access the runtime routines (such as system()) of any language from one particular language, it's being able to easily integrate modules written in different languages. (But actually, I think system() is way overrated anyway, and that QCMDEXC is better in the long run. If you've ever looked in the joblog to see WHAT library it couldn't find or WHAT object wasn't found, you should be able to see why _EXCP_MSGID just isn't enough information.) To get a similar function to system(), write a function in COBOL that calls QCMDEXC, and then call THAT new COBOL function where you wanted to use system(). Except for override commands, but I don't think there's a way to make an override command fail except by getting the command syntax wrong, so system() would be find for overrides.)

      Comment


      • #4
        Any brave souls?

        I absolutely agree with you. The problem is that this a contract that I'm doing and when I leave there are no other programmers left with knowledge of RPG to maintain the application(they all are mainframers freshly and painfully trained in COBOL/400); hence my 100% COBOL requirement!(sigh). As it is, I had a hard time justifying the use of APIs.(believe it or not). I was trying to use the system() function because is provides better 'error handling' than QCMDEXC. But I found out it would have been even worst to be able to use the system() function because then I would had to explain why the QC2LE binding directory is need in order to compile the program.(go figure...) So I have to keep it as simple or as foolproof as possible.

        Comment


        • #5
          Any brave souls?

          You can use QCAPCMD instead of QCMDEXC. It will return errors in the standard API error code parameter.

          Comment


          • #6
            Any brave souls?

            I've posted this message in other COBOL forums but had no takers. Anyone wants to take shot at it? Maybe it has no answer or is just not possible. Subject: Variable _EXCP_MSGID This is the problem; COBOL ILE has full access to all C language functions which can come in handy in providing additional functionality. The C language system() function can be used instead of QCMDEXC to execute a command and is better because the command length does not has to be specified. It returns zero if the command is successful and a 1 if the command fails. The problem is that if the command fails, there's no way to determine why it failed and have the COBOL program 'monitor' for a specific error. Now this function will set a global variable named _EXCP_MSGID which will contain the specific CPF message for the failed command. In RPG IV this is no problem, because this global variable can be defined as: D CPFMSGID S 7A Import('_EXCP_MSGID') And therefore accessible to the RPG program. In an ILE COBOL program this global variable could be declared with the GLOBAL clause, but the name is not a valid COBOL variable name. Hence the problem. Does anybody knows how to access this global variable in ILE COBOL. I've check all the manuals and cannot find a solution. The only workaround I can think of is monitoring the program message queue for errors but that would be an overkill solution compared to just using the QCMDEXC program. This a very "simple" problem which if it had a simple solution could unlock the wealth of C functions available to COBOL but with global variables that are not always accessible as with RPGIV.

            Comment


            • #7
              Any brave souls?

              I posted a purely COBOL and API solution on that "other COBOL forum" you mentioned.

              Comment

              Working...
              X