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
 

 

logic required for file read and sum on amount filed?

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

New User


Joined: 11 Apr 2006
Posts: 93

PostPosted: Tue Jan 19, 2010 6:23 pm    Post subject: logic required for file read and sum on amount filed?
Reply with quote

I have a input file and it is having 4 fields (Branch,User,Amount and Bin).Each branch may have different users and bins.My requirement is calculate the sum of the amount of each bramch,user,bin fields.please provide me the logic.

Input file Data :-

Branch User Amount Bin
B1 U1 200 1
B1 U2 100 1
B1 U3 300 1
B2 U1 200 2
B2 U2 100 2
B2 U3 300 2
B3 U1 200 3
B3 U2 200 3
B3 U3 200 3
B4 U1 100 1
B4 U2 100 1
B4 U3 100 1
B5 U1 200 2
B5 U2 200 2
B5 U3 200 2
B1 U1 200 1
B1 U2 100 1
B1 U3 300 1
B2 U1 200 2
B2 U2 100 2
B2 U3 300 2
B3 U1 200 3
B3 U2 200 3
B3 U3 200 3
B4 U1 100 1
B4 U2 100 1
B4 U3 100 1
B5 U1 200 2
B5 U2 200 2
B5 U3 200 2
B1 U1 200 1
B1 U2 100 1
B1 U3 300 1
B2 U1 200 2
B2 U2 100 2
B2 U3 300 2
B3 U1 200 3
B3 U2 200 3
B3 U3 200 3
B4 U1 100 1
B4 U2 100 1
B4 U3 100 1
B5 U1 200 2
B5 U2 200 2
B5 U3 200 2


Output file should be like this,Here amount is sum of each branch,user and Bin fields.

Branch User Amount Bin
B1 U1 600 1
B1 U2 300 1
B1 U3 900 1
B2 U1 600 2
B2 U2 300 2
B2 U3 900 2
B3 U1 600 3
B3 U2 600 3
B3 U3 600 3
B4 U1 300 1
B4 U2 300 1
B4 U3 300 1
B5 U1 600 2
B5 U2 600 2
B5 U3 600 2
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Tue Jan 19, 2010 6:35 pm    Post subject: Reply to: logic required for file read and sum on amount fil
Reply with quote

this is a help forum, not a do it for me ( You should know better after 80 posts)
show what You have done, and from there on You might get some help
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Tue Jan 19, 2010 6:35 pm    Post subject:
Reply with quote

This is a HELP forum, not a DO-YOUR-JOB-FOR-YOU forum. Most of the people who respond are paid for their professional work product (such as program code). If you're willing to pay their rate (which can exceed 1000 USD per day or fraction thereof), I'm sure you will get your code quickly. Otherwise, you need to write the code, not us.

What have you tried so far and what is not working for you?
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Tue Jan 19, 2010 6:50 pm    Post subject: Reply to: logic required for file read and sum on amount fil
Reply with quote

Hi Robert!
we just experienced a forum collision icon_biggrin.gif we posted at the same time,
looking at the topic my post comes first but from the forum index I am the last poster

in a real time stock exchange application it might cause panic all over

too bad that this post will destroy the proof
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Tue Jan 19, 2010 6:59 pm    Post subject:
Reply with quote

LOL enrico -- these things happen. As long as no bruising is involved, I'm okay with it. ;)
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Jan 19, 2010 9:25 pm    Post subject:
Reply with quote

Hello,

Quote:
Output file should be like this,Here amount is sum of each branch,user and Bin fields.
So, what have you done so far?

Why would you believe it appropriate to ask the forum to provide code/logic for something that is less complex than a student exercise?

Possibly this is a class assignment. . .

Possibly, you would be better served in the student/fresher forum:
http://ibmmainframeforum.com/
Back to top
View user's profile Send private message
babu_hi

New User


Joined: 11 Apr 2006
Posts: 93

PostPosted: Wed Jan 20, 2010 7:08 pm    Post subject:
Reply with quote

Hi all,

i am reading input file(sorted order file) and move the the first record into working storage variables and comapre this first record with second read record,if match with the previous record then sum the amount field,if not match write the working storage field in to output file.

but i am facing problem with working storage variables are not keep the previoiu record.

PERFORM UNTIL END-OF-FILE
READ GAD-DETAIL-TRAN-FILE INTO WS-GAD-FILE-RECORD

EVALUATE TRUE

WHEN FILE-IN-STATUS EQUAL TO ZEROS
MOVE SSTACB TO WS-SSTACB
MOVE SSCPWS TO WS-SSCPWS
MOVE SSBIN TO WS-SSBIN
ADD 1 TO WS-DETL-MATCH-CNT
IF SSTACB = WS-SSTACB
AND SSCPWS =WS-SSCPWS
AND SSCPWS =WS-SSCPWS
MOVE SSCAM1 TO WS-SSCAM1
MOVE SSCHAM TO WS-SSCHAM
COMPUTE WS-AMT = WS-SSCAM1 + WS-SSCHAM
ELSE
PERFORM 2070-WRITE-RDC-BC-CONSOL-FILE
END-IF

please correct my code?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Wed Jan 20, 2010 7:25 pm    Post subject:
Reply with quote

You need to learn to use BBcode. If you have a record, and the hold fields in working storage match the fields you just read, accumulate. Otherwise, you need to output the record, THEN update the working storage fields from the record with the new data. You need an amount accumulator for branch and another for user -- you only have one so far, so you're short. And you're not resetting it each time you find a new branch or user. Note: this is not tested code, it is merely a rewrite of what you've posted so far.

Code:
PERFORM UNTIL END-OF-FILE
READ GAD-DETAIL-TRAN-FILE INTO WS-GAD-FILE-RECORD

IF  FILE-IN-STATUS EQUAL TO ZEROS
    IF  SSTACB = WS-SSTACB
    AND SSCPWS =WS-SSCPWS
        MOVE SSCAM1 TO WS-SSCAM1
        MOVE SSCHAM TO WS-SSCHAM
        COMPUTE WS-AMT = WS-SSCAM1 + WS-SSCHAM
    ELSE
        PERFORM 2070-WRITE-RDC-BC-CONSOL-FILE
        MOVE SSTACB TO WS-SSTACB
        MOVE SSCPWS TO WS-SSCPWS
        MOVE SSBIN TO WS-SSBIN
        ADD 1 TO WS-DETL-MATCH-CNT
    END-IF
END-IF
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 READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts File processing vishwakotin Mainframe Interview Questions 9 Fri Apr 28, 2017 11:38 am


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