000010*---------------------------------------------------------------------- 000020* Date data is defined in this library. 000030*---------------------------------------------------------------------- 000040 01 XXX-DATE. 000050 02 XXX-YYYY PIC 9(4). 000060 02 XXX-MMDD. 000070 03 MM PIC 9(2). 000080 03 DD PIC 9(2).
<Source program>
000010 @OPTIONS MAIN 000020*---------------------------------------------------------------------- 000030* When expanding a copy library, partial character strings can also be 000035* replaced. 000040*---------------------------------------------------------------------- 000050 IDENTIFICATION DIVISION. 000060 PROGRAM-ID. SAMPLE. 000070 DATA DIVISION. 000080 WORKING-STORAGE SECTION. 000090*---------------------------------------------------------------------- 000100* The DISJOINING and JOINING phrases can be used to replace and expand 000110* partial character strings (words linked using a hyphen) of text words 000115* coded in a library. 000120*---------------------------------------------------------------------- 000130 COPY CP-SMPL2 DISJOINING XXX JOINING TODAY AS PREFIX. 000140 COPY CP-SMPL2 DISJOINING XXX JOINING BIRTHDAY AS PREFIX. 000150*---------------------------------------------------------------------- 000160 01 AGE PIC 9(3). 000170 PROCEDURE DIVISION. 000180 DISPLAY "When is your birthday? Example: 19690123 >>" 000185 WITH NO ADVANCING. 000190 ACCEPT BIRTHDAY-DATE. 000200 MOVE FUNCTION CURRENT-DATE TO TODAY-DATE. 000210 COMPUTE AGE = TODAY-YYYY - BIRTHDAY-YYYY. 000220 IF TODAY-MMDD < BIRTHDAY-MMDD THEN 000230 COMPUTE AGE = AGE - 1 000240 END-IF. 000250 DISPLAY " ". 000260 DISPLAY "You are " AGE " years old.". 000270 END PROGRAM SAMPLE.