View previous topic :: View next topic
|
Author |
Message |
jones.jebaraj84
New User
Joined: 26 Nov 2008 Posts: 10 Location: India
|
|
|
|
I have a question. I have used REXX for Delimited files and the processing is good. But can I use the REXX for processing the FIXED files with specified layouts. For example,
Consider the fixed file as:
Code: |
Janet Jackson 25 USA
Joyce Winston 24 INDIA |
The layout for this file is as below:
First Name - Char(10)
Last Name - Char(10)
Age - Char(3)
Country - Char(10)
Now I have each field in a specified location in the file. Can we use REXX to read this file and then do processing?
Can we use Stem variable to read the record and each field in the record? |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
jones.jebaraj84 wrote: |
Can we use REXX to read this file and then do processing?
|
YES.
jones.jebaraj84 wrote: |
Can we use Stem variable to read the record and each field in the record? |
NO. You have to use one of the data processing/formatting functions: PARSE, SUBSTR, LEFT, RIGHT, CENTER, WORD, etc.
I'd use PARSE, but that's really your decision. |
|
Back to top |
|
|
Douglas Wilder
Active User
Joined: 28 Nov 2006 Posts: 305 Location: Deerfield IL
|
|
|
|
You can read the records into stem a variable. You must break the records into fields. You may put the fields in stem variables if you wish.
Code: |
/* REXX READ FIXED LEN FIELDS RECORDS USING STEM */
/* TRACE ALL */
TRACE OFF
DO UNTIL SYSDSN(FROM_NAME) = "OK"
SAY "PLEASE ENTER 'FROM' DATASET NAME"
PULL FROM_NAME
END
"FREE DDNAME(INFILE)"
"ALLOCATE DDNAME(INFILE) SHR DSNAME(" FROM_NAME ")"
"EXECIO * DISKR INFILE (STEM RECD. FINIS"
"FREE DDNAME(INFILE)"
HOW_MANY = RECD.0
DO REC = 1 TO RECD.0
PARSE VALUE RECD.REC WITH FNAME.REC 10 ,
LNAME.REC 20 ,
AGE.REC 23 ,
CNTRY.REC 33 ,
REST.REC
End
SAY 'RECS = ' RECD.0
SAY LNAME.2 ', ' FNAME.2 ' AGE = ' AGE.2 ' CNTRY = ' CNTRY.2
EXIT |
|
|
Back to top |
|
|
jones.jebaraj84
New User
Joined: 26 Nov 2008 Posts: 10 Location: India
|
|
|
|
Thanks... That was really useful... |
|
Back to top |
|
|
|