IDENTIFICATION DIVISION.                                         
       PROGRAM-ID. FUNCDEMO.                                            
      *                                                                 
       ENVIRONMENT DIVISION.                                            
       DATA DIVISION.                                                   
         WORKING-STORAGE SECTION.                                       
         01 A         PIC S9(3) PACKED-DECIMAL VALUE 100.               
         01 B         PIC S9(3) PACKED-DECIMAL VALUE 200.               
         01 C         PIC S9(3) PACKED-DECIMAL VALUE -30.               
         01 SMALLEST  PIC ZZ9-.                                         
         01 D         PIC 9.9(6).                                       
         01 MONTHS.                                                     
            05 NAMES.                                                   
               10  PIC X(9) VALUE "JANUARY".                            
               10  PIC X(9) VALUE "FEBRUARY".                           
               10  PIC X(9) VALUE "MARCH".                              
               10  PIC X(9) VALUE "APRIL".                              
               10  PIC X(9) VALUE "MAY".                                
               10  PIC X(9) VALUE "JUNE".                               
               10  PIC X(9) VALUE "JULY".                               
               10  PIC X(9) VALUE "AUGUST".                             
               10  PIC X(9) VALUE "SEPTEMBER".                          
               10  PIC X(9) VALUE "OCTOBER".                            
               10  PIC X(9) VALUE "NOVEMBER".                           
               10  PIC X(9) VALUE "DECEMBER".                           
            05 MONTH-NAME REDEFINES NAMES PIC X(9) OCCURS 12 TIMES.     
         01 TESTVALUES.                                                 
            05        PIC S99 VALUE 10.                                 
            05        PIC S99 VALUE 20.                                 
            05        PIC S99 VALUE 30.                                 
            05        PIC S99 VALUE 40.                                 
            05        PIC S99 VALUE  1.                                 
            05        PIC S99 VALUE  2.                                 
            05        PIC S99 VALUE  3.                                                
            05        PIC S99 VALUE  4.                         
         01 T REDEFINES TESTVALUES.                             
            05 T-ROW OCCURS 2 TIMES.                            
               10 T-ITEM OCCURS 4 TIMES PIC S99.                
         01 TSUM     PIC ZZZZ9.                                 
         01 TMIN     PIC ZZZZ9.                                 
                                                                
         01 MON-VALUES.                                         
            05 SOME-VALUES.                                     
               10   PIC S9(3) PACKED-DECIMAL VALUE 31.          
               10   PIC S9(3) PACKED-DECIMAL VALUE 29.          
               10   PIC S9(3) PACKED-DECIMAL VALUE 31.          
               10   PIC S9(3) PACKED-DECIMAL VALUE 30.          
               10   PIC S9(3) PACKED-DECIMAL VALUE 31.          
               10   PIC S9(3) PACKED-DECIMAL VALUE 30.          
               10   PIC S9(3) PACKED-DECIMAL VALUE 31.               
               10   PIC S9(3) PACKED-DECIMAL VALUE 30.               
               10   PIC S9(3) PACKED-DECIMAL VALUE 31.               
            05 DAYS-IN-MONTH REDEFINES SOME-VALUES OCCURS 12 TIMES   
                                     PIC S9(3) PACKED-DECIMAL.       
         01 TOTAL-DAYS       PIC ZZ9.                                
         01 MINIMUM-IN-MONTH PIC ZZ9.                                
         01 MIN-MONTH-NAME   PIC X(9).                               
         01 I                PIC S9(3) PACKED-DECIMAL.               
         01 NUMEDVAL1        PIC X(11) VALUE "- 3,333.33".           
         01 NUMVAL1          PIC S99999V99 PACKED-DECIMAL.           
         01 VAL1OUT          PIC ZZ,ZZZ.99-.                         
                                                                       
         01 ECP              PIC 9(4) BINARY VALUE 1140.               
         01 ACP              PIC 9(4) BINARY VALUE 819.                
         01 EI               PIC X(8) VALUE "ABCD1234".                
         01 AO               PIC X(20).                                
                                                                       
       PROCEDURE DIVISION.                                             
                                                                       
      *NO  COMPUTE SMALLEST = FUNCTION MIN(A,B,C)                      
      *YES COMPUTE SMALLEST = FUNCTION MIN(A, B, C)                    
                                                                       
           COMPUTE SMALLEST = FUNCTION MIN(A B C)                      
           DISPLAY "THE SMALLEST VALUE WAS " SMALLEST                  
      *NO  DISPLAY "THE SMALLEST VALUE WAS " FUNCTION MIN(A B C)       
           DISPLAY "ABC IN LOWERCASE IS " FUNCTION LOWER-CASE("ABC")   
                                                                        
      *NO  MOVE FUNCTION MIN(A B C) TO SMALLEST                         
           MOVE FUNCTION LOWER-CASE("FEBRUARY") TO MIN-MONTH-NAME       
           DISPLAY "I MOVED " MIN-MONTH-NAME                            
                                                                        
           COMPUTE D =   FUNCTION RANDOM(10)                            
           DISPLAY "RANDOM # BETWEEN 0 AND 1   = " D                    
           COMPUTE D =   FUNCTION RANDOM                                
           DISPLAY "RANDOM # BETWEEN 0 AND 1   = " D                    
                                                                        
           COMPUTE TOTAL-DAYS = FUNCTION SUM(DAYS-IN-MONTH(ALL))        
           DISPLAY "TOTAL DAYS = " TOTAL-DAYS                           
                                                                        
           COMPUTE MINIMUM-IN-MONTH = FUNCTION MIN(DAYS-IN-MONTH(ALL))  
           DISPLAY "MINIMUM DAYS IN A MONTH = " MINIMUM-IN-MONTH        
                                                                        
                                                                        
           COMPUTE I =  FUNCTION ORD-MIN(DAYS-IN-MONTH(ALL))            
           DISPLAY "MONTH WITH THE MINIMUM # OF DAYS IS " MONTH-NAME(I) 
                                                                        
           COMPUTE TSUM = FUNCTION SUM(T-ITEM(ALL ALL))                 
           DISPLAY "THE ARRAY SUM IS " TSUM                             
                                                                        
           COMPUTE TSUM = FUNCTION SUM(T-ITEM(1 ALL))                   
           DISPLAY "THE SUM OF THE 1ST ROW IS " TSUM                    
                                                                        
           COMPUTE TMIN = FUNCTION MIN(T-ITEM(ALL ALL))                 
           DISPLAY "THE ARRAY MINIMUM IS " TMIN                         
                                                                        
      *  01 NUMEDVAL1        PIC X(11) VALUE "$- 3,333.33".             
      *  01 NUMVAL1          PIC S99999V99 PACKED-DECIMAL.              
      *  01 VAL1OUT          PIC ZZ,ZZZ.99-.                            
           COMPUTE NUMVAL1 = FUNCTION NUMVAL-C(NUMEDVAL1)               
           MOVE NUMVAL1 TO VAL1OUT                                      
           DISPLAY VAL1OUT                                              
                                                                        
      *  01 ECP         PIC 9(4) BINARY VALUE 1140.                     
      *  01 ACP         PIC 9(4) BINARY VALUE 819.                      
      *  01 EI          PIC X(8) VALUE "ABCD1234".                      
      *  01 AO          PIC X(8).                                       
      * CONVERT EBCDIC TO ASCII                                         
           DISPLAY FUNCTION HEX-OF(FUNCTION NATIONAL-OF(EI ECP))        
           DISPLAY "==="                                                
           MOVE FUNCTION DISPLAY-OF(FUNCTION NATIONAL-OF(EI ECP) ACP)   
                   TO AO                                                
           DISPLAY FUNCTION HEX-OF(AO)                                  
           GOBACK                                                       
           .