View previous topic :: View next topic
|
Author |
Message |
dsivapradeep
New User
Joined: 06 Jul 2012 Posts: 43 Location: INDIA
|
|
|
|
Hi all,
I'm getting s322 abend while trying to read KSDS record with a primary key value.
PFB my code below.
Code: |
VSAMPROG START 0
BEGIN SAVE (14,12)
BALR 12,0
USING *,12
ST 13,SAVE+4
OPEN VSAMACB
LOOP GET RPL=RPLLAB
WTO 'SHIVA'
TPUT AREAADDR,L'AREAADDR
WTO TEXT=AREALEN,ROUTCDE=(11)
* B LOOP
END WTO 'END OF FILE'
CLOSE VSAMACB
L 13,SAVE+4
WTO 'AFTER ALL CLOSE'
RETURN (14,12),RC=0
LTORG
*FILE DEFEINITIONS HERE
VSAMACB ACB MACRF=(KEY,DIR,IN),DDNAME=VSAMJCL,EXLST=EXLSTL
EXLSTL EXLST EODAD=END
RPLLAB RPL ACB=VSAMACB,AREA=AREAADDR,AREALEN=80,ARG=PKEY,KEYLEN=4, X
OPTCD=(KEY,MVE,DIR),RECLEN=80
*VARIABLE DECLARATIONS HERE
SAVE DS 18F
PKEY DC CL4'1002'
AREALEN DC H'80'
AREAADDR DS CL80
END VSAMPROG
|
the output screenshot is given below.
Code: |
IGD103I SMS ALLOCATED TO DDNAME JOBLIB
IGD103I SMS ALLOCATED TO DDNAME VSAMJCL
IEF237I JES2 ALLOCATED TO SYSOUT
SHIVA
1002GHAGRA 10000197
END OF FILE
AFTER ALL CLOSE
SHIVA
1002GHAGRA 10000197
END OF FILE
AFTER ALL CLOSE
SHIVA
1002GHAGRA 10000197
END OF FILE
AFTER ALL CLOSE
SHIVA
1002GHAGRA 10000197
END OF FILE
AFTER ALL CLOSE
SHIVA
1002GHAGRA 10000197
END OF FILE
AFTER ALL CLOSE
SHIVA
|
The same record with primary key value=1002 is getting displayed all the time.
Can somebody help me in identifying the mistake i made. |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1193 Location: Dublin, Ireland
|
|
|
|
You haven't changed the key value in PKEY, so you keep reading the same record.
Garry. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Garry Carroll wrote: |
You haven't changed the key value in PKEY, so you keep reading the same record.
Garry. |
What the TS shows is that the loop is commented. My guess is that before
he showed his code the loop was after the WTO for EOF.
Beside that R13 is not pointing to his save area, but still pointing to the caller's SA. |
|
Back to top |
|
|
dsivapradeep
New User
Joined: 06 Jul 2012 Posts: 43 Location: INDIA
|
|
|
|
Hi Gary,
i'll be reading the same record again and again if i write GET operation in LOOP area. But here i i have commented the B LOOP line. so GET operation has to be executed only once!! |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
If you were running the version with the loop commented out, you'd not get an S322.
You got an S322, so, you are running one that still has the loop in, like Garry said. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
This program (if you can call it that) is using the SA of its caller, instead of its own SA. That will lead to unexpected results. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Sorry Peter. Missed your first post. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Bill Woodger wrote: |
Sorry Peter. Missed your first post. |
No problem Bill. Im still in a forgiving mood. |
|
Back to top |
|
|
dsivapradeep
New User
Joined: 06 Jul 2012 Posts: 43 Location: INDIA
|
|
|
|
My Mistake, i dint write LA 13,SAVE instruction before OPEN Macro.
Now its working, thanks Peter
But why is this infinite loop GET operations occuring when i avoided LA 13,SAVE instruction? |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Because SA chaining is not properly set up, registers will contain invalid pointers and/or return adresses. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Step through your program being called (pencil and old listing paper is OK), doing its stuff and returning to the calling program, and then see where the calling program is going to "return" to :-) and then see what will happen next... |
|
Back to top |
|
|
|