DCLGEN and COBOL question.

All sort of Mainframes Interview Questions.
Post Reply
Manohar Pandit
New Member
Posts: 8
Joined: Wed Aug 06, 2014 4:54 pm

DCLGEN and COBOL question.

Post 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?
nicc
Global Moderator
Global Moderator
Posts: 691
Joined: Wed Apr 23, 2014 8:45 pm

Re: DCLGEN and COBOL question.

Post 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.
Regards
Nic
Manohar Pandit
New Member
Posts: 8
Joined: Wed Aug 06, 2014 4:54 pm

Re: DCLGEN and COBOL question.

Post 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.
zprogrammer
Global Moderator
Global Moderator
Posts: 588
Joined: Wed Nov 20, 2013 11:53 am
Location: Mars

Re: DCLGEN and COBOL question.

Post 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
zprogrammer
Manohar Pandit
New Member
Posts: 8
Joined: Wed Aug 06, 2014 4:54 pm

Re: DCLGEN and COBOL question.

Post 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.
nicc
Global Moderator
Global Moderator
Posts: 691
Joined: Wed Apr 23, 2014 8:45 pm

Re: DCLGEN and COBOL question.

Post 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.
Regards
Nic
Manohar Pandit
New Member
Posts: 8
Joined: Wed Aug 06, 2014 4:54 pm

Re: DCLGEN and COBOL question.

Post 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:
User avatar
Anuj Dhawan
Founder
Posts: 2802
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: DCLGEN and COBOL question.

Post 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.
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Manohar Pandit
New Member
Posts: 8
Joined: Wed Aug 06, 2014 4:54 pm

Re: DCLGEN and COBOL question.

Post 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.
User avatar
Anuj Dhawan
Founder
Posts: 2802
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: DCLGEN and COBOL question.

Post 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.
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Manohar Pandit
New Member
Posts: 8
Joined: Wed Aug 06, 2014 4:54 pm

Re: DCLGEN and COBOL question.

Post 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...
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.”