Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search 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
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
References
hchinnam

Active User


Joined: 18 Oct 2006
Posts: 68

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: 3544
Location: Brussels once more ...

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: 3304
Location: Charlotte,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: 536
Location: work

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
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1