Page 1 of 1

DCLGEN and COBOL question.

Posted: Mon Nov 23, 2015 3:17 pm
by Manohar Pandit
Another which I face goes like this, if i have a DCLGEN member called DCLMEM. I will use this in my program as

Code: Select all

EXEC SQL 
      INCLUDE DCLMEM 
END-EXEC.
Q1. Can we write the equivalent of the DCLGEN DCLMEM in cobol terms instead of using

Code: Select all

EXEC SQL 
      INCLUDE DCLMEM 
END-EXEC.
Q2. If yes, then what is the difference of using DCLGEN member instead of direct declarations? DCLGEN is a waste?

Re: DCLGEN and COBOL question.

Posted: Mon Nov 23, 2015 5:13 pm
by nicc
Yes you can - but why would you? Isn't it much simpler and quicker to simply include code that is correct and up-to-date without the risk of mis-typing something? Do you really want to type in all your copybook contents instead of just copying them? Your DCLGEN member is simply a copybook member.

Re: DCLGEN and COBOL question.

Posted: Sat Dec 12, 2015 10:05 pm
by Manohar Pandit
I could not ask this way to an interviewer. But I think answer is that it saves from copying all the contents manually.

Re: DCLGEN and COBOL question.

Posted: Sun Dec 13, 2015 10:27 am
by zprogrammer
Also what if you need to change the DCLGEN member value there is a possibility the direct declarations could be missed in direct declarations

Re: DCLGEN and COBOL question.

Posted: Fri Dec 18, 2015 4:30 pm
by Manohar Pandit
Pandora-Box wrote:Also what if you need to change the DCLGEN member value there is a possibility the direct declarations could be missed in direct declarations
I am sorry what are you saying? I did not understand this.

Re: DCLGEN and COBOL question.

Posted: Fri Dec 18, 2015 5:04 pm
by nicc
I guess, from carefully reading what Pandor-Box wrote, that what is being said is that if you do not use the pre-compiler generated copybook but use a hand-crafted copybook then, if the pre-compiler creates an updated copybook the change may not be noticed and therefor not made to the hand-crafted copybook leading to processing errors/failure.

Re: DCLGEN and COBOL question.

Posted: Sun Dec 20, 2015 5:36 pm
by Manohar Pandit
nicc wrote:I guess, from carefully reading what Pandor-Box wrote, that what is being said is that if you do not use the pre-compiler generated copybook but use a hand-crafted copybook then, if the pre-compiler creates an updated copybook the change may not be noticed and therefor not made to the hand-crafted copybook leading to processing errors/failure.
I could never understand it from what was posted. Thanks for your efforts. But I still feel a better answer can be there for this question, if I again face it in an interview.. :evil:

Re: DCLGEN and COBOL question.

Posted: Mon Dec 21, 2015 1:35 pm
by Anuj Dhawan
As such you can use a COBOL equivalent copybook instead of DCLGEN member, compiler does not stop you, pre-compiler does not stop you. But you are introducing more maintenance work for yourself,in future. Another mistake which might happen is you might end up using COPY statement for the DCLGEN equivalent copybook and if you do use COPY to expand DB2 DCLGEN members, your program will fail at pre-compilation stage as all the host variables are not defined. This happens because COPY members will get expanded only at Compilation stage and not at Pre-compilation.

Re: DCLGEN and COBOL question.

Posted: Mon Dec 28, 2015 3:09 pm
by Manohar Pandit
Anuj Dhawan wrote:As such you can use a COBOL equivalent copybook instead of DCLGEN member, compiler does not stop you, pre-compiler does not stop you. But you are introducing more maintenance work for yourself,in future. Another mistake which might happen is you might end up using COPY statement for the DCLGEN equivalent copybook and if you do use COPY to expand DB2 DCLGEN members, your program will fail at pre-compilation stage as all the host variables are not defined. This happens because COPY members will get expanded only at Compilation stage and not at Pre-compilation.
So basically there is no harm in using it but it can create problems, that is what the gist of it.

Re: DCLGEN and COBOL question.

Posted: Mon Dec 28, 2015 3:26 pm
by Anuj Dhawan
Can I drive a car at 300 km/hr?

The answer is yes, you can. Your mileage (Yes, you read it correct, Your mileage, not of car) may vary!

Is it advisable?

No! per traffic rules, per common sense - no, the answer is no.

Can I still do it?

Yes you can. Society has police. Shops have DBAs and Tech-Leads.

Re: DCLGEN and COBOL question.

Posted: Wed Dec 30, 2015 11:40 am
by Manohar Pandit
Anuj Dhawan wrote:Can I drive a car at 300 km/hr?

The answer is yes, you can. Your mileage (Yes, you read it correct, Your mileage, not of car) may vary!

Is it advisable?

No! per traffic rules, per common sense - no, the answer is no.

Can I still do it?

Yes you can. Society has police. Shops have DBAs and Tech-Leads.
Ha ha ha ...

You have taken it on heart...