Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE
Dhugh2002 Absent Member.
Absent Member.
377 views

CALL "System" command in mf cobol

Jump to solution

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.

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: CALL "System" command in mf cobol

Jump to solution

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.

0 Likes
2 Replies
Micro Focus Expert
Micro Focus Expert

RE: CALL "System" command in mf cobol

Jump to solution

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.
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: CALL "System" command in mf cobol

Jump to solution

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.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.