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

COBOL write operation in to sequential file


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

Active User


Joined: 29 Jun 2005
Posts: 155

PostPosted: Mon Oct 03, 2011 10:26 am
Reply with quote

Hi Folks,

I need a help . I want to change a cobol program which is of write operation in to sequential file. JCL corresponds to GDG Generation for this file . Program existing logic will be of read from VSAM file and write entries in to flat file .
Problem is when read from VSAM if we have more than one entry for account(Key fields) with different amount values,Instead of writing in to mutliple records for the same Account with different amount in GDG file , i want to sum the amount for all entries of the account and write as single record/ entry in to sequential file. Existing logic is fiel is in open output mode and correspond jcl parameter is of DISP=NEW.

Iam also trying with several logic . If any can help me out .

Thanks
Balaji K
Back to top
View user's profile Send private message
smitha T

New User


Joined: 04 Jun 2008
Posts: 2
Location: Hyderabad

PostPosted: Mon Oct 03, 2011 11:35 am
Reply with quote

Hi Balaji,

Is Account number key field in the VSAM? Pls clarify. Also, pls post sample input records.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Oct 03, 2011 11:46 am
Reply with quote

where are You facing issues, the logic or the coding?

learn also to split Your logic...
using a gdg is not a programming issue, it is a data/storage management issue
the program is unaware about it

after six years of hanging around here You should have learned how to post better

OK for the language barrier,
but reread Your post and tell us sincerely if it is something that we can understand clearly .
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Oct 03, 2011 11:57 am
Reply with quote

You've been on here for six years.

You seem to be describing a simple situation. How have you not come across such a thing in all that time?

Code:
save first key (from priming read, for instance) intitliase values
test for change of key
  if so, output to file with old key, store new key, initalise values
accumulate necessary values
at end-of-file ensure last data is output (before closing output file!)


Maybe I'm missing something?

When I say "initialise" I don't mean use INITIALIZE. I think that verb was introduced to dig people who couldn't code a loop properly out of a hole they were faced with all the time. First step on the slippery path...
Back to top
View user's profile Send private message
balaji81_k

Active User


Joined: 29 Jun 2005
Posts: 155

PostPosted: Mon Oct 03, 2011 3:46 pm
Reply with quote

Hi Smitha,

There is no problem in reading VSAM , the logic in which we need to populate records for Flat file(GDG).

Existing code is just move to record structure of flat file and write it .Now the logic we need is instead of directly writing in to it we need to hold some records and check for same account is received for different amount and then combined the amount and write as one record in flat file.

Thanks
Balaji K
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Oct 03, 2011 6:25 pm
Reply with quote

Are you, slowly, going through the posts one-by-one and not reached enrico's yet?

Forget about anything being a GDG. It is irrelevant to your program code.

When you later get to my post, see if the outline helps. If not, tell us the specific problem that you have.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


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

PostPosted: Mon Oct 03, 2011 6:56 pm
Reply with quote

This
balaji81_k wrote:
Existing code is just move to record structure of flat file and write it .Now the logic we need is instead of directly writing in to it we need to hold some records and check for same account is received for different amount and then combined the amount and write as one record in flat file.
and the green-color-text from Bill --
Code:
save first key (from priming read, for instance) intitliase values
test for change of key
  if so, output to file with old key, store new key, initalise values
accumulate necessary values
at end-of-file ensure last data is output (before closing output file!)


don't you think you've the answer already?
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 Oct 03, 2011 9:55 pm
Reply with quote

Hello,

What about summarize do you not yet understand?

If you are looking for someone to do the work for you, sorry. We will help, but not actually do this for you.

A good way to get help is to show what you have done so far and where you are stuck. Someone should be able to offer a suggestion.
Back to top
View user's profile Send private message
balaji81_k

Active User


Joined: 29 Jun 2005
Posts: 155

PostPosted: Tue Oct 04, 2011 2:32 pm
Reply with quote

Hello,

If you carefull read my first statement posted in this topic sates that "that i am also trying several logic " to implement this and i want to get some sharing ideas. Anyway i have implement my own split logic and its working fine . People who posting queries are not to get work done by some other but to get ideas from experts who are specialized in that respective skills.

Please let me know your concerns.

Thanks
Balaji K
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Oct 04, 2011 3:07 pm
Reply with quote

for such a task You do not have any reasonable alternative than follow Bill' s logic.

it seems anyway strange that after 6 years of IT practicing You have not mastered such a simple issue


getting rid of duplicated ( with or without summing up something ) is probably the third exercise in basic <COBOL> training
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Oct 04, 2011 4:43 pm
Reply with quote

Please post your solution, as it may help others faced with a similar requirement in the future.
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 FTP VB File from Mainframe retaining ... JCL & VSAM 2
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top