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

program for file processing in REXX


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
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
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
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: 8797
Location: Welsh Wales

PostPosted: Mon Sep 29, 2008 6:38 pm
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

Global Moderator


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

PostPosted: Mon Sep 29, 2008 6:43 pm
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

Global Moderator


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

PostPosted: Mon Sep 29, 2008 9:15 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top