MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Tables or VSAM files

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
Fin
Beginner


Joined: 19 Jan 2004
Posts: 27
Topics: 8

PostPosted: Thu Aug 12, 2004 6:27 am    Post subject: Tables or VSAM files Reply with quote

I have been asked to consider changing how data is input to a program:
currently it is in a VSAM file (about 6000 records) and I've been asked about putting this data in a regular COBOL internal table -

the advantages I am aware of would be:
less input / output leading to better performance
less maintenance

the downside would be an un-indexed table that might be more difficult to search (with only 6000 records this should not be an issue?)

Are the points above correct / valid?
Is there anything else I should consider when making this design decision?

Thanks.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Thu Aug 12, 2004 7:34 am    Post subject: Reply with quote

Fin,

Are you planning to load the entire vsam record into internal table? If so what is the LRECL of the vsam file? If you are using a serial search (SEARCH) verb then it is going to affect the performance. If the current design is using a vsam file, what is the access mode and the file organization(ksds,rrds,esds)

If you are going to use an internal table, how are you planning to load the internal table? Are you going to hardcode the values , or read it from a file?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Mike Chantrey
Intermediate


Joined: 10 Sep 2003
Posts: 234
Topics: 1
Location: Wansford

PostPosted: Thu Aug 12, 2004 10:30 am    Post subject: Reply with quote

If it's a VSAM file you can load it up and it will be in key order, and you will be able to use the provided COBOL binary search facility (SEARCH ALL) which is very efficient - it should be <13 compares for locating any item by key, since 6000<(2^13) .
Back to top
View user's profile Send private message
Fin
Beginner


Joined: 19 Jan 2004
Posts: 27
Topics: 8

PostPosted: Fri Aug 13, 2004 5:20 am    Post subject: Reply with quote

The VSAM file is created in one program and used (accessed) in another program
that immediately follows it.

The Logical Record length is 7 (consisting of 2 fields, 6-byte + 1-byte).
The space attribute is defined as: SPACE=(7,(600,50),RLSE)
Organization - indexed
Access mode - random

The file is sorted on the 6-byte field.
It is then read into the program and a compare is done on the 6-byte field against a
field thats being read in separately.

The proposed change would be to write a flat file instead of a VSAM file,
create a COBOL table in the second program and read the data from the flat file into this.
Does this seem like a sensible approach?
The number of records varies every cycle (usually in the region of 6000 - 7000) - I would be
declaring a table to occur the maximum (probably 8000) records.

Thanks in advance for any advice.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Fri Aug 13, 2004 7:37 am    Post subject: Reply with quote

Fin,

The proposed change seems fine, as the data is less and the file is also sorted. you can use a binary search (SEARCH ALL) since the data is sorted.As Mike mentioned earlier,it is very efficient as it takes only <13 compares for locating any item by key, since 8000<(2^13= 8192) .

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Fin
Beginner


Joined: 19 Jan 2004
Posts: 27
Topics: 8

PostPosted: Fri Aug 13, 2004 7:42 am    Post subject: Reply with quote

Kolusu, Mike
Many thanks!
Back to top
View user's profile Send private message
Fin
Beginner


Joined: 19 Jan 2004
Posts: 27
Topics: 8

PostPosted: Tue Nov 16, 2004 5:24 am    Post subject: Reply with quote

Hi - just wondering if anyone can figure this out - after changing from VSAM to internal table the job took 3 times the CPU time to run...no other changes made, just change from VSAM to table.
Thanks.
Back to top
View user's profile Send private message
powerhawk
Beginner


Joined: 08 Nov 2004
Posts: 28
Topics: 4
Location: Stockholm

PostPosted: Tue Nov 16, 2004 6:53 am    Post subject: Reply with quote

Is the table sorted in ascending key field order? It must be! And you must use SEARCH ALL. The table is quite easy to sort also after it has been loaded from the VSAM file. I can give you code for that, not the best made but it works. I also recommend you to use a variable table using OCCURS DEPENDING ON, the SEARCH ALL instruction works better with varialbe tables, and use a huge max occurs value for the table like 20.000. And of course a nice error handling if the entire table is filled up during execution. I have code for all this if you want.
Back to top
View user's profile Send private message Send e-mail
Fin
Beginner


Joined: 19 Jan 2004
Posts: 27
Topics: 8

PostPosted: Tue Nov 16, 2004 7:07 am    Post subject: Reply with quote

i'd really appreciate if you could show me the code...many thanks for the helpful advice.
Back to top
View user's profile Send private message
powerhawk
Beginner


Joined: 08 Nov 2004
Posts: 28
Topics: 4
Location: Stockholm

PostPosted: Tue Nov 16, 2004 7:54 am    Post subject: Reply with quote

Here is sample code:
Code:

*
***                  *** THE TABLE AND OTHER VARIABLES
*
     05 FSALLMJ-WORK-LKFTABELL.
        07 FSALLMJ-I-TOPLKF        PIC S9(4) COMP.
        07 FSALLMJ-I-MAXLKF        PIC S9(4) COMP VALUE 20000.
        07 FSALLMJ-WORK-LKFENTRY   OCCURS 1 TO 20000 TIMES
                    DEPENDING ON FSALLMJ-I-TOPLKF
                    ASCENDING KEY FSALLMJ-WORK-LKF
                    INDEXED BY FSALLMJ-I-LKF FSALLMJ-I-LKF2.
          09 FSALLMJ-WORK-LKF      PIC X(6).
     05 FSALLMJ-R-BYT              PIC 9(9) COMP.
*
***                  *** FILL THE TABLE
*
        PERFORM LK700-IO-GET-NEXT
        PERFORM UNTIL NOT LK700-IO-OK
           IF FSALLMJ-I-TOPLKF = FSALLMJ-I-MAXLKF
              <FULL TABLE, ERROR HANDLING HERE>
           ELSE
              ADD 1 TO FSALLMJ-I-TOPLKF
              MOVE LK700-LKFKOD TO FSALLMJ-WORK-LKF(FSALLMJ-I-TOPLKF)
           END-IF
           PERFORM LK700-IO-GET-NEXT
        END-PERFORM
*
***                  *** SORT THE TABLE
*
        MOVE 99 TO FSALLMJ-R-BYT
        PERFORM UNTIL FSALLMJ-R-BYT = ZERO
           MOVE ZERO TO FSALLMJ-R-BYT
           SET FSALLMJ-I-LKF TO 1
           SET FSALLMJ-I-LKF2 TO 2
           PERFORM UNTIL FSALLMJ-I-LKF2 > FSALLMJ-I-TOPLKF
              IF FSALLMJ-WORK-LKF(FSALLMJ-I-LKF) > FSALLMJ-WORK-LKF(FSALLMJ-I-LKF2)
                 MOVE FSALLMJ-WORK-LKF(FSALLMJ-I-LKF) TO FSALLMJ-S-LKF
                 MOVE FSALLMJ-WORK-LKF(FSALLMJ-I-LKF2) TO FSALLMJ-WORK-LKF(FSALLMJ-I-LKF)
                 MOVE FSALLMJ-S-LKF TO FSALLMJ-WORK-LKF(FSALLMJ-I-LKF2)
                 ADD 1 TO FSALLMJ-R-BYT
              END-IF
              SET FSALLMJ-I-LKF UP BY 1
              SET FSALLMJ-I-LKF2 UP BY 1
           END-PERFORM
        END-PERFORM
*
***                  *** SEARCH THE TABLE
*
        MOVE JP210-LKFJ TO FSALLMJ-S-LKF
        MOVE ZERO TO FSALLMJ-S-LKF(5:2)
        SET FSALLMJ-I-LKF TO 1
        SEARCH ALL FSALLMJ-WORK-LKFENTRY
        AT END
           <CAN'T FIND THE VALUE IN THE TABLE, ERROR HANDLING HERE>
        WHEN FSALLMJ-WORK-LKF(FSALLMJ-I-LKF) = FSALLMJ-S-LKF
           <FIND THE VALUE IN THE TABLE, DO SOMETHING NICE HERE>
        END-SEARCH
Back to top
View user's profile Send private message Send e-mail
powerhawk
Beginner


Joined: 08 Nov 2004
Posts: 28
Topics: 4
Location: Stockholm

PostPosted: Tue Nov 16, 2004 8:05 am    Post subject: Reply with quote

All used variables are not defined in the sample above. I think you will understand how the code works anyway.
Back to top
View user's profile Send private message Send e-mail
Fin
Beginner


Joined: 19 Jan 2004
Posts: 27
Topics: 8

PostPosted: Tue Nov 16, 2004 8:31 am    Post subject: Reply with quote

yes, i am able to follow and will build my code around your sample...thanks a million.
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Wed Nov 17, 2004 11:40 am    Post subject: Reply with quote

Just two things, if you think paranoid.

VSAM KSDS automatically ensures sorted records and non-duplicates. If you are 100% sure of non-duplicates and sorted sequence from the program wrting to the (proposed) flat file, then it is OK. Else, a SORT step may help.
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming 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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group