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

Files in Cobol


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
bnveena

New User


Joined: 29 May 2007
Posts: 50
Location: hyderabad

PostPosted: Thu Feb 05, 2009 9:40 am
Reply with quote

I have one input file and i need two output files to be created using one cobol program.

Can i read the first output file and write the records to second output file.

Is there a option in the cobol
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Thu Feb 05, 2009 9:46 am
Reply with quote

If a dataset is for output, why are you reading from it?

Do you want to read and write on a dataset? UPDATE?

Please explain your requirement in detail so that someone here would be able to help you.
Back to top
View user's profile Send private message
bnveena

New User


Joined: 29 May 2007
Posts: 50
Location: hyderabad

PostPosted: Thu Feb 05, 2009 9:50 am
Reply with quote

my input has about 9900000 records and i want to write the records to the report on some condition.

I have written a condition based on that i have written records to the output file by using that output file i have to write all the records in the output file to the report in a formatted way.

well i have written 2 cobol programs for that. But my requirement was I have to write only one program.
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Thu Feb 05, 2009 10:06 am
Reply with quote

If I am right...
Write the records to first output dataset and close it...
Again, Open that dataset in input mode and read the records and format them and write them to another output dataset...
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Thu Feb 05, 2009 11:32 am
Reply with quote

Hi,

Well, you say there is one input (say in1) & two outputs say out1 & out2. Out1 is anyways derived from in1 itself, can't out2 be derived from in1 itself instead of thinking about out1?
Back to top
View user's profile Send private message
bnveena

New User


Joined: 29 May 2007
Posts: 50
Location: hyderabad

PostPosted: Thu Feb 05, 2009 11:54 am
Reply with quote

I think we can do that ...... but i tried using that but my program is running into loop if i am using that logic.....
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: Thu Feb 05, 2009 11:56 am
Reply with quote

Hello,

If you were to post some sample data of each of the three files it would help us understand the requirement.

From what i know so far, you could structure the code to open the first file (in1) as input, the second file (out1) as output and contidionally write records into file 2 from file one as per the requiirement. When all of the records in file 1 were processed, close in1 and out1.

Now open out1 as input and out2 as output and process as needed until end of out1 (now used as input) is reached. Close the 2 files and the process is complete.

If you post more details of the requirement, we may be able to offer better suggestions.

Good luck icon_smile.gif
Back to top
View user's profile Send private message
Shashank.kapoor

New User


Joined: 14 Jan 2009
Posts: 24
Location: Mumbai

PostPosted: Thu Feb 05, 2009 1:17 pm
Reply with quote

Hi,

If I am correct, your requirement is to put same formatted records in both the output files.

Instead of opening and closing of files again & again, I will suggest you to write all your formatted records in one output file through your cobol program and to insert into the 2nd output file you can add an extra step to copy all the records from one to another file through IEBGENER.

I believe this will cosume less resources as compare to opening and closing the file for same records.

Please correct me if misunderstood your requirement.

------------
Shashank
Back to top
View user's profile Send private message
Shashank.kapoor

New User


Joined: 14 Jan 2009
Posts: 24
Location: Mumbai

PostPosted: Thu Feb 05, 2009 1:20 pm
Reply with quote

Quote:
o insert into the 2nd output file you can add an extra step to copy all the records from one to another file


Opps!! I missed the important word i.e. JCL.

o insert into the 2nd output file you can add an extra step in your JCL to copy all the records from one to another file.
Back to top
View user's profile Send private message
Bharath Bhat

Active User


Joined: 20 Mar 2008
Posts: 283
Location: chennai

PostPosted: Thu Feb 05, 2009 1:59 pm
Reply with quote

shashank.kapoor wrote:
If I am correct, your requirement is to put same formatted records in both the output files.

Usually, reports are in a different format than files.

bnveena wrote:
i have to write all the records in the output file to the report in a formatted way.
This suggests that both are differenet formats.

I would go with Anuj's suggestion.
bnveena wrote:
but my program is running into loop if i am using that logic.....


A better option would be to XPEDIT and find out what is going wrong where.
Back to top
View user's profile Send private message
Debabrata Pruseth

New User


Joined: 11 Dec 2008
Posts: 59
Location: Pune , India

PostPosted: Thu Feb 05, 2009 2:04 pm
Reply with quote

We can also do one more thing , instead of having Out1 and Out2 we can have a third VSAM file Out3V . So when you read IN1 and write into Out1 also write in Out3V ( note- only write those fields that are required in Out2 and not entire Out1. Also if you are sure that you cannot have a unique key for Out3V then define the first 7 bytes of Out3V as key and increment it from 1 to 9900000 each time you write a record into it so that key is unique ). Then once In1 has been processed and Out1 and Out3V created , point to the first record of Out3Vand then read sequentially and write it to Out2 as per requirement.

In the next step delete the VSAM file Out3V.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Thu Feb 05, 2009 2:07 pm
Reply with quote

Hi,

How do you conclude this?
Quote:
but my program is running into loop if i am using that logic
Back to top
View user's profile Send private message
bnveena

New User


Joined: 29 May 2007
Posts: 50
Location: hyderabad

PostPosted: Thu Feb 05, 2009 2:37 pm
Reply with quote

Firstly i cant use the VSAM file in my code.

To explain my logic:

My output file contains 9999000 records where all the records i have to retrieve from the database table.

this file i have to process it according to the key fields and i have to move to the report.

i have used compare logic in my first cobol program where i will compare the current record and the previous record if the key is same and there is another field which should be different if that is the case only we have to move the records to the report.

To check this for the 9999000 records and then adding the report format its a bit confusing while i am coding so i have splited the files.

I got the program where i have first opend the first output file and write all the records and close it. and then again open in input mode and write it to the repot according to the format.

thanks every one for giving me some suggestions for this problem....
Back to top
View user's profile Send private message
Shashank.kapoor

New User


Joined: 14 Jan 2009
Posts: 24
Location: Mumbai

PostPosted: Thu Feb 05, 2009 3:25 pm
Reply with quote

Hi Veena,
It’s good to see that you got the template program. Currently you are moving the non-duplicate records from input file to output file and then reading the 1st out file and moving the records to 2nd out file in report format. Correct?

I will suggest you to put a step in JOB to remove the duplicate records and then take the file with non duplicate records as your input.
This will consume less system resources than what you are doing.

-------------
Shashank
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts Write line by line from two files DFSORT/ICETOOL 7
Search our Forums:

Back to Top