Home      Mainframe Forum      Mainfarme Tutorials      IBM Manuals      Mainframe Interview Questions      Mainframe Books      IT News     SiteMap     Downloads


     
 
MAINFRAME - TIP OF THE DAY : All available storage is assigned to the job or jobstep, If REGION is coded 0K or 0M

Google
 
Web mainframegurukul.com

using Index other than subscript

 
Post new topic   Reply to topic    mainframegurukul.com Forum Index -> COBOL
  View previous topic :: View next topic  
Author Message
venkatreddy.com
Member


Joined: 24 Nov 2007
Posts: 3

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Sat Nov 24, 2007 2:20 pm    Post subject: using Index other than subscript Reply with quote

Hi All,

while handling Arrays/tables in cobol, we can either use subscript or Index. more over we can do Search or search ALL(which needs index) using subscript too using perform verbs. but will you please tell me that something for which we have to use Index and cannot be done using subscript. ( not relating to any performance issues)

thanks,
Venkat
Back to top
View user's profile Send private message Send e-mail
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.

Shivankoo
Member


Joined: 13 Dec 2010
Posts: 14

Answer was approved by Question owner.
Useful Post
-1 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Sat Sep 29, 2012 8:35 am    Post subject: Reply with quote

Did you find your answer?
_________________
Thanks and Regards
Shivankoo Sharma

//EMPIRE EXEC PGM=WIFE
//SYSIN DD DSN=VARSHA.ME.HOME,DISP=SHR
//SYSOUT DD DUMMY
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
William Collins
Active Member


Joined: 24 May 2012
Posts: 714

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Sat Sep 29, 2012 12:58 pm    Post subject: Reply with quote

After four years and 11 months (or so) I think they are no longer waiting on "tenter hooks" Smile

I'd go for
Code:

SET index-name TO +1


Can't do that with a subscript. Probably not the answer the TS wanted.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
chaat
Member


Joined: 18 Apr 2010
Posts: 18
Location: St. Cloud, Minnesota, USA

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Sun Dec 30, 2012 8:21 am    Post subject: Reply with quote

Venkatreddy,

I believe that the SEARCH ALL verb requires the use of an INDEX on the array to be searched.

Also indexes are MUCH more efficient than subscripts in all but some very limited situations dealing with arrays with only single byte entries.

Chuck H.
_________________
Chuck Haatvedt

email --> clastnameatcharterdotnet

(replace lastname, at, dot with appropriate
characters)
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
William Collins
Active Member


Joined: 24 May 2012
Posts: 714

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Sun Dec 30, 2012 3:05 pm    Post subject: Reply with quote

Venkatreddy point that out about the index for SEARCH ALL.

Define "MUCH", this is computing, after all. Only with single bytes? Can you show that?

I have a 9,999 entry table (which is what I assume you mean by "array"). Each entry in the table is 30 bytes long, accessed as three separate fields. Which do you determine would be "more efficient" to access this, an index or a subscript defined as COMP PIC 9(4)/S9(4)?
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
chaat
Member


Joined: 18 Apr 2010
Posts: 18
Location: St. Cloud, Minnesota, USA

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Tue Jan 01, 2013 12:00 am    Post subject: Reply with quote

William,

on an IBM Mainframe system using the Enterprise COBOL V4.2 compiler, the use of an index will generate more efficient code.

it should be pretty easy to create two small programs which each loop thru the array a million times and then compare the cpu time of the two.

see this manual...

http://www-01.ibm.com/support/docview.wss?uid=swg27018287

look at page 36
_________________
Chuck Haatvedt

email --> clastnameatcharterdotnet

(replace lastname, at, dot with appropriate
characters)
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
DikDude
Moderator


Joined: 22 Jul 2011
Posts: 1001
Location: usa

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
1 salutes

PostPosted: Tue Jan 01, 2013 1:18 am    Post subject: Reply with quote

Hi Chuck,

WC has done as you suggest multiple times over. . .

I believe there is some picking of nits going on Cool

d
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
William Collins
Active Member


Joined: 24 May 2012
Posts: 714

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Tue Jan 01, 2013 5:15 am    Post subject: Reply with quote

It may be nits Smile

But still, how "MUCH" is "MUCH"? The quote you give, shorn of its specific context, just says "more efficient". It's context, which I know without having to look, is of PIC S9(Cool binary, plus packed-decimal, plus DISPLAY.

What about the "single bytes"?

And the other specific question? I was wondering about your answer, Chuck - how "much"? Now we can access the entire table with a binary halfword. Three instructions for the subscript, two for the index, but the subscript is halfword, the index always fullword. You still going for "MUCH" faster?
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
chaat
Member


Joined: 18 Apr 2010
Posts: 18
Location: St. Cloud, Minnesota, USA

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Tue Jan 01, 2013 1:13 pm    Post subject: Reply with quote

from the Enterprise COBOL performance manual i quoted above. One of the factors which affect these results is how many times subscripted / indexed items are referenced in the code. The more references, the greater the savings. Also muliple dimensioned arrays will also show a greater savings.

ps.. the rationale behind the array with entries which are only 1 byte long is that when the compiler is calculating the displacement, it doesn't have to multiply the subscript times the entry length so effectively it functions very similar to an index.

Indexes vs Subscripts
Using indexes to address a table is more efficient than using subscripts since the index already contains the
displacement from the start of the table and does not have to be calculated at run time. Indexes are defined
using the INDEXED BY phrase of the OCCURS clause for the data item. Subscripts, on the other hand,
contain an occurrence number that must be converted to a displacement value at run time before it can be
used. When using subscripts to address a table, use a binary (COMP) signed data item with eight or fewer
digits (for example, using PICTURE S9(Cool COMP for the data item). This will allow fullword arithmetic to
be used during the calculations. Additionally, in some cases, using four or fewer digits for the data item may
also offer some added reduction in CPU time since halfword arithmetic can be used.
Performance considerations for indexes vs subscripts (PIC S9(Cool):
|
Using binary data items (COMP) to address a table is 40% slower than using indexes
|
Using packed decimal data items (COMP-3) to address a table is 220% slower than using indexes
|
Using DISPLAY data items to address a table is 300% slower than using indexes
_________________
Chuck Haatvedt

email --> clastnameatcharterdotnet

(replace lastname, at, dot with appropriate
characters)
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
William Collins
Active Member


Joined: 24 May 2012
Posts: 714

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Tue Jan 01, 2013 1:31 pm    Post subject: Reply with quote

Leaving the other stuff for now then, we at least have a quantity for "MUCH". The 40% that you quote. With the halfword subscripts not "much" slower indexes?
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
academyindia4
Guest





Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Fri Jan 15, 2016 8:55 pm    Post subject: Topic deleted by Admin Reply with quote

<< Content deleted By Admin >>
Back to top
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
lnpdavid
Member


Joined: 28 Apr 2009
Posts: 11
Location: Missouri USA

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Fri Jan 22, 2016 9:54 pm    Post subject: Reply with quote

Let me add to the "much" answer.

If you have a table that is indexed and the key to the table is in sequence you will be able to do a SEARCH ALL on the table. Assume, for that the table contains 1,000,000 entries. (yes, that might unreasonable, but go with it for a minute) Doing a SEARCH ALL on the table will only look at 20 entries to determine if what you're looking up in the table is there or not. You've only coded one verb (the SEARCH).

If you're using subscripting you'll have to code your own routine to do the same binary search, with the possibility of making coding mistakes.

If you just do a sequential search on the same table you'll have to do an average of 500,000 comparisons to find, or not find, what you're looking for. Let's see 20 vs 500,000??? I'd say that would be MUCH faster.
_________________
David Earhart
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
academyindia4
Guest





Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Sun Jan 24, 2016 12:05 am    Post subject: Topic deleted by Admin Reply with quote

<< Content deleted By Admin >>
Back to top
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Display posts from previous:   
Post new topic   Reply to topic    mainframegurukul.com Forum Index -> COBOL All times are GMT + 5 Hours
Page 1 of 1



 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Related topics
 Topics   Replies   Author   Views   Last Post 
No new posts EZtrv+ - Is there a way to suppress ez-code from printing... 5 seagreg 11386 Mon Feb 01, 2016 1:39 am
academyindia4 View latest post
No new posts Reg DFSORT utility. 5 ursvmg 18134 Mon Feb 01, 2016 1:38 am
academyindia4 View latest post
No new posts test datase empty 8 nick.mamone 16632 Mon Feb 01, 2016 1:38 am
academyindia4 View latest post
No new posts Xpeditor use in batch process 4 nanda_cse 15743 Wed Jan 27, 2016 8:56 pm
academyindia4 View latest post
No new posts thanks 0 chintu 5726 Wed Oct 24, 2007 7:06 pm
chintu View latest post
 


Cobol Tutorial
This cobol tutorial covers most of the important topics like STRING, UNSTRING, COMP, COMP-3.....
DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. Explains in simple language. Some Chapters are locked, Forum members have free access to these chapters
CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming...
JCL Tutorial
This is most popular JCL tutorial from mainframegurukul. It does contain important jcl ....
SORT Tutorial
This Tutorial covers all important aspects of DFSORT. Has more SORT examples
INTERVIEW Questions
This page covers important interview questions
Mainframe Jobs
Mainframe Jobs posted by members of mainframegurukul forum
FaceBook Page
MainframeGurukul FaceBook Page
LinkedIn Page
MainframeGurkul Linkedin Page

This widget requires Flash Player 9 or better







Go to top of the page
 

Online ABEND Reference ||  JCL References ||  COBOL References ||  VSAM References ||  Tutorials by Drona Series ||  SQL tutorial ||  BOOKS  ||  DB2 INTERVIEW QUESTIONS ||  COBOL INTERVIEW QUESTIONS  ||  JCL INTERVIEW QUESTIONS ||  JCL2 INTERVIEW QUESTIONS ||  VSAM INTERVIEW QUESTIONS ||  CICS INTERVIEW QUESTIONS  ||  Online tutorials ||  Online ABEND Reference ||  JCL References ||  COBOL References ||  VSAM References ||  Tutorials by Drona Series ||  SQL tutorial ||  BOOKS  ||  SiteMap  ||  Expeditor Tutorial  ||  FILE-AID Tutorial  ||  Changeman Tutorial  ||  COBOL   ||  DB2   ||  JCL  ||  CICS  ||  VSAM  ||  DB2 Interview Questions ( 110 )   || Simple JCL Tutorials  || JCL Tutorial from MainframeGurukul.com   || Simple JCL Tutorial - Chapter1 ;|| Mainframe Forum - Tutorials  || Mainframe Tutorials || Mainframe CICS tutorial|| Mainframe COBOL Tutorial

Drona Educational Forums - Mainframe Cobol DB2 CICS Board
Powered by phpBB

mainframetopic-3148.html