Page 1 of 1

When the DCLGEN variable are used?

Posted: Tue Sep 06, 2016 3:24 pm
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.

Re: When the DCLGEN variable are used?

Posted: Wed Sep 07, 2016 5:03 pm
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

Re: When the DCLGEN variable are used?

Posted: Thu Sep 08, 2016 12:52 am
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 ?

Re: When the DCLGEN variable are used?

Posted: Thu Sep 08, 2016 2:09 am
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.

Re: When the DCLGEN variable are used?

Posted: Thu Sep 08, 2016 12:33 pm
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?

Re: When the DCLGEN variable are used?

Posted: Thu Sep 08, 2016 2:03 pm
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?