When the DCLGEN variable are used?

All sort of Mainframes Interview Questions.
Post Reply
Meera Longe
Registered Member
Posts: 12
Joined: Tue Jan 19, 2016 10:32 am

When the DCLGEN variable are used?

Post by Meera Longe »

Hi,

Another interview question is this with whcih I need help.

When we write a COBOL DB2 program, we use DCLGNE in the program. When we include the DCLGEN in the program then are the variable taken into consideration at the time of pre-compilation or compilation?

I do not know answer. But I think it shouldbe at compilation time but do we have some place explaining it or someone can help me with an answer please.
Chandan Yadav
Website Team
Website Team
Posts: 70
Joined: Wed Jul 31, 2013 10:19 pm

Re: When the DCLGEN variable are used?

Post by Chandan Yadav »

All the copy books mentioned with INCLUDE taken into consideration during per-compilation and all the copy books mentioned with COPY are taken into consideration during compilation
Imran Lamba
Registered Member
Posts: 13
Joined: Tue Jan 19, 2016 11:49 am

Re: When the DCLGEN variable are used?

Post by Imran Lamba »

Chandan Yadav wrote: All the copy books mentioned with INCLUDE taken into consideration during per-compilation and all the copy books mentioned with COPY are taken into consideration during compilation
But DCLGEN has Cobol variables, if INCLUDE is used on precompile time...what is the use of DCLGEN in precompile ?
nicc
Global Moderator
Global Moderator
Posts: 691
Joined: Wed Apr 23, 2014 8:45 pm

Re: When the DCLGEN variable are used?

Post by nicc »

Have you ever looked at the output from the precompiler? If not then I suggest that you do and then, perhaps, it will become clear to you.
Regards
Nic
Imran Lamba
Registered Member
Posts: 13
Joined: Tue Jan 19, 2016 11:49 am

Re: When the DCLGEN variable are used?

Post by Imran Lamba »

I have seen the output of precompiler. But waht I wanted to say is, we use DCLGEN for COBOL equivialent variables of a Table. But precompiler will not check the COBOL declaration, so does precompile check for table-definition in DCLGEN?
Meera Longe
Registered Member
Posts: 12
Joined: Tue Jan 19, 2016 10:32 am

Re: When the DCLGEN variable are used?

Post by Meera Longe »

i also looked at DCLGEN.

Code: Select all

***** DCLGEN TABLE(DSN8A10.VPHONE)                                 ***
  *****        LIBRARY(SYSADM.TEMP.COBOL(VPHONEC))                   ***
  *****        QUOTE                                                 ***
  ***** ... IS THE DCLGEN COMMAND THAT MADE THE FOLLOWING STATEMENTS ***
           EXEC SQL DECLARE DSN8A10.VPHONE TABLE
           ( LASTNAME                       VARCHAR(15) NOT NULL,
             FIRSTNAME                      VARCHAR(12) NOT NULL,
             MIDDLEINITIAL                  CHAR(1) NOT NULL,
             PHONENUMBER                    VARCHAR(4) NOT NULL,
             EMPLOYEENUMBER                 CHAR(6) NOT NULL,
             DEPTNUMBER                     CHAR(3) NOT NULL,
             DEPTNAME                       VARCHAR(36) NOT NULL
           ) END-EXEC.
  ***** COBOL DECLARATION FOR TABLE DSN8A10.VPHONE                ******
       01  DCLVPHONE.
           10 LASTNAME.
              49 LASTNAME-LEN      PIC S9(4) USAGE COMP.
              49 LASTNAME-TEXT     PIC X(15).
           10 FIRSTNAME.
              49 FIRSTNAME-LEN     PIC S9(4) USAGE COMP.
              49 FIRSTNAME-TEXT    PIC X(12).
           10 MIDDLEINITIAL        PIC X(1).
           10 PHONENUMBER.
              49 PHONENUMBER-LEN   PIC S9(4) USAGE COMP.
              49 PHONENUMBER-TEXT  PIC X(4).
           10 EMPLOYEENUMBER       PIC X(6).
           10 DEPTNUMBER           PIC X(3).
           10 DEPTNAME.
              49 DEPTNAME-LEN      PIC S9(4) USAGE COMP.
              49 DEPTNAME-TEXT     PIC X(36).
  ***** THE NUMBER OF COLUMNS DESCRIBED BY THIS DECLARATION IS 7  ******
So basically precompiler will check all this from above definition:

Code: Select all

EXEC SQL DECLARE DSN8A10.VPHONE TABLE
           ( LASTNAME                       VARCHAR(15) NOT NULL,
             FIRSTNAME                      VARCHAR(12) NOT NULL,
             MIDDLEINITIAL                  CHAR(1) NOT NULL,
             PHONENUMBER                    VARCHAR(4) NOT NULL,
             EMPLOYEENUMBER                 CHAR(6) NOT NULL,
             DEPTNUMBER                     CHAR(3) NOT NULL,
             DEPTNAME                       VARCHAR(36) NOT NULL
           ) END-EXEC.

Is that correct?
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “Interview Questions.”