Page 1 of 1

Reading VSAM in Rexx.

Posted: Sun Mar 13, 2016 10:18 pm
by cobollearn
[font=Arial]Hi, [/font]

[font=Arial]I searched for it but i came to know that we can not access VSAM using REXX? Is it so? Is not it possible to read a KSDS VSAM in REXX? [/font]

[font=Arial]Thanks in advance for any help.[/font]
[font=Arial] [/font]

Re: Reading VSAM in Rexx.

Posted: Sun Mar 13, 2016 10:30 pm
by Akatsukami
The EXECIO command will not work with VSAM. However, there are third party extensions that will, or you can write a programette to do the I/OO and place the result into a Rexx variable.

Re: Reading VSAM in Rexx.

Posted: Mon Mar 14, 2016 3:18 pm
by enrico-sorichetti
Yes , it is possible out of the box,  if Your installation has IBM file manager

http://www.ibm.com/support/knowledgecen ... /vxfun.htm

http://www.ibm.com/support/knowledgecen ... /xvfun.htm

or see file 268 of the CBT tape

Re: Reading VSAM in Rexx.

Posted: Wed Mar 16, 2016 12:04 pm
by cobollearn
Thanks enrico-sorichetti. But we don't have File-Manager.

I have searched more on it and have below examples with me now.

Using the REPRO command and a temporary non-VSAM data set, a REXX exec can use EXECIO to retrieve and update VSAM data, as shown in this example:

Code: Select all

"ALLOCATE DD(TEMPDD) NEW SPACE(1) TRACKS DSORG(PS) LRECL(4095) RECFM(V B)"
"REPRO IDS(TESTKSDS) OFILE(TEMPDD) FROMKEY('98040') COUNT(1)"
"EXECIO 1 DISKR TEMPDD"
PULL Record
"EXECIO 0 DISKR (FINIS"
"FREE DD(TEMPDD)"
 <process data in "record" variable> 

By combining the PRINT command and the OUTTRAP function, a REXX exec can retrieve VSAM records into a stem variable, as shown in the following example:

Code: Select all

x=OUTTRAP('rec.')
"PRINT IDS(TESTKSDS) FROMKEY('98040') COUNT(5) CHAR"
x=OUTTRAP('off')
DO i=1 to rec.0
 IF LEFT(rec.i,13) \= 'KEY OF RECORD' THEN
   SAY rec.i
END 

If REPRO and PRINT do not satisfy your VSAM access needs, you may use RXVSAM, a REXX function package that provides VSAM record-level functions. Here is a REXX code fragment that invokes RXVSAM to write a single record into an ESDS:

Code: Select all

"ALLOCATE FILE(VSAMDD) DSNAME('"dsn"') SHR"
rc = RXVSAM('OPENOUTPUT','VSAMDD','ESDS')
record = 'Record 1'
rc = RXVSAM('WRITE','VSAMDD',,'record')
rxvsam_result = RXVSAM('CLOSE','VSAMDD')

Re: Reading VSAM in Rexx.

Posted: Wed Mar 16, 2016 6:34 pm
by nicc
However, RXVSAM is a non-standard add-on which many (most?) sites do not have.

Re: Reading VSAM in Rexx.

Posted: Wed Mar 23, 2016 7:28 am
by cobollearn
nicc wrote:However, RXVSAM is a non-standard add-on which many (most?) sites do not have.
oh...thanks for that information.