Access VSAM datasets from REXX



IBM's Command List programming language & Restructured Extended Executor

Re: Access VSAM datasets from REXX

Postby kregen » Wed Mar 16, 2011 5:19 pm

Hi,
when i need a record for a given key, then i do the following..

/* Allocation --> you can do it by the job */
ADDRESS 'TSO'
"ALLOC FI(VSAMCLU) DA('VSAM-CLUSTER') SHR REUSE"

/* filling the key */
FKEY = string some data together

/* reading the record */
/* you must read the data in hex-format. you got in trouble when some non-printable characters in the record */
X=OUTTRAP('VRec.')
"PRINT INFILE(EB2VSAM) FROMKEY('" !! FKEY !! "')" !! ,
" TOKEY('" !! FKEY !! "') HEX"
X=OUTTRAP('off')

/* ey voila... the record(s) are in VRec, */
/* the records starting at VRec.2, when duplicates, the are more the 2 records available /*

Vr = x2c(VRec.v) /* converting the data to character */

/* reformatting to the fields */
FromRVS = STRIP(SUBSTR(Vr, 11, Length(VKey)), 'B', ' ')
SprKz = STRIP(SUBSTR(Vr, 55, 1), 'B', ' ')
TODataset = STRIP(SUBSTR(Vr, 56, 44), 'B', ' ')
TORVS = STRIP(SUBSTR(Vr, 100, 3), 'B', ' ')
TOMail = STRIP(SUBSTR(Vr, 103, 350), 'B', ' ')
CCMail = STRIP(SUBSTR(Vr, 453, 350), 'B', ' ')
TITLE = STRIP(SUBSTR(Vr, LENGTH(Vr) - 69), 'B', ' ')

/* free for dataset */
"FREE FI(INDD)"

so... no additional software is needing.

regards
kregen
kregen
 
Posts: 6
Joined: Wed Jan 23, 2008 6:43 pm
Has thanked: 3 times
Been thanked: 0 time

Previous

Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post