sign in
 
   
 
 
 
   
  COBOL TUTORIAL FOR BCA STUDENTS OF M G UNIVERSITY  
  UNIT 4: PROCEDURE DIVISION . . .  
   
  CORRESPONDING OPTION  
     
 

ADD and SUBTRACT CORRESPONDING

 
 

The CORRESPONDING option can also be used with the ADD and SUBTRACT verbs.

The following are the formats of these verbs with the CORRESPONDING option:

 
   
 

In the case of the ADD statement numeric elementary items in the group referred to by identifier-1 are added to and stored in the corresponding elementary items of the group named in identifier-2. In the case of the SUBTRACT statement, the corresponding numeric elementary items of the group referred to by identifier-1 are subtracted from and are stored in the corresponding numeric elementary items of the group referred to by identifier-2.

Example:


 
 

 
 

MOVE CORRESPONDING OLD-REC TO NEW-REC.

The data items are ITEM-1, ITEM-2, ITEM-3 and SEC-1 will take part in the operation. Note that SEC-21, THIRD-1 and THIRD-2 cannot take part in the operation. This is because although those names are common to both the groups, their qualifiers are different.

ADD CORRESPONDING OLD-REC TO NEWREC.

Only ITEM-1 and ITEM-2 will take part in the add operation. This is because ITEM-3 and SEC-1 in NEW-REC are not numeric data items.