View previous topic :: View next topic
|
Author |
Message |
charavind17
New User
Joined: 24 Sep 2008 Posts: 30 Location: chennai
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Hi,
Did you try something, what happened ? Did you get an abend, an error ? |
|
Back to top |
|
|
charavind17
New User
Joined: 24 Sep 2008 Posts: 30 Location: chennai
|
|
|
|
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 |
|
|
ashimer
Active Member
Joined: 13 Feb 2004 Posts: 551 Location: Bangalore
|
|
|
|
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 |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
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 |
|
|
charavind17
New User
Joined: 24 Sep 2008 Posts: 30 Location: chennai
|
|
|
|
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 |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
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 |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
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 |
|
|
charavind17
New User
Joined: 24 Sep 2008 Posts: 30 Location: chennai
|
|
|
|
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 |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
charavind17,
What about the input/output LRECL? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
charavind17
New User
Joined: 24 Sep 2008 Posts: 30 Location: chennai
|
|
|
|
this is the output i only need
output file:
b230 002k41640 20080805I+000000004
b230 005k05250 20080808I+000000003 |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
charavind17
New User
Joined: 24 Sep 2008 Posts: 30 Location: chennai
|
|
|
|
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 |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|