1 / 10

Conceptos Básicos del lenguaje de programación COBOL

Conceptos Básicos del lenguaje de programación COBOL. Prof. Carlos Rodríguez Sánchez. COBOL. CO mmon B usiness O riented L anguage Es un lenguaje muy utilizado dentro del llamado “File Processing System” Permite la utilización de varios archivos de datos que interactúan con el programa.

jana
Download Presentation

Conceptos Básicos del lenguaje de programación COBOL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Conceptos Básicos del lenguaje de programación COBOL Prof. Carlos Rodríguez Sánchez

  2. COBOL • COmmon Business Oriented Language • Es un lenguaje muy utilizado dentro del llamado “File Processing System” • Permite la utilización de varios archivos de datos que interactúan con el programa. • Master File • Transaction File • History File • Table File • Sort File

  3. COBOL IDENTIFICATION DIVISION. PROGRAM-ID. C6. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT CUST-FILE ASSIGN TO "E:CUST.DAT" ORGANIZATION IS LINE SEQUENTIAL. SELECT PRINT-FILE ASSIGN TO "PRN". • Un programa codificado en el lenguaje COBOL consiste de cuatro divisiones principales. • IDENTIFICATION DIVISION • ENVIRONMENT DIVISION • DATA DIVISION • PROCEDURE DIVISION

  4. COBOL DATA DIVISION. FILE SECTION. FD CUST-FILE LABEL RECORDS ARE STANDARD. 01 CUST-REC. 03 INITIAL1 PIC X. 03 INITIAL2 PIC X. 03 LAST-NAME PIC X(10). 03 MONTH-TRANS PIC XX. 03 YEAR-TRANS PIC X(2). 03 TRANS-AMOUNT PIC 9(6). FD PRINT-FILE LABEL RECORDS ARE OMMITED. 01 PRINT-LINE PIC X(80). WORKING-STORAGE SECTION. 01 MORE-RECORDS PIC X VALUE "Y". 01 HEADING-1. 03 PIC X(5) VALUE SPACES. 03 PIC X(4) VALUE "NAME". 03 PIC X(6) VALUE SPACES. 03 PIC X(19) VALUE "DATE OF TRANSACTION". 03 PIC X(24) VALUE " AMOUNT OF TRANSACTION". 03 PIC X(23) VALUE SPACES. 01 DETAIL-LINE. 03 INITIAL1-OUT PIC X. 03 PIC X VALUE ".". 03 INITIAL2-OUT PIC X. 03 PIC X VALUE ".". 03 LAST-NAME-OUT PIC X(10). 03 PIC X(6) VALUE SPACES. 03 MONTH-OUT PIC X(2). 03 PIC X VALUE "/". 03 YEAR-OUT PIC X(2). 03 PIC X(13) VALUE SPACES. 03 AMOUNT-OUT PIC $ZZZ,ZZ9. 03 PIC X(34) VALUE SPACES

  5. COBOL PROCEDURE DIVISION. RUTINA-PRINCIPAL. OPEN INPUT CUST-FILE OUTPUT PRINT-FILE WRITE PRINT-LINE FROM HEADING-LINE AFTER ADVANCING PAGE PERFORM MOVE-AND-WRITE UNTIL MORE-RECORDS = "N" CLOSE CUST-FILE PRINT-FILE STOP RUN. MOVE-AND-WRITE. READ CUST-FILE AT END MOVE "N" TO MORE-RECORDS MOVE INITIAL1 TO INITIAL1-OUT MOVE INITIAL2 TO INITIAL2-OUT MOVE LAST-NAME TO LAST-NAME-OUT MOVE MONTH-TRANS TO MONTH-OUT MOVE YEAR-TRANS TO YEAR-OUT MOVE TRANS-AMOUNT TO AMOUNT-OUT WRITE PRINT-LINE FROM DETAIL-LINE AFTER ADVANCING 1 LINE.

  6. Manejo de Arreglos y Tablas WORKING-STORAGE SECTION. 01 TOTALES-DIARIOS. 03 TOTAL-DIA OCCURS 5 TIMES PIC 9(4)v99 VALUE ZEROS. 01 NOMBRES VALUE "MONTUEWEDTHUFRI". 03 DIAS OCCURS 5 TIMES PIC X(3).

  7. Manejo de Arreglos y Tablas IDENTIFICATION DIVISION. PROGRAM-ID. EJEMPLO CAP 12. AUTHOR. SCI 317. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT VENTAS ASSIGN TO "C:DATAIN.DAT" ORGANIZATION IS LINE SEQUENTIAL. SELECT REPORTE ASSIGN TO "PRN".

  8. Manejo de Arreglos y Tablas DATA DIVISION. FILE SECTION. FD VENTAS LABEL RECORDS ARE STANDARD. 01 RECORDS-VENTAS. 03 DAY-NO PIC 9. 03 SLSNO PIC X(3). 03 AMT-IN PIC 9(3)v99. FD REPORTE LABEL RECORDS ARE OMITTED. 01 LINEA-DE-IMPRESION PIC X(80). WORKING-STORAGE SECTION. 01 TOTALES-DIARIOS. 03 TOTAL-DIA OCCURS 5 TIMES PIC 9(4)v99 VALUE ZEROS. 01 NOMBRES VALUE "MONTUEWEDTHUFRI". 03 DIAS OCCURS 5 TIMES PIC X(3). 01 LINEA-DE-SALIDA. 03 PIC X(15) VALUE SPACES. 03 DIA-OUT PIC XXX. 03 PIC X(10) VALUE SPACES. 03 TOTAL-VENTAS PIC $9,999.99. 03 PIC X(43) VALUE SPACES. 01 MORE-RECORDS PIC X(3) VALUE "YES".

  9. Manejo de Arreglos y Tablas PROCEDURE DIVISION. 100-RUTINA-PRINCIPAL. PERFORM 500-RUTINA-INICIAL PERFORM UNTIL MORE-RECORDS = "NO" READ VENTAS AT END MOVE "NO" TO MORE-RECORDS NOT AT END PERFORM 200-RUTINA-COMPUTOS END-READ END-PERFORM PERFORM 600-RUTINA-FINAL STOP RUN. 200-RUTINA-COMPUTOS. IF DAY-NO < 1 OR DAY-NO > 5 PERFORM 800-RUTINA-ERROR ELSE ADD AMT-IN TO TOTAL-DIA (DAY-NO). 500-RUTINA-INICIAL. OPEN INPUT VENTAS OUTPUT REPORTE. 600-RUTINA-FINAL. PERFORM 700-RUTINA-IMPRIMIR VARYING X FROM 1 BY 1 UNTIL X > 5 CLOSE VENTAS REPORTE. 700-RUTINA-IMPRIMIR. MOVE DIAS (X) TO DIA-OUT MOVE TOTAL-DIA (X) TO TOTAL-VENTAS WRITE LINEA-DE-IMPRESION FROM LINEA-DE-SALIDA AFTER ADVANCING 2 LINES. 800-RUTINA-ERROR. DISPLAY "NUMERO DEL DIA INVALIDO", DAY-NO CLOSE VENTAS REPORTE STOP RUN.

  10. Proceso de Compilación • Source program .CBL • Object program .COB

More Related