What is the output generated by the following code?
01 GRP-I.
05 SUBFLD1 PIC XX VALUE "AB".
05 FILTER PIC X(6) VALUE SPACES.
01 GRP-2 REDEFINED GRP-1.
05 SUB-FLD2 PIC XX.
05 SUB-FLD3 PIC XX.
05 FILTER PIC X(4).
IF SUB-FLD1 NOT = SPACES
DISPLAY "SUBFLD1"
MOVE "ABBCCD" TO GRP-1
IF SUB-FLD3 = SPACES
DISPLAY "SPACES"
ELSE
DISPLAY "SUBFLD3"
DISPLAY "END"
ELSE
DISPLAY "SPACES"
DISPLAY "END".
(a) SUBFLD1
SUBFLD3
END
(b) SPACES
END
(c) SUBFLD1
END
(d) SUBFLD1
SPACES

Answer Posted / vish

I doubt if we can code like IF ELSE ELSE....since no scope
terminatior (END-IF) has been given for the nested IF ELSE
so it should throw a compilation error. It can display the
output as (a) ONLY if the code is something like below:

01 GRP-1.
05 SUBFLD1 PIC XX VALUE "AB".
05 FILTER PIC X(6) VALUE SPACES.
01 GRP-2 REDEFINED GRP-1.
05 SUB-FLD2 PIC XX.
05 SUB-FLD3 PIC XX.
05 FILTER PIC X(4).
IF SUB-FLD1 NOT = SPACES
DISPLAY "SUBFLD1"
MOVE "ABBCCD" TO GRP-1
IF SUB-FLD3 = SPACES
DISPLAY "SPACES"
ELSE
DISPLAY "SUBFLD3"
DISPLAY "END"
END-IF
ELSE
DISPLAY "SPACES"
DISPLAY "END".

Please correct me if I am wrong.

Is This Answer Correct ?    5 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why did you choose to work with ibm mainframe cobol programming?

620


How arrays can be defined in COBOL?

654


What is the utilization of copybook in cobol?

646


Difference between cobol and cobol-ii?

695


Describe the cobol database components?

668






What is the difference between external and global variables in COBOL?

804


What are the cobol coding sheets?

655


IF I mention stop run in CICS what happens?

1883


What rules are followed by the search verb.

627


how do you reference the variable unblock file formats from cobol programs

732


What is the utilization of copybook in cobol? Could we utilize a similar copybook?

702


Write a program to enter and display the names of students in a class using the occurs clause.

640


What are literals?

621


example for sub strings ? and refernce modifications whit output pls

1832


Define cobol?

852