View previous topic :: View next topic
|
Author |
Message |
sijayapal
New User
Joined: 23 Dec 2008 Posts: 69 Location: India
|
|
|
|
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 |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
sijayapal
New User
Joined: 23 Dec 2008 Posts: 69 Location: India
|
|
|
|
That answers my question
Thanks robert. |
|
Back to top |
|
|
jctgf Currently Banned Active User
Joined: 04 Nov 2006 Posts: 109
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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)
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 |
|
|
jctgf Currently Banned Active User
Joined: 04 Nov 2006 Posts: 109
|
|
|
|
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 |
|
|
sijayapal
New User
Joined: 23 Dec 2008 Posts: 69 Location: India
|
|
|
|
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.
Thanks
Sija |
|
Back to top |
|
|
sijayapal
New User
Joined: 23 Dec 2008 Posts: 69 Location: India
|
|
|
|
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 |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
Quote: |
(Hint: Never say NEVER) |
You just did Bill. |
|
Back to top |
|
|
|