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 process single seq file

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

New User


Joined: 19 Sep 2013
Posts: 7
Location: India

PostPosted: Wed Sep 25, 2013 11:39 pm    Post subject: How to process single seq file
Reply with quote

Hi,

How to process single sequential file to do rollup
of data as follows using cobol,

Requirement,

Key1 Key2 Value

a 1 0.1
a 1 0.2
a 1 0.4
b 2 0.9
b 3 0.2
b 3 0.1
c 1 0.1
c 1 0.1


Result,


Key1 Key2 Value

a 1 0.7
b 2 0.9
b 3 0.3
c 1 0.2
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Wed Sep 25, 2013 11:42 pm    Post subject:
Reply with quote

What have you tried and what are you having trouble with?

We help with problems; we don't write code for you. Is this a homework problem?
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1534
Location: Andromeda Galaxy

PostPosted: Thu Sep 26, 2013 3:16 pm    Post subject:
Reply with quote

If this is not a homework or testing of skills work would suggest to have this work with SORT aswell
Back to top
View user's profile Send private message
Gary McDowell

Active User


Joined: 15 Oct 2012
Posts: 139
Location: USA

PostPosted: Thu Sep 26, 2013 6:11 pm    Post subject:
Reply with quote

If I'm not mistaken the requestor is not asking for any code (yet), and not asking for a SORT solution but a COBOL solution.

This look like a typical COBOL Control Break process. Most, if not all, "teaching" COBOL books will have examples/process.

There are many ways to accomplish Control Breaks process but this is how I tend to proceed (more or less):

In a one-time Initialize routine I Perform an input Read, and then move the input keys to Working Storage.
Something like this…
Move input-key1 to WS-KEY1. Move input-key2 to WS-KEY2. WS-KEY1 PIC X(05) i.e. 'A 1 0' WS-KEY2 PIC 9(01) i.e. 1

In your Mainline routine, Perform an Input Read, and determine if input-key1 is different from Working Storage key1 (WS-KEY1);
if different (Control Break) move your Working Storage key information to your output record, write output, and move your input "break" key to working storage key.
If key1 not different add your input key2 to Working Storage key2 (WS-KEY2).
Pseudo-code something like this…
If input-key1 not equal to WS-KEY1 {Control Break}
Move WS-KEY1 to output-key1
Move WS-KEY2 to output-key2
Perform Write
Move input-key1 to WS-KEY1 {Break key}
Move zero to WS-KEY2 [clear-out rollup accumulator]
End of If.
Add input-key2 to WS-KEY2.
Perform Read.

If you have any coding problems/questions come on back and ask! Another hint…at end-of-file be sure to move your Working Storage keys to output and write [most beginner developers miss writing the last key rollup]. Good luck.
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 Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 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
No new posts File processing vishwakotin Mainframe Interview Questions 9 Fri Apr 28, 2017 11:38 am
No new posts Occurrence of various strings within ... TS70363 JCL & VSAM 1 Thu Apr 27, 2017 8:18 pm


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