Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
Hi Hema Madhavi,
I believe you have missed the principals of move corresponding. First here is the content from the IBM COBOL manual for the CORRESPONDING phrase.
Quote:
The CORRESPONDING (CORR) phrase allows ADD, SUBTRACT, and MOVE operations
to be performed on elementary data items of the same name if the group
items to which they belong are specified.
Both identifiers following the keyword CORRESPONDING must name group
items. In this discussion, these identifiers are referred to as
identifier-1 and identifier-2.
A pair of data items (subordinate items), one from identifier-1 and one
from identifier-2, correspond if the following conditions are true:
° In an ADD or SUBTRACT statement, both of the data items are elementary
numeric data items. Other data items are ignored.
° In a MOVE statement, at least one of the data items is an elementary
item, and the move is permitted by the move rules.
° The two subordinate items have the same name and the same qualifiers
up to but not including identifier-1 and identifier-2.
° The subordinate items are not identified by the keyword FILLER.
° Neither identifier-1 nor identifier-2 is described as a level 66, 77,
or 88 item, nor is either described as a USAGE IS INDEX item. Neither
identifier-1 nor identifier-2 can be reference-modified.
° The subordinate items do not include a REDEFINES, RENAMES, OCCURS, or
USAGE IS INDEX clause in their descriptions.
However, identifier-1 and identifier-2 themselves can contain or be
subordinate to items containing a REDEFINES or OCCURS clause in their
descriptions.
x ° Neither identifier-1 nor identifier-2 nor the two subordinate items
x are described as USAGE IS POINTER items.
x ° Identifier-1 and/or identifier-2 can be subordinate to a FILLER item.
For example, if two data hierarchies are defined as follows:
Then, if ADD CORR ITEM-2 TO ITEM-1(X) is specified, ITEM-A and ITEM-A(X),
ITEM-B and ITEM-B(X), and ITEM-E and ITEM-E(X) are considered to be
corresponding and are added together. ITEM-C and ITEM-C(X) are not
included because they are not numeric. ITEM-D and ITEM-D(X) are not
included because ITEM-D(X) includes a REDEFINES clause in its data
description. ITEM-F and ITEM-F(X) are not included because they are
defined as USAGE IS INDEX. Note that ITEM-1 is valid as either
identifier-1 or identifier-2.
If any of the individual operations in the ADD CORRESPONDING statement
produces a size error condition, imperative-statement-1 in the ON SIZE
ERROR phrase is not executed until all of the individual additions are
completed.
In the MOVE CORRESPONDING you specify two group items as in the example below. The elemental items within the group item are ?CORRESPONDING?, basically, if the names are the same. Check the documentation for the exact CORRESPONDING rules.
Code:
01 GROUP-A.
05 A
05 B
05 D
05 E
01 GROUP-B.
05 A
05 B
05 C
05 E
MOVE CORRESPONDING GROUP-A TO GROUP-B.
Is equivalent to:
MOVE A OF GROUP-A TO A OF GROUP-B.
MOVE B OF GROUP-A TO B OF GROUP-B.
MOVE E OF GROUP-A TO E OF GROUP-B.
In the example above, when you do the MOVE CORRESPONDING GROUP-A to GROUP-B, nothing will be moved to D of GROUP-A because there is no ?CORRESPONDING? name in GROUP-B, and C of GROUP-B will not be moved because there is no ?CORRESPONDING? name in GROUP-A.