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
 

 

Copy a new record inbetween file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
suresh111

New User


Joined: 14 Feb 2005
Posts: 17

PostPosted: Fri Apr 03, 2009 5:57 pm    Post subject: Copy a new record inbetween file
Reply with quote

QSAM File A has 10 records and QSAM File B has 1 record but I want to include File B record after the 5th record of file A as well as already existing 6th record should move to 7th like wise all ...now total 11 records should show in the File A.

Thanks & Regards,
Suresh
Back to top
View user's profile Send private message

superk

Moderator Team Head


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

PostPosted: Fri Apr 03, 2009 6:07 pm    Post subject: Reply to: Copy a new record inbetween file
Reply with quote

Read File B and store the contents in Working-Storage.

Read File A with a record-counter incremented by 1 for each read. Write each record to File C. When you reach record 5, write it to File C, write the stored records from File B to File C, then continue the read-write process until File A reaches its EOF.

Afterward, you can delete or rename File A, then either rename File C or copy File C to a new File A.
Back to top
View user's profile Send private message
muthuvel

Active User


Joined: 29 Nov 2005
Posts: 217
Location: Chennai

PostPosted: Fri Apr 03, 2009 6:08 pm    Post subject:
Reply with quote

For the above scenario, there are few questions,Is 1 record in file B is going to be the same or will it vary for every run?
If it varies,how you want them to be processed.


Keeping the questions apart,for your scenario ,

You cannot wirte a record intermediate in a sequential file,so you have to create a new file- File C
the solution will be ; Open file A in Input ;file B in Input;Open file C in output;
Code:
Read file A;
Increment FileA-Read-Cntr
If FileA-Read-Cntr =5
  Read fileB
  Write FileB rec to File C
Else
  Write FileA rec to File C
End-if
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7931
Location: Bellevue, IA

PostPosted: Fri Apr 03, 2009 6:12 pm    Post subject:
Reply with quote

muthuvel: what happens to the fifth record in file A using your algorithm? Do you see a difference between what Kevin posted and what you posted?
Back to top
View user's profile Send private message
suresh111

New User


Joined: 14 Feb 2005
Posts: 17

PostPosted: Fri Apr 03, 2009 6:18 pm    Post subject:
Reply with quote

Thanks for the solution

Regards,
Suresh
Back to top
View user's profile Send private message
arvind.m

Active User


Joined: 28 Aug 2008
Posts: 205
Location: Hyderabad

PostPosted: Fri Apr 03, 2009 6:22 pm    Post subject:
Reply with quote

Yes. the 5th record from file-A is not written into output file. Maybe try this:

Code:

Read file A;
Increment FileA-Read-Cntr
If FileA-Read-Cntr =5
  Read fileB
  Write FileA rec to File C
  Write FileB rec to File C
Else
  Write FileA rec to File C
End-if
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10210
Location: italy

PostPosted: Fri Apr 03, 2009 6:42 pm    Post subject: Reply to: Copy a new record inbetween file
Reply with quote

Code:
Read file A;
Increment FileA-Read-Cntr
If FileA-Read-Cntr =5
  Read fileB
  Write FileA rec to File C
  Write FileB rec to File C
Else
  Write FileA rec to File C
End-if


wonder why not keep things simpler

Code:
Read file A;
Write FileA rec to File C
Increment FileA-Read-Cntr
If FileA-Read-Cntr =5
  Read fileB
  Write FileB rec to File C
End-if
Back to top
View user's profile Send private message
suresh111

New User


Joined: 14 Feb 2005
Posts: 17

PostPosted: Fri Apr 03, 2009 7:59 pm    Post subject:
Reply with quote

Thanks a lot All of you..........
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts HALDB data refresh/copy from producti... vineetanand2007 IMS DB/DC 0 Mon Jan 02, 2017 11:16 am
No new posts Copy RECFM =VB TO FB file with RECL =... sahil41352 DFSORT/ICETOOL 3 Wed Dec 28, 2016 11:29 pm
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 7 Fri Dec 02, 2016 9:47 am
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm


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