Skip to main content

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?

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?

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

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


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

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

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.


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.

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.

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.

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