Site icon TechTricky: A Technology Blog on HTML, CSS, JQuery, Webaps and How to\'s

COBOL DISPLAY Statement

COBOL DISPLAY Statement is used to Display the data on Output device. This is a procedure division statement and very useful to get the required data on output device.

Syntax:

DISPLAY identifier/Literal

Example  for Identifier 

DISPLAY WW-NAME

Example for Literal

DISPLAY "PROGRAM STARTED:"

Identifier & literal can be combined.

DISPLAY "Account Holder name is : " WW-NAME

It gets printed on output as  ‘Account Holder Name is : Mahender

IN batch Programs, generally the display statements gets printed in the spool and for Online programs, it gets printed in the CICS region spool.

Example Program:

016100 WORKING-STORAGE SECTION.
016200
016200 01 WW-NAME-DATE.
016200    05 WW-NAME PIC X(10) VALUE 'MAHENDER'.
016200    05 WW-TIMESTMP.
016200       07 WD-DATE PIC X(06) VALUE SPACES.
016200       07 WD-TIME PIC X(08) VALUE SPACES.
153700
153800 PROCEDURE DIVISION.
153900
           ACCEPT WD-DATE FROM DATE
           ACCEPT WD-TIME FROM TIME
154000     DISPLAY 'PROGRAM STARTED @ ' WW-TIMESTMP
154000     DISPLAY 'CUSTOMER NAME IS :' WW-NAME
           ACCEPT WD-DATE FROM DATE
           ACCEPT WD-TIME FROM TIME
154000     DISPLAY 'PROGRAM ENDED @ 'WW-TIMESTMP
155500
155600 STOP RUN.
155700

Output:

PROGRAM STARTED @ 19092605150946
CUSTOMER NAME IS :MAHENDER
PROGRAM ENDED @ 19092605150946

Here the program is very small and has no processing which takes some time, so that start & end times are same.

Using Multiple Identifiers:

When multiple variables are used under single disply, it gets printed in a single row.

016200 01 WK-NAME-ACNT.
016200      05 WK-NAME PIC X(10) VALUE 'MAHENDER'.
016200      05 WK-ACCOUNT PIC X(10) VALUE '123456 '.

DISPLAY 'CUSTOMER NAME and ACCOUNT :' WK-NAME WK-ACCOUNT

Output:

CUSTOMER NAME and ACCOUNT :MAHENDER 123456

Using Figurative Constants in Display

DISPLAY ZEROES
        HIGH-VALUES
        LOW-VALUES
        QUOTES

 

Refer MAINFRAMES Section for  ACCEPT verb detailed information. it is explained with examples. Also respond via comments if you feel any of the details are missing.

 

Exit mobile version
Close Bitnami banner
Bitnami