Apostila Cobol

Embed Size (px)

Text of Apostila Cobol

COBOL II

1

NDICEINTRODUO............................................................................................................................................4 EXEMPLO DE UM PROGRAMA COBOL............................................................................................5 FOLHA DE CODIFICAO COBOL.....................................................................................................8 AS DIVISES DO COBOL........................................................................................................................9 IDENTIFICATION DIVISION..........................................................................................................9 CLUSULA COMMON ........................................................................................................................9 CLUSULA INITIAL ...........................................................................................................................9 ENVIRONMENT DIVISION...................................................................................................................11 CONFIGURATION SECTION........................................................................................................11 SOURCECOMPUTER.....................................................................................................................11 OBJECTCOMPUTER......................................................................................................................11 SPECIAL NAMES...........................................................................................................................11 INPUTOUTPUT SECTION.............................................................................................................12 DATA DIVISION.......................................................................................................................................13 FUNES DA DATA DIVISION..........................................................................................................13 ESTRUTURA GERAL DA DATA DIVISION............................................................................................13 FILE SECTION...............................................................................................................................13 RECORDING MODE......................................................................................................................15 RECORD DESCRIPTION...............................................................................................................15 CLUSULA OCCURS....................................................................................................................16 CLUSULA REDEFINES...............................................................................................................16 WORKINGSTORAGE SECTION....................................................................................................18 ITENS INDEPENDENTES NA WORKINGSTORAGE SECTION..................................................19 ITENS DE GRUPO NA WORKING-STORAGE SECTION............................................................21 NOMES CONDICIONAIS...............................................................................................................21 CLUSULA PICTURE...................................................................................................................22 PICTURES DE EDIO.................................................................................................................23 CLUSULA BLANK WHEN ZERO...............................................................................................24 REGRAS DE ALINHAMENTO......................................................................................................25 PROCEDURE DIVISION........................................................................................................................25 SUBDIVISES DA PROCEDURE..................................................................................................25 COMANDOS DO COBOL.......................................................................................................................26 OPEN..............................................................................................................................................26 CLOSE............................................................................................................................................26 READ..............................................................................................................................................27 WRITE............................................................................................................................................27 IF/ELSE...........................................................................................................................................29 AND E OR.......................................................................................................................................30 INITIALIZE....................................................................................................................................30 INSPECT.........................................................................................................................................32 MOVE.............................................................................................................................................34 MOVE NUMRICO........................................................................................................................34 MOVE ALFANUMRICO..............................................................................................................35 MOVE CORRESPONDING (CORR)...............................................................................................35 MOVE ALL.....................................................................................................................................35 PERFORM.......................................................................................................................................37 REWRITE.......................................................................................................................................38 STOP RUN......................................................................................................................................39 OPERADORES ARITMTICOS.....................................................................................................40 ADD................................................................................................................................................40

2

SUBTRACT.....................................................................................................................................40 MULTIPLY.....................................................................................................................................41 DIVIDE...........................................................................................................................................42 COMPUTE......................................................................................................................................42 OPCO ROUNDED........................................................................................................................43 CLUSULA ON SIZE ERROR.......................................................................................................43 CONTINUE.....................................................................................................................................44 DELETE..........................................................................................................................................44 DISPLAY........................................................................................................................................44 EVALUATE....................................................................................................................................45 ACCEPT..........................................................................................................................................47 MANIPULAO DE TABELAS............................................................................................................49 INDEXADORES.............................................................................................................................55 SEARCH.........................................................................................................................................55 PESQUISA SEM A INSTRUO SEARCH:..................................................................................................56 PESQUISA COM INSTRUO SEARCH:....................................................................................................56 SEARCH.........................................................................................................................................57 SET..................................................................................................................................................57 START............................................................................................................................................57 STRING...........................................................................................................................................58 UNSTRING.....................................................................................................................................58 SORT...............................................................................................................................................59 CLUSULA ASCENDIG/DESCENDING....