COBOL - Usando PICTURE numérica maior que 18 bytes - www.cadcobol.com.br


Volta a página anterior

Volta ao Menu Principal


Desenvolvido por DORNELLES Carlos Alberto - Analista de Sistemas - Brasília DF. - cad_cobol@hotmail.com

Usando PICTURE numérica maior que 18 bytes - depende do compilador

O número máximo de dígitos que você pode especificar na cláusula PICTURE para um decimal compactado, um decimal externo e um numérico editado, por itens de dados,
é elevado de 18 para 31, quando você usa o CBL ARITH(EXTEND).

        CBL ARITH(EXTEND)
      *-----------------------------------------------------------------
       IDENTIFICATION DIVISION.                                         
      *-----------------------------------------------------------------
       PROGRAM-ID.    CADARITH.                                         
       AUTHOR.        CARLOS ALBERTO DORNELLES.                         
                                                                        
      *-----------------------------------------------------------------
      * TESTE DA PICTURE NUMERICA MAIOR QUE 18 BYTES USANDO A           
      * DECLARACAO DE OPERANDOS ARITMETICOS - ARITH(EXTEND)             
      *-----------------------------------------------------------------
                                                                        
      *-----------------------------------------------------------------
       ENVIRONMENT DIVISION.                                            
      *-----------------------------------------------------------------
                                                                        
       CONFIGURATION SECTION.                                           
       SPECIAL-NAMES.                                                   
                      DECIMAL-POINT IS COMMA.                           
                                                                        
      *-----------------------------------------------------------------
       DATA DIVISION.                                                   
      *-----------------------------------------------------------------
                                                                        
       WORKING-STORAGE SECTION.                                         
                                                                        
       01  WSS-AUXILIARES.                                              
           05  WSS-PIC18          PIC 9(018)            VALUE ZEROES.   
           05  WSS-PIC19          PIC 9(019)            VALUE ZEROES.   
           05  WSS-PIC20          PIC 9(020)            VALUE ZEROES.   
           05  WSS-PIC23          PIC 9(023)            VALUE ZEROES.   
           05  WSS-PIC25          PIC 9(025)            VALUE ZEROES.   
           05  WSS-PIC30          PIC 9(030)            VALUE ZEROES.   
           05  WSS-PIC31          PIC 9(031)            VALUE ZEROES.   
           05  WSS-PIC32          PIC 9(029)V9(02)      VALUE           
               12345678901234567890123456789,99.                        
           05  WSS-PIC33          PIC 9(005)V9(26)      VALUE           
               12345,67890123456789012345678901.                        
           05  WSS-PIC34          PIC 9(031)            VALUE           
               1234567890123456789.                                     
           05  WSS-PIC35          PIC 9(031)            VALUE ZEROES.   
           05  WSS-PIC36          PIC 9(031)            VALUE ZEROES.   
           05  WSS-PICCI          PIC $(031)            VALUE ZEROES.   
           05  WSS-PICZZ                                                
               PIC ZZ.ZZZ.ZZZ.ZZZ.ZZZ.ZZZ.ZZZ.ZZZ.ZZZ.ZZ9,99            
                                                        VALUE ZEROES.   
           05  WSS-PICDE                                                
               PIC ZZ.ZZ9,99999999999999999999999999    VALUE ZEROES.   
           05  WSS-PICAS          PIC *(031)            VALUE ZEROES.   
                                                                        
      *-----------------------------------------------------------------
       PROCEDURE DIVISION.                                              
      *-----------------------------------------------------------------
                                                                        
           MOVE 18              TO WSS-PIC18                            
           MOVE 30              TO WSS-PIC20                            
           ADD  10              TO WSS-PIC23                            
           COMPUTE  WSS-PIC19    = 3 ** 3                               
           COMPUTE  WSS-PIC25    = WSS-PIC23 + WSS-PIC20                
           COMPUTE  WSS-PIC30    = WSS-PIC23 - WSS-PIC20                
           COMPUTE  WSS-PIC31    = WSS-PIC20 / WSS-PIC23                
           MOVE     WSS-PIC32   TO WSS-PICZZ                            
           MOVE     WSS-PIC33   TO WSS-PICDE                            
           MOVE     WSS-PIC34   TO WSS-PICCI                            
           MOVE     WSS-PIC34   TO WSS-PICAS                            
           DIVIDE   WSS-PIC34   BY 11                                   
                    GIVING WSS-PIC35 REMAINDER WSS-PIC36

           DISPLAY 'WSS-PIC18  - ' WSS-PIC18                            
           DISPLAY 'WSS-PIC19  - ' WSS-PIC19                            
           DISPLAY 'WSS-PIC20  - ' WSS-PIC20                            
           DISPLAY 'WSS-PIC23  - ' WSS-PIC23                            
           DISPLAY 'WSS-PIC25  - ' WSS-PIC25                            
           DISPLAY 'WSS-PIC30  - ' WSS-PIC30                            
           DISPLAY 'WSS-PIC31  - ' WSS-PIC31                            
           DISPLAY 'WSS-PICZZ  - ' WSS-PICZZ                            
           DISPLAY 'WSS-PICDE  - ' WSS-PICDE                            
           DISPLAY 'WSS-PICCI  - ' WSS-PICCI                            
           DISPLAY 'WSS-PICAS  - ' WSS-PICAS                            
           DISPLAY 'WSS-PIC35  - ' WSS-PIC35                            
           DISPLAY 'WSS-PIC36  - ' WSS-PIC36                            
           STOP RUN                                                     
           .


Resultados do teste efetuado:
********************************* TOP OF DATA **********************************
WSS-PIC18  - 000000000000000018                                                 
WSS-PIC19  - 0000000000000000027                                                
WSS-PIC20  - 00000000000000000030                                               
WSS-PIC23  - 00000000000000000000010                                            
WSS-PIC25  - 0000000000000000000000040                                          
WSS-PIC30  - 000000000000000000000000000020                                     
WSS-PIC31  - 0000000000000000000000000000003                                    
WSS-PICZZ  - 12.345.678.901.234.567.890.123.456.789,99                          
WSS-PICDE  - 12.345,67890123456789012345678901                                  
WSS-PICCI  -            $1234567890123456789                                    
WSS-PICAS  - ************1234567890123456789                                    
WSS-PIC35  - 0000000000000112233444556677889                                    
WSS-PIC36  - 0000000000000000000000000000010                                    
******************************** BOTTOM OF DATA ********************************