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

How to add records(updating) to the an existing file in rexx


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
anilsanda

New User


Joined: 07 Jun 2007
Posts: 15
Location: chennai

PostPosted: Fri Jul 06, 2007 6:00 pm
Reply with quote

hi,
i want to know how to add records(updating) to the an existing file.
it will be helpful if anyone quote syntax and some examples.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Fri Jul 06, 2007 6:21 pm
Reply with quote

To add records, or to update records ?

If you just want to add records then use DISP=MOD as you disposition, but if you want to update in place then that will be DISP=OLD.

If you do want to add records, I would suggest that you write a new file out and use a utility to then merge the existing file and the new file, which will preserve the data integrity of the original file.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Fri Jul 06, 2007 6:22 pm
Reply with quote

Yes this is possible in REXX. For adding records,

1) First u read the file into a stem variable (By doing this all the records will be stored in the stem variable)
2) Get the count of the total records in the file (stem.0)
3) Open a stack and Form a loop to QUEUE the record.
4) Once the last record is reached Queue the record which u want to add.
5) Close the stack and write the queued data to a new file.

If u dont want to write it into a new file then delete the input file after reading the contents to a stem variable.

For updating records, do step 1 - 3 . Search for the record to be updated using POS command and then use substring to update the record.
Back to top
View user's profile Send private message
anilsanda

New User


Joined: 07 Jun 2007
Posts: 15
Location: chennai

PostPosted: Fri Jul 06, 2007 6:36 pm
Reply with quote

could u pls provide me some example ....it will be helpful
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Fri Jul 06, 2007 6:52 pm
Reply with quote

Quote:
If u dont want to write it into a new file then delete the input file after reading the contents to a stem variable.

And if your job fails after you have deleted the dataset ???

Also, why bother to read the records only to rewrite them again, why not just MOD the existing dataset, although it's not something I would willingly do. See my last post.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Fri Jul 06, 2007 7:26 pm
Reply with quote

Quote:
And if your job fails after you have deleted the dataset ???


S in that case i would lose my dataset icon_sad.gif !

Quote:
why not just MOD the existing dataset, although it's not something I would willingly


Is there anyway to add a record to a file in REXX without reading the whole file into a stem variable ?

Please clarify
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Fri Jul 06, 2007 7:54 pm
Reply with quote

DISP=MOD when allocating the file.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Mon Jul 09, 2007 7:08 pm
Reply with quote

Ok ! so to add a record we would use DISP=MOD while allocating the file.

For updating the record we would use DISP=OLD while allocating the file.

Quote:


Is there anyway to add a record to a file in REXX without reading the whole file into a stem variable ?


But one has to read the whole file for updating and inserting the record in the file. hope am not wrong !
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Jul 09, 2007 7:27 pm
Reply with quote

Hello,

If you provide the specifics of what you need to do, someone may have a suggestion.

What kind of file are you working with that needs new records added and/or existing records updated? How is the process driven (have you created a screen, does this run in batch, etc).

The more and better info you provide, the better suggestions you will receive.
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 How to split large record length file... DFSORT/ICETOOL 7
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top