Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

program for file processing in REXX

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
nagamanjari

New User


Joined: 25 Apr 2008
Posts: 9
Location: hyderabad

PostPosted: Mon Sep 29, 2008 6:28 pm    Post subject: program for file processing in REXX
Reply with quote

Can anyone suggest a program which reads a file and process it. And finally writes into another flat file.
It will be very helpfull.
Back to top
View user's profile Send private message

hchinnam

New User


Joined: 18 Oct 2006
Posts: 73

PostPosted: Mon Sep 29, 2008 6:32 pm    Post subject:
Reply with quote

One example below,

Code:


/*REXX*/                                     
SAY 'ITS WORKING'                           
DSN1= '''T.SATEESH.TEST'''                   
DSN2= '''T.SATEESH.OUT'''                   
SAY DSN1                                     
"ALLOC DDN(NEWDD) DSN("DSN1") SHR REUSE"     
"ALLOC DDN(OUTDD) DSN("DSN2") SHR REUSE"     
"EXECIO * DISKR NEWDD (STEM NEWVAR."         
SAY NEWVAR.0                                 
I = 1                                       
DO FOREVER                                   
  OUTVAR.I = SUBSTR(NEWVAR.I,1,20)           
  IF SUBSTR(NEWVAR.I,20,1) < 5               
                    THEN NAME = 'DAVID'     
                    ELSE NAME = 'WHITE'     
  OUTVAR.I = OUTVAR.I NAME                   
  I = I + 1                                 
  IF I = NEWVAR.0 THEN                       
  LEAVE                                     
END                                         
"EXECIO * DISKW OUTDD (STEM OUTVAR."         


But i suggest you to go through rexx manuals to understand how each statement works.

If you know the basics and have a problem on working with them, then post your problem in full so that someone can help you.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Mon Sep 29, 2008 6:38 pm    Post subject:
Reply with quote

Maybe I'm being picky ................................ but, the amended code will now close and free the input and output datasets to avoid problems of dataset / file allocations in case of reruns from an online terminal.
Code:

/*REXX*/                                     
SAY 'ITS WORKING'                           
DSN1= '''T.SATEESH.TEST'''                   
DSN2= '''T.SATEESH.OUT'''                   
SAY DSN1                                     
"FREE  FI(NEWDD,OUTDD)"
"ALLOC DDN(NEWDD) DSN("DSN1") SHR REUSE"     
"ALLOC DDN(OUTDD) DSN("DSN2") SHR REUSE"     
"EXECIO * DISKR NEWDD (STEM NEWVAR. FINIS"         
SAY NEWVAR.0                                 
I = 1                                       
DO FOREVER                                   
  OUTVAR.I = SUBSTR(NEWVAR.I,1,20)           
  IF SUBSTR(NEWVAR.I,20,1) < 5               
                    THEN NAME = 'DAVID'     
                    ELSE NAME = 'WHITE'     
  OUTVAR.I = OUTVAR.I NAME                   
  I = I + 1                                 
  IF I = NEWVAR.0 THEN                       
  LEAVE                                     
END                                         
"EXECIO * DISKW OUTDD (STEM OUTVAR. FINIS"         
"FREE  FI(NEWDD,OUTDD)"
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4649
Location: Raleigh, NC, USA

PostPosted: Mon Sep 29, 2008 6:43 pm    Post subject: Reply to: program for file processing in REXX
Reply with quote

A silly thing that reverses the text of each record:
Code:

Do Forever                                   
  "EXECIO 1 DISKR indd"                     
  If rc <> 0 Then Leave                     
  Parse Pull myrec                           
  outrec = ""                               
  Do i = Length(Strip(myrec)) To 1 By -1     
    char = Substr(myrec,i,1)                 
    outrec = outrec||char                   
  End                                       
  Push outrec                               
  "EXECIO 1 DISKW outdd"                     
End                                         
"EXECIO 0 DISKR indd (FINIS"                 
"EXECIO 0 DISKW outdd (FINIS"               
Exit 0                                       
Back to top
View user's profile Send private message
Pedro

Senior Member


Joined: 01 Sep 2006
Posts: 2051
Location: Silicon Valley

PostPosted: Mon Sep 29, 2008 9:15 pm    Post subject: Reply to: program for file processing in REXX
Reply with quote

I think the use of quotes is confusing. I use double quotes to delimit constants that include single quotes.
Code:
DSN1= '''T.SATEESH.TEST'''

Code:
DSN1= "'T.SATEESH.TEST'"

This way they look distinct from each other.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts REXX to get the all datasets name parasmalik20 CLIST & REXX 5 Tue Jul 18, 2017 9:10 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts How system know which REXX to excute? jackzhang75 CLIST & REXX 14 Thu Jul 06, 2017 1:09 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us