cobol

Move to variables with same name


My Cobol structure:

01. MyData.
    02. Corp-Entity
        03. Corp-Branch1.
            04. Address.
                05. AddressLine1 PIC X(20).
                05. AddressLine2 PIC X(20).
                05. PostalCode   PIC 9(05).
    02. PIC-Entity.
        03. Address.
            04. AddressLine1 PIC X(20).
            04. AddressLine2 PIC X(20).
            04. PostalCode   PIC 9(05).

I have the data to move in Address of Corp-Entity and another data to move in Address of PIC-Entity

But when I try to move the value

move valueAddressLine1 to AddressLine1 
                       of Address
                       of PIC-Entity

Error Message:

"AddressLine1 of Address of PIC-Entity" was not a uniquely defined name.
The definition to be used could not be determined from the context. The reference to the name was discarded.

How to move 'valueAddressLine1' to AddressLine1 of Address of PIC-Entity?


Solution

  • You can change it to:

    move valueAddressLine1 to AddressLine1 
                       in Address
                       in PIC-Entity
                       in MyData
    

    most likely you have PIC-Entity that has same structure somewhere else outside MyData definition.