IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Can AIX as VSAM file be read dynamically?


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Apeksha

New User


Joined: 21 May 2008
Posts: 37
Location: Mumbai

PostPosted: Thu Jan 07, 2010 3:09 pm
Reply with quote

I want to read AIX file with dynamically as the full key is not available thru Input.

The SELECT statement used as

Code:
SELECT  AIX-IN      ASSIGN  TO  AIXFILE 
        ORGANIZATION   IS INDEXED           
        ACCESS MODE    IS DYNAMIC           
        RECORD KEY     IS AIX-PRM-KEY   
        FILE STATUS    IS WS-AIX-STAT.     

The layout defined for this AIX is

Code:
01 AIXIN-REC.                                                   
  03 AIXIN-LENGTH                             PIC S9(4) COMP.   
  03 AIXIN-REC-CNT                            PIC S9(4) COMP.   
  03 FILLER                                   PIC 9(01).
  03 AIXIN-PRM-KEY.                                             
     05 AIXIN-PRM-NUMBER                      PIC 9(06).       
     05 AIXIN-PRM-MEMID                       PIC X(11).       
     05 AIXIN-PRM-DATE                        PIC 9(08) COMP-3.
  03 AIXIN-DATA                               PIC X(2380).     

Thru input I can only pass values of AIXIN-PRM-NUMBER and AIXIN-PRM-MEMID. Reading with this key dynamically.

Code is
Code:

 INITIALIZE                  AIXIN-REC.               
 MOVE ZEROES              TO AIXIN-PRM-DATE.
 MOVE INPUT-OLD-MEMID     TO AIXIN-PRM-MEMID.     
 MOVE INPUT-NUMBER        TO AIXIN-PRM-NUMBER.   
                                                   
 START  AIX-IN                                 
        KEY IS >= AIXIN-PRM-KEY                   
 END-START.                                       
                                                   
 READ AIX-IN NEXT.


Here READ next is not fetching the desired record from FILE. The record is just holding the OLD-MEMID and NUMBER which is moved to build the key. And remaining fields of records are appearing with spaces.

Well, could not figure out the reasons for that.
Can anyone help out with this?
Back to top
View user's profile Send private message
Apeksha

New User


Joined: 21 May 2008
Posts: 37
Location: Mumbai

PostPosted: Thu Jan 07, 2010 3:18 pm
Reply with quote

Oh, I put wrong layout in above post, correcting here.

Code:
01 AIXIN-REC.                                                   
  03 AIXIN-LENGTH                             PIC S9(4) COMP.   
  03 AIXIN-REC-CNT                            PIC S9(4) COMP.   
  03 FILLER                                   PIC 9(01).
  03 AIXIN-PRM-KEY.                                             
     05 AIXIN-PRM-NUMBER                      PIC 9(06).       
     05 AIXIN-PRM-MEMID                       PIC X(11).       
     05 AIXIN-PRM-DATE                        PIC 9(08) COMP-3.
  03 AIXIN-DATA                               PIC X(32).     
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Jan 07, 2010 3:20 pm
Reply with quote

is an AIX (alternate index???) file, of and by itself a VSAM file?

also seems to be a rather large record for an alternate index.
Back to top
View user's profile Send private message
Apeksha

New User


Joined: 21 May 2008
Posts: 37
Location: Mumbai

PostPosted: Thu Jan 07, 2010 3:23 pm
Reply with quote

Yes, This is alternate index of one CLUSTER, which I am trying to read like VSAM file.

Record is not large, I mistakenly coded wrong value for layout.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Thu Jan 07, 2010 3:29 pm
Reply with quote

My guess is you should code :

ACCESS IS RANDOM
ACTUAL KEY IS AIX-PRM-KEY

Where AIX-PRM-KEY is working storage.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Jan 07, 2010 3:34 pm
Reply with quote

1. don't see any use of status-code for the file. would suggest your open failed and your start did also.

2. I don't think an AIX has both a data and index component, so it can not be read as a VSAM.

3. why don't you use the AIX as it is supposed to function -
I assume you actually want to retrieve the complete record from the CLUSTER-
as an alternate index.
there are several threads in this forum about reading vsam by AIX,
and here is a link to VSAM Demystified which I suggest you download and read.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Thu Jan 07, 2010 3:46 pm
Reply with quote

dbzTHEdinosauer wrote:

2. I don't think an AIX has both a data and index component, so it can not be read as a VSAM.


Hello Dick,

an AIX has just like a KSDS a data AND index component, so random read actions are allowed.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Thu Jan 07, 2010 4:13 pm
Reply with quote

A very nice slide show about VSAM AIX's can be found here :

www.scribd.com/doc/6888387/05-VSAM-Alternate-Indexes
Back to top
View user's profile Send private message
Apeksha

New User


Joined: 21 May 2008
Posts: 37
Location: Mumbai

PostPosted: Thu Jan 07, 2010 5:35 pm
Reply with quote

@PeterHolland,

I dont have full key to read RANDOMLY


Quote:
1. don't see any use of status-code for the file. would suggest your open failed and your start did also.


Status code is checked while file open and close, and its successful.

@dbzTHEdinosauer,

Here was one problem, I wanted to replace old member id with new member id which is a aprt of alternate key for CLUSTER.

As already mentioned, I do not have primary key of that cluster thru input, to read the CLUSTER and to modify the alternate key fields (member ID) (By using DELETE-WRITE or REWRITE).

So, I read the CLUSTER with alternate key. I.e. START - READ NEXT and then DELETE old record and WRITE new one. But the Pointer for START is getting corrupted as I am changing the key field.

So i decided to read AIX as KSDS file with key.

I hope I answere your all questions here.
Now my problem still persists, read next for above AIX is resulting in spaces.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Thu Jan 07, 2010 6:02 pm
Reply with quote

Quote:
So i decided to read AIX as KSDS file with key.
This is your FIRST mistake. An AIX is not an independent KSDS file that you can treat separately from the base cluster. It must be handled as part of the base cluster -- otherwise you will (not may, will) have problems.

Your SELECT should reference the base cluster and use the ALTERNATE RECORD KEY IS phrase to identify the AIX key. You can then open the base cluster, move data to your alternate key, and issue a direct READ using the KEY IS alternate-key-name to specify reading by the alternate key. There is no need to reference the primary key -- it will be returned as part of the data read.

Attempting to do anything else is just begging for trouble.
Back to top
View user's profile Send private message
Apeksha

New User


Joined: 21 May 2008
Posts: 37
Location: Mumbai

PostPosted: Thu Jan 07, 2010 6:07 pm
Reply with quote

Robert,

Thanks for your response, but please refer to the reply above from peterholland.

AIX can be used as different KSDS.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Thu Jan 07, 2010 6:15 pm
Reply with quote

Peter's comment did not say that an AIX can be used independently of the base cluster at all. He pointed out that an AIX has data and index components just like the base cluster, so random reads to an AIX are allowed. Anybody who has ever defined an AIX through IDCAMS knows this. Especially if the UPGRADE parameter was defined as part of the AIX, attempting to use the AIX without referencing the base cluster has a good chance of corrupting the VSAM file.
Back to top
View user's profile Send private message
Apeksha

New User


Joined: 21 May 2008
Posts: 37
Location: Mumbai

PostPosted: Thu Jan 07, 2010 6:15 pm
Reply with quote

To mention again Robert, I want to change the field MEMID which is part of alternate key itself.

I cannot read with alternate key (START and READ-NEXT) then delete the record and write with the same alternate key.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Thu Jan 07, 2010 6:28 pm
Reply with quote

Quote:
Here READ next is not fetching the desired record from FILE. The record is just holding the OLD-MEMID and NUMBER which is moved to build the key. And remaining fields of records are appearing with spaces.

Well, could not figure out the reasons for that.
Can anyone help out with this?
You're being told what the problem is but you're not listening. Let's try one more time.

First, find the VSAM Demystified redbook from IBM. You need to read this to understand even the basics of AIX processing -- which it is clear from your comments that you do not understand, at all.

An alternate index record consists of two things and only two things -- the alternate index value and one (or more if DUPLICATES are allowed) primary keys that match the alternate index value. There are no fields from any part of the base cluster record stored in the alternate index -- just the alternate index value and the primary key(s) for the record(s) which match the alternate index value. So reading an alternate index file without accessing the base cluster means you get nothing back except the alternate index key value and the first primary key with that alternate index value. If your code has the alternate index associated with the base cluster, yes you get back the data fields but they are coming from the base cluster which is automatically read using the primary key. No base cluster, no data fields.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Thu Jan 07, 2010 9:16 pm
Reply with quote

Apeksha,

Any how I think, there was something to be done and as a solution some one suggested to use Alternate Index approach. The way your first post is posted here, code behaving the way it should - suggest you tell us the problem statement and why did you choose for AIX, may be someone just have some suggestions which can work for you.
Back to top
View user's profile Send private message
Apeksha

New User


Joined: 21 May 2008
Posts: 37
Location: Mumbai

PostPosted: Fri Jan 08, 2010 1:06 pm
Reply with quote

@Robert,
I have sent you the details of AIX.

@Anuj,
Hi, how are you doing?

What I am actully looking for is;
I have a VSAM cluster with primary key of 32 length and alternate key of 32 length. Alternate key of 3 fields
1. number 2.mem id 3. date

Now I want to replace mem id with new mem id which will appear in input.
Input file contains, only number, old member id and new member id.

I found the solution for the same. Here it is,

1. Read file with alternate key and fetch primary key for that record
2. read file with primary key
3. populated new record
4. deleted old record
5. written new record
6. read again with primary key to fetch next record


Code:
SELECT  VSAM-IN    ASSIGN  TO  VSAM-FILE       
        ORGANIZATION   IS INDEXED                 
        ACCESS MODE    IS DYNAMIC                 
        RECORD KEY     IS VSAM-PRM-KEY       
        ALTERNATE KEY IS VSAM-ALT1-KEY
        FILE STATUS    IS WS-STAT.     


Code:
MOVE INPUT-NO            TO VSAM-ALT1-NO. 
MOVE OLD-MEMID           TO VSAM-ALT1-MEMID.   
MOVE ZEROES              TO VSAM-ALT1-DATE.


Code:
START  VSAM-IN                                   
       KEY IS >= VSAM-ALT1-KEY                   
END-START.                           
                                                     
READ VSAM-IN NEXT.         
*READING WITH ALTERNATE KEY

IF ((INPUT-OLD-MEMID NOT = VSAM-ALT1-MEMID)   
                         OR                         
    (INPUT-NO NOT = VSAM-ALT1-NO) OR
    (WS-STAT = '46'))
     GO TO EXIT
ELSE                                                 
  START  VSAM-IN                             
       KEY IS >= VSAM-PRM-KEY               
 END-START                                       
                                                     
 READ VSAM-IN NEXT     
*READING WITH PRIMARY KEY

MOVE VSAM-REC TO WS-REC
MOVE INPUT-NEW-MEMID TP WS-NEW-MEMID

DELETE VSAM-IN

WRITE VSAM-REC FROM WS-REC

READ VSAM-IN NEXT   
*READ WITH PRIMARY KEY
END-IF.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Fri Jan 08, 2010 5:11 pm
Reply with quote

Glad to hear you got it working. The revised code you've posted reflects -- extremely closely-- the comments that Dick, Peter, Anuj, and I have all made in that it does not attempt to treat an AIX as an independent VSAM file but properly handles it as a part of a VSAM cluster.
Back to top
View user's profile Send private message
Apeksha

New User


Joined: 21 May 2008
Posts: 37
Location: Mumbai

PostPosted: Fri Jan 08, 2010 5:34 pm
Reply with quote

Yes Robert,

Thanks for all of your inputs.

I could use AIX as independent file also.

Thanks,
Apeksha
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Jan 08, 2010 5:59 pm
Reply with quote

Quote:
I could use AIX as independent file also.


so what? what will/can you accomplish?

this must be thin-skinned,
I am right in the face of all facts,
I am not appreciated,
and my co-workers do not speak to me because I am such a fool
and that is why I post my questions in an anonymous forum
DAY

or I can drive very fast in reverse!
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Fri Jan 08, 2010 6:02 pm
Reply with quote

You keep insisting you're right in spite of multiple senior members telling you otherwise -- arrogance at its worst. Try this: use IDCAMS to dump the AIX DATA file to see how much data from your VSAM file you can see in it.
Back to top
View user's profile Send private message
Apeksha

New User


Joined: 21 May 2008
Posts: 37
Location: Mumbai

PostPosted: Fri Jan 08, 2010 6:07 pm
Reply with quote

Robert,

I agree that you all are senior members, and you all have better knowledge than me.

But could you take a look at the attachment which I sent you.

Let me know your thoughts on it
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Jan 08, 2010 6:13 pm
Reply with quote

Robert,

I think what the TS was trying to imply was that by using the AIX in independent VSAM mode, he could modify his AIX.

Why someone would think that this would be faster/better that using the idcams utility to build/rebuild an AIX I don't know.

it almost seemed that he wanted to modify his AIX based on 'to be' key values (the result of an upcoming update to the master). Since he already had a 'old-new' file, it was an unnecessary exercise.

another case of finding a situation for the solution.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Fri Jan 08, 2010 6:14 pm
Reply with quote

I've sent my thoughts -- your program does not show access to only the AIX but access to the base cluster THROUGH the AIX.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Sat Jan 09, 2010 1:54 am
Reply with quote

Hello,

Quote:
I could use AIX as independent file also.
There is a huge difference between being persistent and merely being stubborn. . .

No matter how long/repeatedly you mis-use termnology, it will not become correct (or acceptable in technical discussions).

All you can accomplish by continued insistence, is to remain confused as well as confuse others who are also trying to learn.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Unable to interpret a hex value to De... COBOL Programming 7
No new posts how to eliminate null indicator value... DB2 7
No new posts Dynamically build sort control statem... SYNCSORT 18
No new posts VSAM LISTCAT INFORMATION JCL & VSAM 2
No new posts Format Binary file to EBCDIC JCL & VSAM 4
Search our Forums:

Back to Top