2

In this code, I'd like to ACCEPT and DISPLAY the 01 level D variable. While the 05 level D is easy, D OF F, is there a way to specify the 01 level D?

The obvious solution is “just change the variable name”, but hoping there's a better way!

IDENTIFICATION DIVISION.
    PROGRAM-ID. DISAMBIGUATION-ISSUE.
DATA DIVISION.
    WORKING-STORAGE SECTION.
    01 D VALUE PIC 9(8). 
    01 F.
        05 Y PIC 9(4).
        05 M PIC 9(2).
        05 D PIC 9(2).
PROCEDURE DIVISION.
*> Errors here, D is ambiguous
    ACCEPT D.
    DISPLAY "Date: " D.
STOP RUN.
Simon Sobisch
  • 6,263
  • 1
  • 18
  • 38
Yimin Rong
  • 1,890
  • 4
  • 31
  • 48

1 Answers1

6

I'm afraid the only way in this circumstance is to change the variable name or to make the 01-level D into a subordinate item, e.g.

 01  D-rec.
     03  D PIC 9(8).
 ...
     DISPLAY D IN D-rec
Edward H
  • 576
  • 3
  • 8