Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Reg: Hard coding a cobol array.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sijayapal

New User


Joined: 23 Dec 2008
Posts: 69
Location: India

PostPosted: Wed Sep 30, 2009 5:10 pm    Post subject: Reg: Hard coding a cobol array.
Reply with quote

Hi all,

I work for a performance tuning task. There is a file used by a cobol program which has only 18 records. I need to remove this file since this is not updated in the past 10 years of time. I need to hard code the values into an Array. I am bit confused with the syntax. Is it possible to give values in occurs clause of working storage section itself??

Please help me with the syntax.. i will be greatful...
Back to top
View user's profile Send private message

guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Wed Sep 30, 2009 5:15 pm    Post subject:
Reply with quote

Hello Sija,

Yes Values can be given in occurs clause ...but to provide better solution please specify the declaration of your array variable & value?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7999
Location: Bellevue, IA

PostPosted: Wed Sep 30, 2009 5:19 pm    Post subject:
Reply with quote

Code up FILLER elementary variables with the VALUE clauses, use a REDEFINES on the group variable and the OCCURS is on the REDEFINES variable.
Code:
05  TABLE-ITEMS.
    10  FILLER PIC X(20) VALUE 'ABCDEFGHIJKLMNOPQRST'.
    10  FILLER ...
05  TABLE-VALUES REDEFINES TABLE-ITEMS
                 OCCURS 18
                 PIC X(05).
Back to top
View user's profile Send private message
sijayapal

New User


Joined: 23 Dec 2008
Posts: 69
Location: India

PostPosted: Wed Sep 30, 2009 7:32 pm    Post subject:
Reply with quote

That answers my question icon_smile.gif
Thanks robert.
Back to top
View user's profile Send private message
jctgf
Currently Banned

Active User


Joined: 04 Nov 2006
Posts: 109

PostPosted: Wed Sep 30, 2009 7:56 pm    Post subject:
Reply with quote

Hi,
Why not to read this small file and load it into the array at the beginning of the processing? It would amount to have the array the way you want now, but with the advantage of keeping the data separate from the code.
Imagine that you can accidently change the content of this small array during any maintenance you're going to make in this program.
Here, we try to keep every single piece of data away from the code, no matter if it's a single constant. We don't have performance problems because we load all the variables at the beginning of the processing.
Just an opinion.
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: Wed Sep 30, 2009 8:08 pm    Post subject:
Reply with quote

Hello,

Quote:
Why not to read this small file and load it into the array at the beginning of the processing
I agree - better to keep the "data" out of the "code".

Also, as often happens, someone will identify a need to run with a different set of values (either one-time or permanently). . . If the data is external, a new set of this data could be created more easily than changing/promoting the code.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Sep 30, 2009 8:47 pm    Post subject: Reply to: Reg: Hard coding a cobol array.
Reply with quote

I'm all for Dynamic Arrays, defined to LINKAGE, with the necessary storage allocated based upon (LRECL * NBR-OF-RECORDS) + 4 (the 4 is for the OCCURS DEPENDING ON fullword at the beginning of the ARRAY).

EG:
Code:

01  LS-DYNAMIC-TBL-REC.
    03  LS-DYNAMIC-NBR-ENTRIES PIC  9(008) COMP.
    03  LS-DYNAMIC-ENTRIES     OCCURS 1 TO 1000 TIMES
                               DEPENDING ON LS-DYNAMIC-NBR-ENTRIES
                               INDEXED BY X-LS-DE, X-LS-DE-MAX
                               PIC  X(???).


Is this a QSAM or VSAM file?

Can you be guaranteed that they'll never be more than 18 records in this file?

(Hint: Never say NEVER) icon_wink.gif

I'm specifying 1000 as the maximum number of records that you'll ever have, just as a failsafe. This can be adjusted by you as needed.

Index X-LS-DE-MAX will be set by you, based upon the NBR-OF-RECORDS and used as the high-water mark, avoiding a S0C4.

Also, if your compiler supports COMP-5, then change LS-DYNAMIC-NBR-ENTRIES to COMP-5, which is "Native Binary".

You would use LE Callable Service routines "CEEGTST" to obtain the Dynamic Storage and "CEEFRST" to free the Dynamic Storage or, the Storage will be implicitly freed at step termination.

Bill
Back to top
View user's profile Send private message
jctgf
Currently Banned

Active User


Joined: 04 Nov 2006
Posts: 109

PostPosted: Wed Sep 30, 2009 9:00 pm    Post subject:
Reply with quote

Bill,
I find your suggestion VERY interesting. I think I've read another reply from you in this forum in which you mention the use of a dynamic array.
Could you please provide more examples of how to use it (a piece of code, if possible)?
However, I have a question: if you define the maximum occurrence of your array (depending on...) it isn't a dynamic array truly, isn't it? I mean, you have a limit (in your post, it would be 1000) that will be set during compiling time.
During execution time, it would be impossible to go over this limit, right?
Thanks.
Back to top
View user's profile Send private message
sijayapal

New User


Joined: 23 Dec 2008
Posts: 69
Location: India

PostPosted: Mon Oct 05, 2009 11:31 am    Post subject:
Reply with quote

Hi JCTGF,

U r idea is good and i also thought of the same initially. But the problem here is that the program is a called module. This program is called by more than 1000times. So this idea wont fit here. I want to completely eliminate the I/O. Every one agreed for the hardcoding since the data is not changed for more than 10years of time.

Bill,

I agree your point. I cannot say never here. After consulting with the concerned team i will allocate the space accordingly. And also if they want to add any values.. they need to change the program. Even at that time the table size can be modified. So it wont be a big bottle neck as of now. icon_biggrin.gif


Thanks
Sija
Back to top
View user's profile Send private message
sijayapal

New User


Joined: 23 Dec 2008
Posts: 69
Location: India

PostPosted: Mon Oct 05, 2009 1:09 pm    Post subject:
Reply with quote

Dick,

Usually we keep the data out of the code. But here in this case considering the amount of effort to change now as well as in future.. we find it better to keep the values inside the code.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Mon Oct 05, 2009 8:11 pm    Post subject:
Reply with quote

Quote:
(Hint: Never say NEVER)
You just did Bill. 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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts RULES(NOEVENPACK) in cobol jackzhang75 COBOL Programming 5 Wed Mar 29, 2017 12:47 am
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Execute TSO ACF commands from COBOL-I... supreethi.srid TSO/ISPF 0 Tue Feb 21, 2017 5:19 pm
No new posts Mainframe Interview Questions CICS,CO... akshathan Mainframe Interview Questions 6 Thu Feb 09, 2017 6:38 pm
No new posts Submit job from Cobol with input data abdulrafi COBOL Programming 4 Wed Feb 01, 2017 12:41 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us