Re: VAX Cobol

Csesztregi György <c_gyuri@freemail.c3.hu>



Varga Tibor wrote:

> Sziasztok !
>
> Hasznaljak mashol is a Cobolt VMS alatt, vagy csak nalunk ?
> Kollegaim most probalnak masodlagos index szerinti filekezelest es
> igencsak kinlodnak.
> Tudna segiteni valaki ?
> (En nem ertek a Cobolhoz.)
>
> Udv. Tibi

Sziasztok !

En is csak kozvetito vagyok Cobol ugyben, de a kolleganom osszedobott
egy kis mintaprogramkat, talan segit nektek:

IDENTIFICATION DIVISION.
PROGRAM-ID. proba.

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
    SELECT ism-file
 ASSIGN TO "proba.ism"
 ORGANIZATION IS INDEXED
        RECORD KEY IS broker DUPLICATES ASCENDING
        ALTERNATE RECORD KEY IS cover  DUPLICATES
        ACCESS MODE IS DYNAMIC.
DATA DIVISION.

FILE SECTION.
FD ism-file
    LABEL RECORDS ARE STANDARD.
*      rekordhossz: 15
* elsodleges kulcs: broker       (3.poz.-tol 4 hosszan)
* alternativ kulcs: cover        (8.poz.-tol 3 hosszan)
01  ism-rec.
    02  relpos   pic xx.
    02  broker   pic xxxx.
    02  filler       pic x.
    02  cover    pic xxx.
    02   filler      pic x.
    02  barmi    pic xx.
    02  valami   pic xx.
*
WORKING-STORAGE SECTION.
01  STATUS_RESULT   PIC S9(9) COMP.
01  it              PIC S999 value zero.
*
PROCEDURE DIVISION GIVING status_result.

*DECLARATIVES.
*d SECTION.
*    USE AFTER STANDARD ERROR PROCEDURE ON ism-file.
*d1.
*    move RMS-STS to status_result.
*    exit program.
*END DECLARATIVES.

A SECTION.
B.
    set status_result to success.
    open input ism-file.
    move "000"  to cover.

    display "".
    display "INDEXSZEKVENCIÁLIS FILE OLVASÁSA ALTERNATIV KULCS SZERINT".

    display "".

    start ism-file key > cover
          invalid key
            display "-->start ut. invalid key..."
            move rms-sts to status_result
            go to exit-program
          end-start.
olv.
     read ism-file next record
          at end
            display "end of file allt be...."
            go to exit-program
          end-read.
     add 1 to it.
     display it with conversion ". rekord ->" ism-rec "<-".
     go to olv.
exit-program.
     close ism-file.
     CALL "sys$exit" USING BY VALUE status_result.
     stop run.

Udv:
Csesztregi Gyorgy