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

Need logic to compute.


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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

Superior Member


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

PostPosted: Wed Nov 12, 2008 1:54 pm
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
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
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: 2481
Location: @my desk

PostPosted: Wed Nov 12, 2008 3:16 pm
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
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: 1287
Location: Chennai, India

PostPosted: Wed Nov 12, 2008 5:18 pm
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: 2481
Location: @my desk

PostPosted: Wed Nov 12, 2008 5:20 pm
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
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: 2481
Location: @my desk

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

charavind17,

What about the input/output LRECL?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Wed Nov 12, 2008 10:04 pm
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
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

Moderator Emeritus


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

PostPosted: Thu Nov 13, 2008 11:29 am
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
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: 2481
Location: @my desk

PostPosted: Thu Nov 13, 2008 11:47 am
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

Moderator Emeritus


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

PostPosted: Thu Nov 13, 2008 11:55 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Finding faulty logic Subscript out of... COBOL Programming 5
This topic is locked: you cannot edit posts or make replies. Need assistance in job scheduling logic. Mainframe Interview Questions 2
No new posts Rexx Logic error while adding seperat... CLIST & REXX 3
No new posts PL/1 Callback address logic in z/OS C... PL/I & Assembler 1
No new posts Sync logic between VSAM files and DB2... COBOL Programming 9
Search our Forums:

Back to Top