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
 

 

Need logic to compute.

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

New User


Joined: 24 Sep 2008
Posts: 30
Location: chennai

PostPosted: Wed Nov 12, 2008 1:15 pm    Post subject: Need logic to compute.
Reply with quote

I have file which is having records like below
Code:
b230 002k41640   20080805I+000000002
b230 002k41640   20080805I+000000002
b230 005k05250   20080808I+000000002
b230 005k05250   20080808I+000000002
b230 005k05250   20080808I-000000001

I need to add like records based on 2nd filed(9bytes) and date fileds(6bytes) the output should be like below
Code:
b230 002k41640   20080805I+000000004
b230 005k05250   20080808I+000000003

I need the logic to code this.
Code:
b230 005k05250   20080808I+000000002



Edited: Please use BBcode when You post some code, that's rather readable...Anuj
Back to top
View user's profile Send private message

Anuj Dhawan

Senior Member


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

PostPosted: Wed Nov 12, 2008 1:54 pm    Post subject:
Reply with quote

Hi,

Did you try something, what happened ? Did you get an abend, an error ?
Back to top
View user's profile Send private message
charavind17

New User


Joined: 24 Sep 2008
Posts: 30
Location: chennai

PostPosted: Wed Nov 12, 2008 2:25 pm    Post subject:
Reply with quote

i tried with sorting but did not work....i wanted to code a cobol pgm but i am not getting how to code logic
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Wed Nov 12, 2008 3:16 pm    Post subject:
Reply with quote

Read the file ... add until your date field changes for the 2nd field or till your 2nd field changes ..... either store the result in working storage or write to an o/p file ...
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Wed Nov 12, 2008 3:16 pm    Post subject:
Reply with quote

Quote:
i tried with sorting but did not work

Did it abend? If not post what you got and what you were expecting. I believe what u r trying is quite possible in sort.
Back to top
View user's profile Send private message
charavind17

New User


Joined: 24 Sep 2008
Posts: 30
Location: chennai

PostPosted: Wed Nov 12, 2008 5:12 pm    Post subject:
Reply with quote

It abended with soc7....sort filed which i used is
SORT FIELDS=(6,20,CH,A,60,6,CH,A)
SUM FIELDS=(70,8,ZD)
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Wed Nov 12, 2008 5:18 pm    Post subject: Reply to: Need logic to compute.
Reply with quote

Aravind,

SORT card looks OK but we will not be able to judge the positions from your code. Place the complete JCl, field posns of input and output.

Also please post the error message that you got.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Wed Nov 12, 2008 5:20 pm    Post subject:
Reply with quote

S0C7 suggests you have invalid numeric data at pos-70. Try the same with a smaller set of input, say some 10 records. Make sure that you have numeric data there. If still you get abend, post a few input and output records you used with relevant col-positions
Back to top
View user's profile Send private message
charavind17

New User


Joined: 24 Sep 2008
Posts: 30
Location: chennai

PostPosted: Wed Nov 12, 2008 5:41 pm    Post subject:
Reply with quote

this sort card worked for me
SORT FIELDS=(10,20,CH,A,64,6,CH,A)
SUM FIELDS=(74,9,ZD)
since the file was VB i added 4 to each field

but the problem now is I have added the 000000002 to 000000002,but the +symbol which is there somtimes this will be '-' also...I need to take this into consideration. it the second row has ' - ' in it i have to get as '000000000' the value.

b230 002k41640 20080805I+000000002
b230 002k41640 20080805I+000000002
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Wed Nov 12, 2008 8:37 pm    Post subject:
Reply with quote

charavind17,

What about the input/output LRECL?
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: Wed Nov 12, 2008 10:04 pm    Post subject:
Reply with quote

Hello,

Why are there 2 different "outputs" for this
"b230 005k05250 "?

I suspect that until the rules are clearly posted, it won't matter which "language" is used. . .

Please post all of the rules and explain how the outputs posted fulfill the rules. You may need to create more complete sample input and output to go with the rules.
Back to top
View user's profile Send private message
charavind17

New User


Joined: 24 Sep 2008
Posts: 30
Location: chennai

PostPosted: Thu Nov 13, 2008 11:21 am    Post subject:
Reply with quote

this is the output i only need
output file:
b230 002k41640 20080805I+000000004
b230 005k05250 20080808I+000000003
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: Thu Nov 13, 2008 11:29 am    Post subject:
Reply with quote

Hello,

Quote:
this is the output i only need
OK, now explain how these (the 2 lines you just posted) are needed in the output and the "other" one is not. . .
Code:
b230 002k41640   20080805I+000000002
b230 002k41640   20080805I+000000002
b230 005k05250   20080808I+000000002
b230 005k05250   20080808I+000000002
b230 005k05250   20080808I-000000001

Something in the rules has not made it into the topic.
Back to top
View user's profile Send private message
charavind17

New User


Joined: 24 Sep 2008
Posts: 30
Location: chennai

PostPosted: Thu Nov 13, 2008 11:38 am    Post subject:
Reply with quote

scherrer
The other one is wrong.It was to be deleted but i did'nt delete it before posting.sorry for that.

suppose if you see the input 1 and second record are having the second feild common and also the date feild common, now if this exits then we need to sum the last feild with the sign feild for this two records and make it one line.
Similarly for the 3,4 and 5th record should be added and made into one line.
the output should be

b230 002k41640 20080805I+000000004
b230 005k05250 20080808I+000000003.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Thu Nov 13, 2008 11:47 am    Post subject:
Reply with quote

Dick,

I think he's trying to sum the last field .ie., number prefixed by sign when the key(remaining fields) are the same. That explains the sum 4 ( 2 + 2) and 3 ( 2 + 2 - 1 ) for the output.

charavind17,

You need post further information - input and output LRECL. Unless you reply to whatever have been asked here, it's not going to do anything good to you.
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: Thu Nov 13, 2008 11:55 am    Post subject:
Reply with quote

Hello,

Much more clear now - thanks:)

I believe you want the SFF format. There are some examples in the DFSORT part of the forum.
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 Wildcard logic in COBOL dudenithy COBOL Programming 13 Thu Sep 01, 2016 7:36 pm
No new posts Sort Logic to extract data scorp_rahul23 DFSORT/ICETOOL 13 Tue Mar 01, 2016 1:22 am
No new posts Need a logic to validate the data in ... sandeep kumar302 COBOL Programming 17 Mon Feb 01, 2016 3:30 pm
No new posts Tricky sort logic required pgopi92 DFSORT/ICETOOL 3 Mon Jan 25, 2016 3:29 pm
No new posts DB2 - CURRENT DATE + 2 YRS logic balaji81_k DB2 3 Thu Nov 26, 2015 3:07 am


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