On Mon, Aug 11, 2014 at 8:37 PM, Ron Thomas <[email protected]> wrote:
> Hello.
>
> We have a array like this , what would be best way to initlaize this array
> in terms of performance ?
>
> 01 EXAMPLE-TABLE.
> 05 MY-TABLE.
> 10 TABLE-ENTRY OCCURS 9999 TIMES.
> 15 FIRST-NAME PIC X(15).
> 15 LAST-NAME PIC X(15).
> 15 SEX-CODE PIC X.
> 15 DOB.
> 20 DOB-YYYY PIC 9(4).
> 20 DOB-MM PIC 99.
> 20 DOB-DD PIC 99.
> 15 SSN PIC 9(9).
> 15 SALARY PIC S9(9)V99 COMP-3.
>
> Thanks
> Ron T
>
If you want to initialize it only once, just use the VALUE clause and
put it in WORKING-STORAGE. If it is in a subroutine and you want it
reinitialized every time the subroutine is CALL'ed, then use a VALUE
clause but put it in the LOCAL-STORAGE. WORKING-STORAGE is initialized
once per "run-unit" whereas LOCAL-STORAGE is initialized every time
the program is executed (via a CALL).
I don't recommend doing the following, but it will probably be the
fastest way, assuming you want to initialize it multiple times.
01 EXAMPLE-TABLE.
05 MY-TABLE.
10 TABLE-ENTRY OCCURS 9999 TIMES.
15 FIRST-NAME PIC X(15).
15 LAST-NAME PIC X(15).
15 SEX-CODE PIC X.
15 DOB.
20 DOB-YYYY PIC 9(4).
20 DOB-MM PIC 99.
20 DOB-DD PIC 99.
15 SSN PIC 9(9).
15 SALARY PIC S9(9)V99 COMP-3.
*
01 EXAMPLE-TABLE-I..
05 MY-TABLE-I.
10 TABLE-ENTRY-I OCCURS 9999 TIMES.
15 FIRST-NAME-I PIC X(15) VALUE SPACES.
15 LAST-NAME-I PIC X(15) VALUE SPACES.
15 SEX-CODE -I PIC X VALUE SPACES
15 DOB-I.
20 DOB-YYYY-I PIC 9(4) VALUE ZERO.
20 DOB-MM-I PIC 99 VALUE ZERO.
20 DOB-DD -I PIC 99 VALUE ZERO.
15 SSN-I PIC 9(9) VALUE ZERO.
15 SALARY-I PIC S9(9)V99 COMP-3. VALUE ZERO.
IF LENGTH OF EXAMPLE-TABLE IS NOT EQUAL TO LENGTH OF EXAMPLE-TABLE-I THEN
DISPLAY 'PROGRAM DEFINITION ERROR FOR EXAMPLE-TABLE.' UPON SYSOUT
DISPLAY 'PROGRAM ABORTING. KILL THE PROGRAMMER!' UPON SYSOUT
MOVE +16 TO RETURN-CODE
STOP RUN.
END-IF
MOVE EXAMPLE-TABLE-I TO EXAMPLE-TABLE
END-MOVE.
Of course, this has many drawbacks. The biggest being that you must
keep the EXAMPLE-TABLE and EXAMPLE-TABLE-I in sync. If you don't want
this worry, then use the VALUE clause like I showed above. And use the
sentence: INITIALIZE EXAMPLE-TABLE to reinitialize the table. From
what I have read, this is not CPU efficient. I don't know why.
--
There is nothing more pleasant than traveling and meeting new people!
Genghis Khan
Maranatha! <><
John McKown
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN