Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
About memory allocation of tables

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
View previous topic :: :: View next topic  
Author Message
Lavanya_Dhushetty
Warnings : 2

New User


Joined: 30 Aug 2007
Posts: 24
Location: Chennai

PostPosted: Fri Sep 14, 2007 10:06 am    Post subject: About memory allocation of tables
Reply with quote

See the following table definition:

01 WS-TABLE.
05 WS-VAR-A PIC X(2) OCCURS 1 to 90 TIMES DEPENDING ON WS-D.

If WS-D is 50 how much memory will be used by this table?

Answers:
a.180 Bytes
b.90 Bytes
c.COBOL will allocate depending on the availability of the memory
d.100 Bytes
e.182 Bytes
Back to top
View user's profile Send private message

agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Fri Sep 14, 2007 11:15 am    Post subject:
Reply with quote

Answer a.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Fri Sep 14, 2007 11:19 am    Post subject:
Reply with quote

COBOL will allocate maximum memory that can an OCCURS DEPENDING ON table can occupy. I hope you are clear with the answer now.. icon_smile.gif

This can be confusing but it is the fact. Dynamic memory allocation is not very easy in COBOL.
Back to top
View user's profile Send private message
Lavanya_Dhushetty
Warnings : 2

New User


Joined: 30 Aug 2007
Posts: 24
Location: Chennai

PostPosted: Fri Sep 14, 2007 11:40 am    Post subject: Reply to: About memory allocation of tables
Reply with quote

How it could be A???????Can U please explain it???
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Fri Sep 14, 2007 11:54 am    Post subject:
Reply with quote

Abhijit,

Go thru the following link -

http://publib.boulder.ibm.com/infocenter/iadthelp/v7r0/index.jsp?topic=/com.ibm.etools.iseries.langref.doc/c0925395765.htm

Sample quote from the link -

Quote:
The length of TABLE-1 is calculated by multiplying the contents of COUNTER-1 (the number of occurrences of RECORD-1) by 3 (the length of RECORD-1).
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Fri Sep 14, 2007 12:35 pm    Post subject:
Reply with quote

Lavanya, I have already given the explanation. This much explantion should be enough for an interview question. I told you this can be confusing, as your experience will grow then things will be clearer to you.

One more thing, I was actually expecting question like 'What is advantage of occurs depending on if it allocates max memory?'
Here is the key-
You don't save memory in program, but when you write record to file, you will save those bytes. Let me know if you have any further question.

Murali,
Question was about memory allocation I guess. Not about calculating length of field. COBOL does not dynamically allocate memory for occurs depending on.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Fri Sep 14, 2007 1:45 pm    Post subject: Re: Reply to: About memory allocation of tables
Reply with quote

Lavanya_Dhushetty wrote:
How it could be A???????Can U please explain it???

What should be the answer accroding to you ?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Sep 14, 2007 8:54 pm    Post subject:
Reply with quote

Hello,

Quote:
How it could be A???????Can U please explain it???


Quote:
PIC X(2) OCCURS 1 to 90 TIMES

How could the length be anything other than 180 (2x90)?
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Sep 14, 2007 9:22 pm    Post subject:
Reply with quote

dick scherrer wrote:
Hello,

Quote:
How it could be A???????Can U please explain it???


Quote:
PIC X(2) OCCURS 1 to 90 TIMES

How could the length be anything other than 180 (2x90)?


The amount of memory allocated for the table would be 180 but the amount used would be 100 (2 x 90 and 2 x 50). The extra 80 bytes would be wasted since it can not be reallocated.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Sep 14, 2007 9:43 pm    Post subject:
Reply with quote

Hello,

I believe that (unlike dasd) when space is allocated by a load module it is also used. Those bytes are filled (just not referenced when the code runs).

I suppose the "right" answer to the original question depends on how the question was intended icon_smile.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Identify top 30 big tables or indexes... ashek15 DB2 0 Fri Jun 16, 2017 10:01 am
No new posts VSAM Space Allocation mrgnndhmk JCL & VSAM 7 Sat Apr 22, 2017 12:42 am
No new posts Data replication from multiple Db2 ta... kishpra DB2 9 Mon Mar 27, 2017 9:58 pm
No new posts SPUFI -- Joining 3 tables – data in... Sysaron DB2 2 Wed Mar 08, 2017 4:18 am
No new posts To know activities on db2 tables ashek15 DB2 4 Fri Mar 03, 2017 11:23 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us