This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Alternative for CBL_GET_PROGRAM_INFO in JVM Cobol

In our application we use the CBL_GET_PROGRAM_INFO function embedded in a copy to determine and output the name of the active program for logging purposes.
Now we want to migrate our application to JVM Cobol.

Our search for an adequate function there has so far been unsuccessful.

How can the program name be determined there?

  • 0  

    Are you using Functions 8 or 10 of this library routine?

    https://www.microfocus.com/documentation/visual-cobol/vc90/EclUNIX/HRCLRHCALL2J.html 

  • 0 in reply to   

    Here is the code snippet that we use in our legacy application. Returns no result in JVM-Cobol. The function returns with status 181.

    77 Prog-Info-Funktion pic x(4) comp-5.
    01 Prog-Info-Param-block.
    03 Prog-Info-size pic x(4) comp-5 value 20.
    03 Prog-Info-flags pic x(4) comp-5 value 1.
    03 Prog-Info-hWind pointer.
    03 Prog-Info-prog-handle pointer.
    03 Prog-Info-attributes pic x(4) comp-5.
    77 Prog-Info-name-buf pic x(100).
    77 Prog-Info-name-len pic x(4) comp-5 value 100.
    77 Prog-Info-status-code PIC X(2) COMP-5.

    CALL-GET-PROGRAM-INFO SECTION.

    move 0 to Prog-Info-Funktion
    call "CBL_GET_PROGRAM_INFO" using by value Prog-Info-funktion
    by reference Prog-Info-param-block
    by reference Prog-Info-Name-buf
    by reference Prog-Info-Name-len
    returning Prog-Info-Status-Code

    move 7 to Prog-Info-Funktion
    call "CBL_GET_PROGRAM_INFO" using by value Prog-Info-funktion
    by reference Prog-Info-param-block
    by reference Prog-Info-Name-buf
    by reference Prog-Info-Name-len
    returning Prog-Info-Status-Code.

  • Suggested Answer

    0   in reply to 

    The problem is because the size of the parameter block is not 20 bytes when compiling to JVM, as the pointers are 8 bytes. If you add this before making the call

    move length of Prog-Info-Param-block to Prog-Info-size
    it will work correctly regardless of the pointer size.
  • 0 in reply to   

    Thanks for the tip. This is how it works now.
    Some things can be so simple.