Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RMCobol Program Output In Windows Environment

Status
Not open for further replies.

klophockey

Programmer
May 25, 2016
41
0
0
US
I am executing a Cobol program using RMCobol in a Windows environment.
I have made a slight change to the program so that I could prove it was working properly and also allows me to ask the following question.
As the program executes it executes 'Display' statements.
I can see the displayed information in a separate display window that pops up over the Command Prompt window.
I am able to see them all because I have put an 'Accept' data-field at the end of the program which keeps that Display window up until I hit enter.
This Accept statement is only for the purpose of figuring out what is going on. It cannot be part of the Production program.


MY QUESTION:
I need the output that is being put in the Display window to be sent to a file. We would call this a Standard Output file in MFCobol, ISCobol or ACUCobol.
RMCobol in the Linux environment puts the program display statement output to a Standard Output file without any special coding to do so.

Is there a change I could make to the configuration file statements which are used at the time runcobol.exe is executed which would send the program display information to a file?

I thank you and appreciate your expertise on the subject.
 
I should add that the following code is in the configuration file that I currently use
EXTERNAL-ACCESS-METHOD NAME=RMBTRV32 CREATE-FILES=YES OPTIONS='T=RMBTRV32.log'
 
You can keep the window hidden by setting the 'Main Window Type Property' to Hidden. You can also use the Persistent property when debugging to prevent the window from disappearing at the end of the run unit, removing the need for the ACCEPT.

There are some things you can do to get Format 1 DISPLAY statements to a file, I think. Haven't done that in a l-o-n-g time. I normally use a fairly generic subprogram to log messages to a file (OPEN EXTEND) rather than use DISPLAY.

Tom Morrison
Consultant
 
Perhaps, it would be better if I was very clear on how I was executing the Cobol program from which I would like for the ‘Display’ messages within it to be written to a file in order for you to help me resolve my issue that I am encountering with RMCobol. Thank you very much for your consideration of offering your assistance.

This is what is executed:
c:\Program Files (x86)\Micro Focus\RM\RMCOBOLv12>runcobol.exe mypgm x runcobol.cfg
mypgm is the cobol program I am executing
runcobol.cfg is the configuration I am currently using
Both mypgm.cob and runcobol.cfg are located in in the same user file path as the file to which I want the output of the Cobol program (mypgm) written to. The file exists and is open to be written to.
The runcobol.cfg file currently contains the following data:
EXTERNAL-ACCESS-METHOD NAME=RMBTRV32 CREATE-FILES=YES OPTIONS='T=RMBTRV32.log'

An example of the Cobol program (stripped down for this example) to show what it doing is:
IDENTIFICATION DIVISION.
Program-Id. mypgm.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 OK-SW Pic X.
PROCEDURE DIVISION.
MAIN section.
begin.
DISPLAY 'Begin mypgm Program Testing'.
DISPLAY 'My World Is Sunny’.
DISPLAY ‘Our World Is Big’.
DISPLAY 'End mypgm Program Testing'.
DISPLAY 'Hit Enter Key To Continue'.
Accept OK-SW.
stop run.

Please note that the code to Accept the OK-SW is only in there because CURRENTLY the output goes to a pop up window and it would go away immediately after stop run. This just allows me to see the program output until I can get it to go to a file.

What I expect the file output to contain is:
Begin mypgm Program Testing
My World Is Sunny
Our World Is Big
End mypgm Program Testing
 
Not sure if it is a coincidence or not, but this question has just been raised, and answered, in the Micro Focus Community Forum for RM/COBOL.

I will also state again, for debugging:
k5tm said:
You can also use the Persistent property when debugging to prevent the window from disappearing at the end of the run unit, removing the need for the ACCEPT.

Page 42 describes a process by which you can redirect Format 1 DISPLAY statements. Not really easy, but perhaps that will help.

If you are interested, I can post a small logging program that can be called with an arbitrary PIC X(n) or string constant that will log to a sequential file.

Tom Morrison
Consultant
 
Here is a logging program. I log to an indexed file to permit logging of non-DISPLAY characters (comp-6 in particular) and to take advantage of data compression available in indexed files. An indexed file can also act as a queue, allowing another program, perhaps running at intervals (e.g. cron on Linux), to read and delete messages in chronological order.

Code:
       >>IMP MARGIN-R IS END    
       identification division.
       program-id. msg-log.
      *
      * CALL "msg-log" USING MessageArea 
      *
      * where:
      *        MessageArea is the message to be logged
      *

       environment division.
       input-output section.
       file-control.
           select optional log-file    assign log-file-pathname
               organization indexed access random
               record key logged-timestamp-key duplicates
               alternate record key logged-program-name duplicates
               file status log-file-status.
       *> log-file could be sequential with some minor changes
       *> to change comp-6 to usage display
       
       data division.
       file section.
       
       fd  log-file
           record varying 41 to 2041 depending on log-record-size.
       01  log-record.
           02  logged-timestamp        pic 9(16) comp-6.  *> YYYYMMDDhhmmsscc
           02  logged-timestamp-key    redefines logged-timestamp pic x(8).
           02  logged-program-name     pic x(30).         *> Modifying program name 
           02  logged-program-line     pic 9(6)  comp-6.  *> Line number of operation
           02  message-area            pic x(2000).       *> Record area contents 
       66  log-record-fixed  		   renames logged-timestamp 
                                              thru logged-program-line.       

       working-storage section.

       01  information-about-message.
           02  msg-line                pic 9(6) binary.
           02  msg-program-name        pic x(30).
           02  unused-intraline        pic 9(2) binary.

       01  ws-log-file-open-flag       pic x(8).
           88  ws-log-file-is-open value "FiLeOpEN" false spaces.

       01  log-file-extended-status.
           02  log-file-status         pic xx.
           02                          pic x(9).

       01  log-file-pathname           pic x(100).

       01  usage binary(2).
           02  i                       pic 9(4).
           02  j                       pic 9(4).
           02  k                       pic 9(4).
           02  my-ptr                  pic 9(4).

       01  current-arg                 pic 9(3) binary.

       01  message-length              pic 9(6) binary.
       01  output-length               pic 9(6) binary.
       01  required-output-length      pic 9(6) binary.
       01  log-record-size             pic 9(4) binary.

       01  argument-count              pic 9(3) binary.

       01  current-datestamp           pic 9(16). 
       01  redefines current-datestamp.
           02                          pic xx.   *> century
           02  current-yymmdd          pic x(6).
           02  redefines current-yymmdd.
               03  current-yymm        pic x(4).
               03                      pic x(2).
           02  current-hhmmsscc        pic x(8). 
       01  redefines current-datestamp.
           02  current-yyyymm          pic x(6).
           02                          pic x(10).

       01  ARGUMENT-DESCRIPTION.       
           02  ARGUMENT-TYPE           PIC 9(2)  BINARY(2).
               88  is-omitted          value 32.
           02  ARGUMENT-LENGTH         PIC 9(8)  BINARY(4).
           02  ARGUMENT-DIGIT-COUNT    PIC 9(2)  BINARY(2).
           02  ARGUMENT-SCALE          PIC S9(2) BINARY(2).
           02  ARGUMENT-POINTER        POINTER.
           02  ARGUMENT-PICTURE        POINTER.

       01  C-CARG-SUCCESS              PIC X.
           88  IS-C-CARG-SUCCESS       VALUE "Y".

       linkage section.
       01  MessageArea.
           02  pic x occurs 1 to 10000 
                     depending on message-length.

       procedure division.  *> parameter is referenced by arg number

       declaratives.
       log-file-error section.  
           use after error procedure on log-file.
       a.  continue.               
       end declaratives.

       the-main section.
       a.
           CALL "C$WRU" USING msg-program-name, msg-line, unused-intraline.
           accept current-datestamp from date-and-time.
           if ws-log-file-is-open
               continue
           else
               move spaces to log-file-pathname
               string "msglog-"     delimited size
                      current-yyyymm delimited size
                   into log-file-pathname
               open i-o log-file
               if log-file-status (1:1) not = "0"
                   display "log file error = " log-file-status " " log-file-pathname
                   exit program
               end-if
               set ws-log-file-is-open to true
           end-if.
          
           move spaces to log-record.

           call "C$DARG" using 1, Argument-Description
           if is-omitted exit program end-if
           set address of MessageArea to argument-pointer
           move MessageArea (1:argument-length) to message-area
           add length of log-record-fixed, argument-length giving log-record-size
           accept logged-timestamp from date-and-time.
           move msg-line            to logged-program-line.
           move msg-program-name    to logged-program-name.
           write log-record.

           *> demonstration only.  remove in production
           display message-area (1:argument-length)
           exit program.

       end program msg-log.

Code:
       >>IMP MARGIN-R IS END    
       identification division.
       Program-Id. mypgm.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       77 OK-SW Pic X.
       PROCEDURE DIVISION.
       MAIN section.
       begin.
           call "msg-log" using 'Begin mypgm Program Testing'.
           call "msg-log" using 'My World Is Sunny'.
           call "msg-log" using 'Our World Is Big'.
           call "msg-log" using 'End mypgm Program Testing'.
           call "msg-log" using 'Hit Enter Key To Continue'.
           Accept OK-SW.

Here is the output from the non-production DISPLAY statement at the end of msg-log.
[pre]RM/COBOL Runtime - Version 12.12 for 32-Bit Windows.
...
Begin mypgm Program Testing
My World Is Sunny
Our World Is Big
End mypgm Program Testing
Hit Enter Key To Continue[/pre]

Tom Morrison
Consultant
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top