IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

About memory allocation of tables


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
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
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: 691
Location: Earth

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

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

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Fri Sep 14, 2007 11:19 am
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
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: 1436
Location: Bangalore,India

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

Abhijit,

Go thru the following link -

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: 691
Location: Earth

PostPosted: Fri Sep 14, 2007 12:35 pm
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

Superior Member


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

PostPosted: Fri Sep 14, 2007 1:45 pm
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

Moderator Emeritus


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

PostPosted: Fri Sep 14, 2007 8:54 pm
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
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

Moderator Emeritus


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

PostPosted: Fri Sep 14, 2007 9:43 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts CLIST - Virtual storage allocation error CLIST & REXX 5
No new posts Need to fetch data from so many DB2 t... DB2 9
No new posts Dynamic file allocation using JCL JCL & VSAM 8
No new posts How to: PK does not exist in several ... DB2 6
No new posts Access an specific memory address exp... COBOL Programming 1
Search our Forums:

Back to Top