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

not getting correct amounts after compute amounts?


IBM Mainframe Forums -> COBOL Programming
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
babu_hi

New User


Joined: 11 Apr 2006
Posts: 93

PostPosted: Thu Jan 21, 2010 4:11 pm
Reply with quote

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
20 UA01 1 5000 0
20 UA01 1 5000 0
20 UA01 1 5000 0
20 UA01 2 10000 10000
20 UA01 2 50000 50000
20 UA01 2 0 10000
20 UA01 3 0 50000
20 UA02 1 10000 0
20 UA02 1 1000 0
20 UA02 1 1500000 0
20 UA02 3 10000 0
610 SS01 1 10000 0
610 SS01 2 0 72400
610 SS01 2 0 13800
610 SS01 3 0 500
610 SS01 3 0 500
610 SS03 1 0 32474
610 SS03 1 10000 0
610 SS03 1 10000 0
610 SS03 2 0 12300
610 SS03 2 0 12000
610 SS03 3 1000 0
610 SS03 3 0 500
610 SS05 1 0 32474
610 SS05 1 0 32474
610 SS05 1 13000 0
610 SS05 2 0 10000
610 SS05 2 0 1200
610 SS05 3 10000 0
610 SS05 3 0 10000

I got out put like this,
Branch User Amount Bin
*************************** TOP OF DATA **
20 UA01 1 10000
20 UA01 2 110000
20 UA01 3 0
20 UA02 1 1501000
20 UA02 3 0
10 SS01 1 0
10 SS01 2 86200
10 SS01 3 1000
10 SS03 1 20000
10 SS03 2 24300
10 SS03 3 1500
10 SS05 1 45474
10 SS05 2 11200
10 SS05 3 0
************************** BOTTOM OF DATA

when i ran my code i am getting incorrect amounts.The amounts are not computed properly.please let me know the if any wrong in my code?

READ GAD-DETAIL-TRAN-FILE INTO WS-GAD-FILE-RECORD
MOVE SSTACB TO WS-SSTACB
MOVE SSCPWS TO WS-SSCPWS
MOVE SSBIN TO WS-SSBIN
MOVE SSCAM1 TO WS-SSCAM1
MOVE SSCHAM TO WS-SSCHAM

PERFORM UNTIL END-OF-FILE
READ GAD-DETAIL-TRAN-FILE

EVALUATE TRUE

WHEN FILE-IN-STATUS EQUAL TO ZEROS

ADD 1 TO WS-DETL-MATCH-CNT

IF SSTACB = WS-SSTACB
AND SSCPWS = WS-SSCPWS
AND SSBIN = WS-SSBIN
COMPUTE WS-AMT1 = SSCAM1 + WS-SSCAM1
COMPUTE WS-AMT2 = SSCHAM + WS-SSCHAM
ELSE
COMPUTE WS-AMT = WS-AMT1 + WS-AMT2
PERFORM 2070-WRITE-RDC-BC-CONSOL-FILE
INITIALIZE WS-GAD-FILE-RECORD
MOVE ZEROS TO WS-AMT1
MOVE ZEROS TO WS-AMT2
MOVE ZEROS TO WS-AMT
END-IF
MOVE SSTACB TO WS-SSTACB
MOVE SSCPWS TO WS-SSCPWS
MOVE SSBIN TO WS-SSBIN
MOVE SSCAM1 TO WS-SSCAM1
MOVE SSCHAM TO WS-SSCHAM
Back to top
View user's profile Send private message
Lijo

New User


Joined: 24 Aug 2008
Posts: 41
Location: Cochin

PostPosted: Thu Jan 21, 2010 4:43 pm
Reply with quote

If you post exact requirement and expected output, someone can help you out.

You're adding 'WS-AMT1 + WS-AMT2' in the code, but your requirement description doesn't talk about this:

Quote:
My requirement is calculate the sum of the amount of each bramch,user,bin fields
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Jan 21, 2010 8:17 pm
Reply with quote

Quote:
please provide me the logic.
Most of the responders on this forum are paid for their professional work product. Unless you are willing to pay their rates (and 1000 U.S. dollars per day or any fraction thereof is not an unusual rate), please do not ask for code.

What you are doing is called control breaks and Google is your friend: searching for cobol control break returned 38,100 hits. The first page of results has examples of control break logic.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Jan 21, 2010 8:24 pm
Reply with quote

You already posted a similar question!
ibmmainframes.com/viewtopic.php?p=221686&highlight=#221686
posting twice on the same issue will not get You double answers

what about doing a bit of homework Yourself???
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
No new posts ADRDSSU BY(REFDT... not selecting cor... IBM Tools 3
No new posts Compute statement with Cobol Z/os 5.2 COBOL Programming 2
No new posts Is the explanation correct? XRST,CHKP IMS DB/DC 1
No new posts ROUNDED Problem with COMPUTE statement COBOL Programming 11
Search our Forums:

Back to Top