Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 8620
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: 4650
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: 2088
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
No new posts ISSUE IN copying Sequential file reco... thesumitk JCL & VSAM 2 Wed Dec 13, 2017 3:07 pm
No new posts Looping REXX - unable to interrupt RAVISANKAR07 CLIST & REXX 3 Wed Dec 06, 2017 1:08 pm
No new posts The same REXX program doesnt work for... jackzhang75 CLIST & REXX 5 Wed Dec 06, 2017 2:51 am
No new posts File Tailoring -- Temporary dataset i... samzee71 CLIST & REXX 3 Fri Dec 01, 2017 3:12 am
No new posts Rexx - File tailoring samzee71 CLIST & REXX 10 Thu Nov 30, 2017 10:47 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us