Summary -

In this topic, we described about the below sections -

ACCEPT statement accepts the data or system date-related information during the program execution. ACCEPT transfers received information into the data area referenced by the specified identifier. There is no editing or error checking of the receiving data.

Syntax - data transfer

ACCEPT - Data transfer syntax

The above syntax transfers data from an input source into the data item referenced by identifier-1. FROM phase is optional in the ACCEPT statement.

When the FROM phrase is omitted, the default system input device is assumed. The above syntax is useful when operator intervention is required. The operator should be supply with the appropriate message.

identifier-1

The receiving area/data item. identifier-1 can be an alphanumeric group item or an elementary data item of usage DISPLAY.

mnemonic-name-1

Specifies the input device. mnemonic-name-1 should be associated in the SPECIAL-NAMES paragraph with an environment-name.

environment-name

Identifies the source of input data. An environment-name is SYSIN or SYSIPT can be specified.

System date-related information transfer -

System information contained in the data items DATE, DATE YYYYMMDD, DAY, DAY YYYYDDD, DAY-OF-WEEK or TIME can be transferred into the data item identifier-2.

Syntax - system information transfer

ACCEPT System date-related information transfer

identifier-2

The receiving data item. The data item can be an alphanumeric group item or an elementary item (alphanumeric, alphanumeric-edited, numeric-edited (with usage DISPLAY), numeric, internal floating-point and external floating-point (with usage DISPLAY).

Current date can be accessed in two formats - the day of the week or the time of day. The current date and time can also be accessed with the intrinsic function CURRENT-DATE.

The conceptual data items DATE, DATE YYYYMMDD, DAY, DAY YYYYDDD, DAY-OF-WEEK and TIME implicitly have USAGE DISPLAY.

DATE

Identifier-2 must be defined with PICTURE 9(6). The returned value has implicit DATE FORMAT YYXXXX. The sequence of data elements (from left to right) is -

  • Two digits for the year
  • Two digits for the month
  • Two digits for the day

DATE YYYYMMDD

Identifier-2 must be defined with PICTURE 9(8). The returned value has implicit DATE FORMAT YYYYXXXX. The sequence of data elements (from left to right) is -

  • Four digits for the year
  • Two digits for the month
  • Two digits for the day

DAY

Identifier-2 must be defined with PICTURE 9(5). The returned value has implicit DATE FORMAT YYXXX. The sequence of data elements (from left to right) is -

  • Two digits for the year
  • Three digits for the day

DAY YYYYDDD

Identifier-2 must be defined with PICTURE 9(7). The returned value has implicit DATE FORMAT YYYYXXX. The sequence of data elements (from left to right) is -

  • Four digits for the year
  • Three digits for the day

DAY-OF-WEEK

Identifier-2 must be defined with PICTURE 9(1). The single data element represents the day of the week according to the following values -

  • 1 represents Monday
  • 2 represents Tuesday
  • 3 represents Wednesday
  • 4 represents Thursday
  • 5 represents Friday
  • 6 represents Saturday
  • 7 represents Sunday

TIME

Identifier-2 must be defined with PICTURE 9(8). The sequence of data elements (from left to right) is -

  • Two digits for hour of day
  • Two digits for minute of hour
  • Two digits for second of minute
  • Two digits for hundredths of second

Practical Example -

Code -


 IDENTIFICATION DIVISION.                                         
 PROGRAM-ID. ACCPTST.                                            
 ENVIRONMENT DIVISION.                                            
 DATA DIVISION.                                                   
 WORKING-STORAGE SECTION.                                         
 01 AGE                       PIC 9(03).                          
 01 GENDER                    PIC X(01).                         
 PROCEDURE DIVISION.                                             
     ACCEPT AGE.                                                  
     ACCEPT GENDER.                                               
     EVALUATE TRUE ALSO TRUE                                      
        WHEN AGE > 018 ALSO GENDER = 'M'                          
             DISPLAY 'THE BOY IS MAJOR   '                        
        WHEN AGE > 018 ALSO GENDER = 'F'                         
             DISPLAY 'THE GIRL IS MAJOR  '                       
        WHEN AGE <= 018 ALSO GENDER = 'M'                         
             DISPLAY 'THE BOY IS MINOR   '                        
        WHEN AGE <= 018 ALSO GENDER = 'F'                         
             DISPLAY 'THE GIRL IS MINOR  '                        
        WHEN OTHER                                                
             DISPLAY 'INVALID INPUT      '                        
     END-EVALUATE.                                                
     STOP RUN.