How to get the Cobol DISPLAY to work in a JCL so that I can see the output message to use them as a debug?

StackOverflow https://stackoverflow.com/questions/22230097

  •  06-06-2023
  •  | 
  •  

Question

I am working on a Cobol program and need the DISPLAY to print messages so that I can see them when I run the program. I thought that it was SYSOUC that was used to write this type of Cobol Message but I cannot get it to display and it should be so that i can view it and just see the displays or at least that is what I thought.

Question: How do I get the DISPLAY in Cobol to display messages?

//STEP2      EXEC PGM=MyProgram,REGION=32M,COND=(0,NE)          
//STEPLIB     DD DSN=MyPrgram,DISP=SHR              
//SYSOUT      DD SYSOUT=1   --system messages                  
//SYSDBOUT    DD SYSOUT=1                                      
//SYSOUC      DD SYSOUT=3   --display                          
//SYSPRINT    DD SYSOUT=1                                      
//SYSUDUMP    DD SYSOUT=1                                      
//INPUT1      DD DSN=MyFile,DISP=SHR,BUFNO=30            
//INPUT2      DD DSN=CDP.PARMLIB(SomeParmCard),DISP=SHR            
//OUTPUT1     DD DSN=&&Temp,DISP=(,PASS),UNIT=SYSDA,            
//            DCB=aaaa.bbbb.MODEL,MGMTCLAS=TMM               
//PRTOUTA     DD SYSOUT=2,DCB=(BLKSIZE=0,LRECL=133,RECFM=FBM)  
Was it helpful?

Solution

By default, from IBM's Enterprise COBOL, your DISPLAY messages are going to //SYSOUT DD SYSOUT=whatyouneedatyoursite

You have marked that as being for system messages, but you should check there. With some utilities (SORT is a good example) that will contain the message output from the product, but that is not the case by default with COBOL.

It is possible to change where the output from DISPLAY goes by compile option: OUTDD(YOURDD). If your output is not on SYSOUT, check the beginning of your compile listings for the options and see if OUTDD is being used.

It is a possibility that logic errors are ensuring that your DISPLAY statements are not executed.

I would recommend putting TIME=(,2) on your EXEC card or your JOB card. This will save you if you happen to get a loop. I still do that today (although get fewer loops than when I was starting out..., many fewer, but if it happens, it'll save a heap of CPU). You may be able to get away with TIME=(,1), but sometimes that chops the dump-processing off in its prime.

When wondering where DISPLAYs that you'e put in the program are, another thing to check is that you are executing the correct version of the program. One thing I find helpful is this:

01  W-WHEN-COMPILED             PIC X(8)BX(8).

MOVE WHEN-COMPILED              TO W-WHEN-COMPILED
DISPLAY "yourprogramname " W-WHEN-COMPILED

You do the 01 in the WORKING-STORAGE and the MOVE and DISPLAY "once only". Then after any run, you look at the sysout and can tell that you are running the program you compiled (or you can tell that you are not). The date/time should be identical to that on your latest compile listing if that is the one you are running. Saved me lots of time over the years.

There is an Intrinsic Function which gives similar output, including a 4-digit year. That is about the only difference between the two. Both are fully resolved at compile-time, so as long as you only execute them in the "once-only" part of your program, there are no performance implications with either of them. Consult the Enterprise COBOL Language Reference for the documentation of WHEN-COMPILED and the Intrinsic Function, and the Programming Guide for documentation of the compile options.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top