Reading a PS and selecting some part of data



IBM's Command List programming language & Restructured Extended Executor

Reading a PS and selecting some part of data

Postby shivendu » Mon Jul 21, 2008 6:20 pm

I have a requirement like this:
Read a file (actually a text file uploaded to mainframe) line by line and copy next 8 bytes when a particular word is found in the record. E.g., if the input file is like the one below then the REXX code should give next 8 characters whenever say “Program:” is encountered i.e. output file for the below input file should have 2 records- M002233 and M1254789.

Description..
The purpose of this section is to put in ..
Job: J002233
Program:M002233
The purpose of this section..
The purpose of Program:M1254789


Note: position of tag like ‘Program:’ in above sample file is NOT fixed.

How to do this?

Thanks,
Shvndu
shivendu
 
Posts: 11
Joined: Sun May 04, 2008 3:52 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Reading a PS and selecting some part of data

 

Re: Reading a PS and selecting some part of data

Postby MrSpock » Mon Jul 21, 2008 9:28 pm

I'd use a PARSE statement:

"EXECIO 1 DISKR myindd"
If rc <> 0 Then ...
Parse Pull the_record
Parse Var the_record . the_identifier the_value
If the_identifier = "Program:" Then
  Do
    Push Left(the_value,8)
    "EXECIO 1 DISKW myoutdd"
  End
...
User avatar
MrSpock
Global moderator
 
Posts: 810
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 2 times

Re: Reading a PS and selecting some part of data

Postby shivendu » Thu Jul 24, 2008 5:29 pm

Thanks for the reply. I got the desired result though using a bit different code.

done = 'no'                                           
lineno = 0                                           
DO WHILE done = 'no'                                 
"EXECIO 1 DISKR ddin"                                 
If rc = 0 Then                                       
 do                                                   
   Parse Pull the_record                             
   IF INDEX(the_record,'Program:') \= 0 THEN                     
   Do                                                 
     Push Left(the_record,17)                         
     "EXECIO 1 DISKW ddout"                           
   end                                               
 end                                                 
else                                                 
 done = 'yes' 
end           
shivendu
 
Posts: 11
Joined: Sun May 04, 2008 3:52 pm
Has thanked: 0 time
Been thanked: 0 time


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post