Skip to main content

Declarative section in MF COBOL

  • April 5, 2013
  • 3 replies
  • 0 views

In the declarative section in MF COBOL for Net Express (on Windows) and Server Express (on  Solaris, Linux, AIX, HP UX), what should be defined as SOURCE-COMPUTER?

We are aware of the compiler directive TRACE, and are able to make use of it. We are explicitly looking for the usage of DECLARATIVE section.

Our product works on multiple platforms, and hence using TRACE compiler directive is not an option, since it won't be available on IBM Mainframe.


#ServerExpressHTTPURL
#netexpress
#debugging

3 replies

In the declarative section in MF COBOL for Net Express (on Windows) and Server Express (on  Solaris, Linux, AIX, HP UX), what should be defined as SOURCE-COMPUTER?

We are aware of the compiler directive TRACE, and are able to make use of it. We are explicitly looking for the usage of DECLARATIVE section.

Our product works on multiple platforms, and hence using TRACE compiler directive is not an option, since it won't be available on IBM Mainframe.


#ServerExpressHTTPURL
#netexpress
#debugging

Hi

To use ansi debug

For MF COBOL you need this env variable

# allow ansi debug debug declaratives and lines pre fixed by D

COBSW=" D"

export COBSW

in source code you need this line.

SOURCE-COMPUTER. ZX81ROCKS WITH DEBUGGING MODE.

For trace i check using conditionals in MF COBOL

$IF TRACE set

  $DISPLAY directive TRACE has been set so ready trace and reset trace should work

      78  readytrace                            value "enabled".

$ELSE

  $DISPLAY directive TRACE has not been set so ready trace and reset trace act as comments

      78  readytrace                            value "disabled".

$END              

The declarative section would look like this.

      procedure division.

      declaratives.

      debugprocedures section.

     *>     use for debugging on all procedures.

          use for debugging on sortprocedureinput, sortprocedureoutput.

      debugprocedures-010.

          if in-abort or debug-declaratives-on

              display "debugprocedures debug-item <", debug-item(1:70), ">"

          end-if

          .

      debugprocedures-090.

          exit.      

      debugfiles section.

          use for debugging on inputfile, outputfile, sortfile.

      debugfiles-010.

          if in-abort or debug-declaratives-on

              display "debugfiles debug-item <", debug-item(1:70), ">"

          end-if

          .

      debugfiles-090.

          exit.      

      debugvariable section.

          use for debugging on all references of sortfile-rec,

                                                 abort-count,

                                                 sortprocedureoutputloop-count,

                                                 file-status.

      debugvariable-010.

          if in-abort or debug-declaratives-on

              display "debugvariable debug-item <", debug-item(1:70), ">"

          end-if

          .

      debugvariable-090.

          exit.      

      filesortfile section.

          use after standard error procedure on sortfile.

      filesortfile-010.

D          display "filesortfile declarative sortfile executing"

          perform check-file-status

          .

      filesortfile-090.

          exit.

      fileio section.

          use after standard error procedure on I-O.

      fileio-010.

D          display "fileio declarative I-O executing"

          perform check-file-status

          .

      fileio-090.

          exit.

      fileinput section.

          use after standard error procedure on INPUT.

      fileinput-010.

D          display "fileinput declarative INPUT executing"

          perform check-file-status

          .

      fileinput-090.

          exit.

      fileoutput section.

          use after standard error procedure on OUTPUT.

      fileoutput-010.

D          display "fileoutput declarative OUTPUT executing"

          perform check-file-status

          .

      fileoutput-090.

          exit.

      fileextend section.

          use after standard error procedure on EXTEND.

      fileexxtend-010.

D          display "fileextend declarative EXTEND executing"

          perform check-file-status

          .

      fileextend-090.

          exit.

      end declaratives.

      main section.

      main-010.

          perform init

          perform work

          perform fini

          .

      main-090.

          goback.

This code will trigger declarative and as abort-count is updated trigger them to.

     *>

     *> test stand alone release

     *>

          set not-in-abort to true

          move "00" to file-status

          reset trace

D          move 700 to abort-count

D          display "work release outside of sort procedure abort count set <", abort-count, ">"

          move all "A" to inputfile-rec

          release sortfile-rec from inputfile-rec

D          if in-abort add 1 to abort-count end-if

          if in-abort

              display "work test 700 in-abort check-file-status has been executed by declaratives"

D              if in-abort add 1 to abort-count end-if

          else

              display "work test 700 not-in-abort check-file-status has not been executed by declaratives"

              perform check-file-status

D              if in-abort add 1 to abort-count end-if

          end-if

D          if in-abort add 1 to abort-count end-if

Notice the D this should be in column 7 unless using free format when it should be in column 1.

Output from the log

work release outside of sort procedure abort count set <0700 >

debugvariable debug-item <   391 ABORT-COUNT                                      0700          >

debugvariable debug-item <   393 SORTFILE-REC                                     AAAAAAAAAAAAAA>

work test 700 not-in-abort check-file-status has not been executed by declaratives

check-file-status trace directive <enabled>

check-file-status tracing turned on by ready trace

check-file-status <9/220>

COBRT220 Attempt to execute more than one SORT or MERGE simultaneously (Fatal)

CHECK-FILE-STATUS-090

This is simple explanation but hope this helps

Regards

Tony


In the declarative section in MF COBOL for Net Express (on Windows) and Server Express (on  Solaris, Linux, AIX, HP UX), what should be defined as SOURCE-COMPUTER?

We are aware of the compiler directive TRACE, and are able to make use of it. We are explicitly looking for the usage of DECLARATIVE section.

Our product works on multiple platforms, and hence using TRACE compiler directive is not an option, since it won't be available on IBM Mainframe.


#ServerExpressHTTPURL
#netexpress
#debugging

Thanks Tony for the solution.

I will try this out tomorrow.

Regards,

Jinesh


In the declarative section in MF COBOL for Net Express (on Windows) and Server Express (on  Solaris, Linux, AIX, HP UX), what should be defined as SOURCE-COMPUTER?

We are aware of the compiler directive TRACE, and are able to make use of it. We are explicitly looking for the usage of DECLARATIVE section.

Our product works on multiple platforms, and hence using TRACE compiler directive is not an option, since it won't be available on IBM Mainframe.


#ServerExpressHTTPURL
#netexpress
#debugging

Thanks Tony for the solution.

I will try this out tomorrow.

Regards,

Jinesh