Skip to main content

Hello,

I've always been a IBM mainframer, we just switched over to micro focus Cobol. I need to use the call "system" command to call the dos command prompt and then I need to execute the windows  lpr print command to send a print file to specific printer. Any suggestions?. I've heard I can also use the x91 function 35.

Hello,

I've always been a IBM mainframer, we just switched over to micro focus Cobol. I need to use the call "system" command to call the dos command prompt and then I need to execute the windows  lpr print command to send a print file to specific printer. Any suggestions?. I've heard I can also use the x91 function 35.

You can execute a command line using either the call "system" or the x"91" function 35. Make sure that you null terminate the command when using system as shown below:

Example of both.

 

       identification division.
       program-id. Program1.
       data division.
       working-storage section.
       01 my-command   pic x(256)  value Z"notepad.exe c:\\temp\\myfile.txt".
       01 result       pic x comp-x.
       01 function-code pic x comp-x value 35.
       01 parameter.
          05 param-len pic x comp-x value 0.
       procedure division.
       
           call "system" using my-command

           *> or you can use the following

           display my-command upon command-line
           call x"91" using result
                 function-code
                 parameter

           goback.

Hello,

I've always been a IBM mainframer, we just switched over to micro focus Cobol. I need to use the call "system" command to call the dos command prompt and then I need to execute the windows  lpr print command to send a print file to specific printer. Any suggestions?. I've heard I can also use the x91 function 35.

I'm under the impression that the preferred method is call "SYSTEM", with "SYSTEM" in uppercase.

  • The entry point "system" (lowercase) is a function in the C standard library. It's defined to invoke an implementation-defined command interpreter, passing it a (nul-terminated) string as its command line.
  • The entry point "SYSTEM" (uppercase) is a function in the COBOL RTS. It also does some COBOL-specific stuff, I think mostly having to do with screen handling. At any rate, it's provided by the RTS specifically as a wrapper around the standard system and is recommended by the Coretech team.

The RTS SYSTEM library function also requires a nul-terminated string, though unfortunately that information seems to be missing from the product documentation.

So, for example:

data division.
working-storage section.

77 cmdline     pic x(100).

procedure division.

   move z"notepad c:\\temp\\myfile.txt" to cmdline
   call "SYSTEM" using cmdline

   stop run.

Would be preferred.

Note that (contra the title of this thread), there is no "System" entry point in mixed case - at least not in the standard C library or the COBOL RTS. Case is significant.


You can execute a command line using either the call "system" or the x"91" function 35. Make sure that you null terminate the command when using system as shown below:

Example of both.

 

       identification division.
       program-id. Program1.
       data division.
       working-storage section.
       01 my-command   pic x(256)  value Z"notepad.exe c:\\temp\\myfile.txt".
       01 result       pic x comp-x.
       01 function-code pic x comp-x value 35.
       01 parameter.
          05 param-len pic x comp-x value 0.
       procedure division.
       
           call "system" using my-command

           *> or you can use the following

           display my-command upon command-line
           call x"91" using result
                 function-code
                 parameter

           goback.

Hi Chris,  we need to call C# program from managed Cobol is that possible. if yes can you provide some sample code.