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
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
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    Post subject: How to add records(updating) to the an existing file in rexx
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: 8593
Location: Back in jolly old England

PostPosted: Fri Jul 06, 2007 6:21 pm    Post subject:
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: 1288
Location: Chennai, India

PostPosted: Fri Jul 06, 2007 6:22 pm    Post subject: Re: How to add records(updating) to the an existing file in
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    Post subject: hi
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: 8593
Location: Back in jolly old England

PostPosted: Fri Jul 06, 2007 6:52 pm    Post subject:
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: 1288
Location: Chennai, India

PostPosted: Fri Jul 06, 2007 7:26 pm    Post subject: Re: How to add records(updating) to the an existing file in
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: 8593
Location: Back in jolly old England

PostPosted: Fri Jul 06, 2007 7:54 pm    Post subject:
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: 1288
Location: Chennai, India

PostPosted: Mon Jul 09, 2007 7:08 pm    Post subject: Re: How to add records(updating) to the an existing file in
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

Site Director


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

PostPosted: Mon Jul 09, 2007 7:27 pm    Post subject:
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    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. Need help on If condition continuatio... ashok_uddaraju CLIST & REXX 4 Fri May 19, 2017 8:55 am
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Issue with NDM process to transmit ES... chetanambi All Other Mainframe Topics 6 Wed May 03, 2017 10:52 am


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