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: 7996
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: 10231
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 Changing of LRECL of a file abdulrafi DFSORT/ICETOOL 2 Fri Mar 24, 2017 3:25 pm
No new posts splitting a file abdulrafi DFSORT/ICETOOL 3 Fri Mar 24, 2017 11:51 am
No new posts Record Not found in AlX but record re... mukun264 COBOL Programming 5 Fri Mar 24, 2017 9:28 am
No new posts Count the length of the record & ... sreekusr DFSORT/ICETOOL 4 Thu Mar 23, 2017 7:52 pm
No new posts Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm


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