SELECT & TO DISC in Visual COBOL for Unix

[Migrated content. Thread originally posted on 08 March 2012]

Hello,

We have noticed that the following definition:
           SELECT OPTIONAL TRABSEQ
                  ASSIGN TO DISC LOC-TRABSEQ
                  ORGANIZATION IS LINE SEQUENTIAL
                  FILE STATUS IS STAT-TRABSEQ.

shows an unpredictable behavior, whereas the same instruction -without DISC- works as expected.

We are using the following directives:
SHOW-DIR
CALLFH(ACUFH)
RM "GIVING"
RM "ANSI"
REMOVE"TIMEOUT"
PERFORM-TYPE"RM"
OLDNEXTSENTENCE
  • Can you please elaborate on what you mean by "unpredictable behavior"?

    Exactly what is it that is occurring in your application?

    Thanks.
  • For example, in the code below, the information is written but the read operation does not return anything. If you remove the clause, it wors fine.
          $SET USE"/MNG/DESA/FUENTES/EQBASE/VC/CFG/myDirectives.dir"
           IDENTIFICATION DIVISION.
           PROGRAM-ID. PRDISC.
           AUTHOR. mossa.
           ENVIRONMENT DIVISION.
           CONFIGURATION SECTION.
           SOURCE-COMPUTER. LEVEL-6.
           OBJECT-COMPUTER. LEVEL-6.
           SPECIAL-NAMES.
    VC         call-convention 0 is VisualCOBOLcall
               DECIMAL-POINT COMMA.
           INPUT-OUTPUT SECTION.
           FILE-CONTROL.
               SELECT OPTIONAL TRABSEQ
                      ASSIGN TO DISC LOC-TRABSEQ
                      ORGANIZATION IS LINE SEQUENTIAL
                      FILE STATUS IS STAT-TRABSEQ.
          /
           DATA DIVISION.
           FILE SECTION.
           FD  TRABSEQ
               LABEL RECORD IS STANDARD
               DATA RECORD IS ART-TRSEQ.
           01 ART-TRSEQ                    PIC X(80).

           WORKING-STORAGE SECTION.
           COPY "FWOR4SB.CPY".
           77 LOC-TRABSEQ               PIC X(128) VALUE SPACES.
           77 STAT-TRABSEQ              PIC XX.
           
           01  WENTRADA                    PIC X(74).
           01  ENTORNO-W                   PIC X(10).
               88 ENTORNO-REAL-W              VALUE "/MNG".
               88 ENTORNO-PRUEBAS-W           VALUE "/MNG1".
           
          * ////////////////////////////////////////////////////////////////
          * ////////////////////////////////////////////////////////////////
           PROCEDURE DIVISION.

          ***********************
          * SECCION DE ENTRADA. *
          ***********************
           INICIO SECTION.
          *---------------
           INI-1.
               MOVE "/MNG/EXPL/TMP/TEST.TXT" TO LOC-TRABSEQ.
               OPEN OUTPUT TRABSEQ.
               MOVE "CACA" TO ART-TRSEQ.
               WRITE ART-TRSEQ.
               CLOSE TRABSEQ.
               ACCEPT FP-Z.
               OPEN INPUT TRABSEQ.
               READ TRABSEQ AT END
                   MOVE HIGH-VALUES TO ART-TRSEQ
               END-READ.
               DISPLAY ART-TRSEQ.
               CLOSE TRABSEQ.

            FIN-PROGRAMA.
               GOBACK.


           COPY "FPROC4SB.CPY".
           
  • For example, in the code below, the information is written but the read operation does not return anything. If you remove the clause, it wors fine.
          $SET USE"/MNG/DESA/FUENTES/EQBASE/VC/CFG/myDirectives.dir"
           IDENTIFICATION DIVISION.
           PROGRAM-ID. PRDISC.
           AUTHOR. mossa.
           ENVIRONMENT DIVISION.
           CONFIGURATION SECTION.
           SOURCE-COMPUTER. LEVEL-6.
           OBJECT-COMPUTER. LEVEL-6.
           SPECIAL-NAMES.
    VC         call-convention 0 is VisualCOBOLcall
               DECIMAL-POINT COMMA.
           INPUT-OUTPUT SECTION.
           FILE-CONTROL.
               SELECT OPTIONAL TRABSEQ
                      ASSIGN TO DISC LOC-TRABSEQ
                      ORGANIZATION IS LINE SEQUENTIAL
                      FILE STATUS IS STAT-TRABSEQ.
          /
           DATA DIVISION.
           FILE SECTION.
           FD  TRABSEQ
               LABEL RECORD IS STANDARD
               DATA RECORD IS ART-TRSEQ.
           01 ART-TRSEQ                    PIC X(80).

           WORKING-STORAGE SECTION.
           COPY "FWOR4SB.CPY".
           77 LOC-TRABSEQ               PIC X(128) VALUE SPACES.
           77 STAT-TRABSEQ              PIC XX.
           
           01  WENTRADA                    PIC X(74).
           01  ENTORNO-W                   PIC X(10).
               88 ENTORNO-REAL-W              VALUE "/MNG".
               88 ENTORNO-PRUEBAS-W           VALUE "/MNG1".
           
          * ////////////////////////////////////////////////////////////////
          * ////////////////////////////////////////////////////////////////
           PROCEDURE DIVISION.

          ***********************
          * SECCION DE ENTRADA. *
          ***********************
           INICIO SECTION.
          *---------------
           INI-1.
               MOVE "/MNG/EXPL/TMP/TEST.TXT" TO LOC-TRABSEQ.
               OPEN OUTPUT TRABSEQ.
               MOVE "CACA" TO ART-TRSEQ.
               WRITE ART-TRSEQ.
               CLOSE TRABSEQ.
               ACCEPT FP-Z.
               OPEN INPUT TRABSEQ.
               READ TRABSEQ AT END
                   MOVE HIGH-VALUES TO ART-TRSEQ
               END-READ.
               DISPLAY ART-TRSEQ.
               CLOSE TRABSEQ.

            FIN-PROGRAMA.
               GOBACK.


           COPY "FPROC4SB.CPY".
           
  • For example, in the code below, the information is written but the read operation does not return anything. If you remove the clause, it wors fine.
          $SET USE"/MNG/DESA/FUENTES/EQBASE/VC/CFG/myDirectives.dir"
           IDENTIFICATION DIVISION.
           PROGRAM-ID. PRDISC.
           AUTHOR. mossa.
           ENVIRONMENT DIVISION.
           CONFIGURATION SECTION.
           SOURCE-COMPUTER. LEVEL-6.
           OBJECT-COMPUTER. LEVEL-6.
           SPECIAL-NAMES.
    VC         call-convention 0 is VisualCOBOLcall
               DECIMAL-POINT COMMA.
           INPUT-OUTPUT SECTION.
           FILE-CONTROL.
               SELECT OPTIONAL TRABSEQ
                      ASSIGN TO DISC LOC-TRABSEQ
                      ORGANIZATION IS LINE SEQUENTIAL
                      FILE STATUS IS STAT-TRABSEQ.
          /
           DATA DIVISION.
           FILE SECTION.
           FD  TRABSEQ
               LABEL RECORD IS STANDARD
               DATA RECORD IS ART-TRSEQ.
           01 ART-TRSEQ                    PIC X(80).

           WORKING-STORAGE SECTION.
           COPY "FWOR4SB.CPY".
           77 LOC-TRABSEQ               PIC X(128) VALUE SPACES.
           77 STAT-TRABSEQ              PIC XX.
           
           01  WENTRADA                    PIC X(74).
           01  ENTORNO-W                   PIC X(10).
               88 ENTORNO-REAL-W              VALUE "/MNG".
               88 ENTORNO-PRUEBAS-W           VALUE "/MNG1".
           
          * ////////////////////////////////////////////////////////////////
          * ////////////////////////////////////////////////////////////////
           PROCEDURE DIVISION.

          ***********************
          * SECCION DE ENTRADA. *
          ***********************
           INICIO SECTION.
          *---------------
           INI-1.
               MOVE "/MNG/EXPL/TMP/TEST.TXT" TO LOC-TRABSEQ.
               OPEN OUTPUT TRABSEQ.
               MOVE "CACA" TO ART-TRSEQ.
               WRITE ART-TRSEQ.
               CLOSE TRABSEQ.
               ACCEPT FP-Z.
               OPEN INPUT TRABSEQ.
               READ TRABSEQ AT END
                   MOVE HIGH-VALUES TO ART-TRSEQ
               END-READ.
               DISPLAY ART-TRSEQ.
               CLOSE TRABSEQ.

            FIN-PROGRAMA.
               GOBACK.


           COPY "FPROC4SB.CPY".
           
  • Verified Answer

    The word "DISC" is not recognized by the Visual COBOL compiler.
    According to the documentation for the File-Control entry the keyword should be "DISK" and not "DISC".

    File-Control Entry

    The compiler is interpreting the word "DISC" as being a data-item name that should contain the name of the file when it is opened. Since "DISC" does not exist in the working-storage section the compiler generates the data-item automatically.

    When I use the following syntax in Visual COBOL:

    select optional test-file assign to DISC FILENAME

    it gives me a warning that FILENAME will be treated as documentary even though it is a valid data-item in working-storage because the compiler interprets this statement as having two data items in the assign clause which is allowed but the second item will be treated as documentary.

    If you change "DISC" to "DISK" it works as expected.
  • You could also use the checker directive:

    addsyn"disk"="disc"

    If you did not want to change your code.