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

Read record and Strip data from column 45-55 in other datase


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Phalgun

New User


Joined: 18 May 2009
Posts: 16
Location: Hyd

PostPosted: Sat Nov 14, 2009 9:41 pm
Reply with quote

Hi ,

I do this work manually
1) browse dataset do F '2A' 20 21 ALL to get count of number of account
2) Do F '2A' 20 21 and copy data in Column 45 to 55 from that particular record in other dataset ..

Please how this can be automated using rexx ..
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Sat Nov 14, 2009 10:17 pm
Reply with quote

read the file,
if the record contains '2A' in 20 & 21,
then parse the record collecting columns 45 to 55
and output that data to your new file.

How many records are in the dataset, on average?
what is the record length of the input file?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Sun Nov 15, 2009 2:14 am
Reply with quote

Sorry,
read the file
Commands neccessary: Allocate, EXECIO

Process input
DO a=1 TO input-record.0 by 1

if record contains '2A' in 20 & 21,
IF SUBSTR(input-record.a,20,2) = "2A" THEN

then parse the record collecting columns 45 to 55
Commands: PARSE or SUBSTR

and output that data to your new file.
Commands neccessary: Allocate, EXECIO

FREE both files.

REXX Reference
REXX User Guide
Back to top
View user's profile Send private message
Phalgun

New User


Joined: 18 May 2009
Posts: 16
Location: Hyd

PostPosted: Mon Nov 16, 2009 8:26 am
Reply with quote

Hi Dz Thanks for your reply ..

My Output should also includue total number of unique record that qualify.. I usually find that giving command F '2A' 20 21 ALL .. How to decipher this part of code in rexx ..
Second question how to "parse the record collecting columns 45 to 55 "

I'm new to rexx languagE

:cry:
I tried to write this part of code as per your suggestion .. But still it is incomplete

/* Rexx */

"ALLOC DA('My.input') F(indd) SHR REUSE"
"ALLOC DA('my.output') F(Outdd) New"
"EXECIO * DISKR indd (STEM newip."
/* Return count of number of records in dataset */
"ISREDIT FIND ALL '2A' 20 21 "
"ISREDIT (COUNT) = FIND_COUNTS"
SAY Total number of records "=" count
DO i=1 TO newip.0 BY 1
IF SUBSTR(newip.i,20,2) = '2A' THEN
/*PAse record from Column 45 55 into array*/
/* Write it to new file */
FREE F (Indd outdd)

dz i tried but not able to complete and retest as it is incomplete.. Please help me to correct this code ..

Say input file contain 6 records
after this code run
out put :
Total number of records = 6
Accounts number qualify
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx

where xxxxxxxxx --> account info in col 45 -55 ..

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

Global Moderator


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

PostPosted: Mon Nov 16, 2009 3:10 pm
Reply with quote

Quote:

/* Rexx */

"ALLOC DA('My.input') F(indd) SHR REUSE"
"ALLOC DA('my.output') F(Outdd) New"
"EXECIO * DISKR indd (STEM newip."
/* Return count of number of records in dataset */
"ISREDIT FIND ALL '2A' 20 21 "
"ISREDIT (COUNT) = FIND_COUNTS"
SAY Total number of records "=" count
DO i=1 TO newip.0 BY 1
IF SUBSTR(newip.i,20,2) = '2A' THEN
/*PAse record from Column 45 55 into array*/
/* Write it to new file */
FREE F (Indd outdd)

ABSOLUTLY UNTESTED

Code:


/* Rexx */

"ALLOC DA('My.input') F(indd) SHR REUSE"
"ALLOC DA('my.output') F(Outdd) New"

"EXECIO * DISKR indd (STEM newip."
/* Return count of number of records in dataset */
num_hits = 0
newop=""
DO i=1 TO newip.0 BY 1
 IF SUBSTR(newip.i,20,2) = '2A' THEN
   DO
     num_hits = num_hits + 1
     newop.num_hits = SUBSTR(newip.i,45,11)
   END
END
newop.0 = num_hits
"EXECIO * DISKW Outdd (STEM newop"
FREE F (Indd outdd)


your EXECIO read should have fini, probably the write also.
others I am sure will add to the post.
did not feel like generating a PARSE statement for you,
but if you look in the manual, PARSE with pattern, especially when you know the physical location is easy.
I think the PARSE will be more effecient than the SUBSTR, but both will work.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Mon Nov 16, 2009 3:12 pm
Reply with quote

your REXX script is a not a MACRO,

so, your FIND commands are useless.

by the way,
excellent first attempt!
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 -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Store the data for fixed length COBOL Programming 1
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Error to read log with rexx CLIST & REXX 11
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top