View previous topic :: View next topic
|
Author |
Message |
SRUTHI DRAVIDAMANI
New User
Joined: 31 Jan 2018 Posts: 7 Location: INDIA
|
|
|
|
how to add the amount for duplicate records and write it in a single record in cobol program?
For ex:
Inp:
1)empid15 account15 amt100
2)empid15 account15 amt100
Out:
1)empid15 account15 amt200 |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
Easy - what is your problem? And why use COBOL when you could use your sort product? |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Maybe a candidate for the rookie forum ? |
|
Back to top |
|
|
SRUTHI DRAVIDAMANI
New User
Joined: 31 Jan 2018 Posts: 7 Location: INDIA
|
|
|
|
because i have five files and im converting that into ten files as header and detail records separately. So i need to do this process for all ten files. |
|
Back to top |
|
|
SRUTHI DRAVIDAMANI
New User
Joined: 31 Jan 2018 Posts: 7 Location: INDIA
|
|
|
|
Can someone tell the program logic? i need to do this in COBOL only that is the requirement. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
Quote: |
how to add the amount for duplicate records and write it in a single record in cobol program? |
Quote: |
because i have five files and im converting that into ten files as header and detail records separately. |
unless the TS comes up with a reasonable description of the requirement the topic will be locked |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3048 Location: NYC,USA
|
|
|
|
Code: |
set first-record-read to true
initialize ws-amt
Read input DS until end
if not end of DS
If first-record-read
move ws-in-empid to ws-previous-empid
move ws-in-empid to ws-current-empid
else
move ws-in-empid to ws-current-empid
end-if
if ws-previous-empid = ws-current-empid
compute ws-amt = ws-amt+ amt100
second-record-read to true
else
write out DS based on ws-previous-empid and ws-amt
move ws-in-emp id to ws-previous-empid
initialize ws-amt
compute ws-amt = ws-amt+ amt100
end-if
else
If second-record-read
write out DS based on ws-previous-empid and ws-amt
end-if
end-if
|
|
|
Back to top |
|
|
rajesh_mbt
New User
Joined: 27 Mar 2006 Posts: 97 Location: India
|
|
|
|
Rohit Umarjikar wrote: |
Code: |
set first-record-read to true
initialize ws-amt
Read input DS until end
if not end of DS
If first-record-read
move ws-in-empid to ws-previous-empid
move ws-in-empid to ws-current-empid
else
move ws-in-empid to ws-current-empid
end-if
if ws-previous-empid = ws-current-empid
compute ws-amt = ws-amt+ amt100
second-record-read to true
else
write out DS based on ws-previous-empid and ws-amt
move ws-in-emp id to ws-previous-empid
initialize ws-amt
compute ws-amt = ws-amt+ amt100
end-if
else
If second-record-read
write out DS based on ws-previous-empid and ws-amt
end-if
end-if
|
|
Can someone tell me whether any other better logic in cobol to achieve this scenario... |
|
Back to top |
|
|
rajesh_mbt
New User
Joined: 27 Mar 2006 Posts: 97 Location: India
|
|
|
|
[quote="Rohit Umarjikar[/quote]
This logic will not work for all the scenarios |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
Quote: |
This logic will not work for all the scenarios |
How does it not work for the scenario that it was designed for?
If your scenario is the same then the logic should work. If your scenario is different then, of course, it will not work - you need a different algorithm.
But as you have just tagged onto an old topic with no details what do you expect in the way of help? |
|
Back to top |
|
|
|