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

how to add the amount for duplicate records and write


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
SRUTHI DRAVIDAMANI

New User


Joined: 31 Jan 2018
Posts: 7
Location: INDIA

PostPosted: Wed Feb 21, 2018 7:21 pm
Reply with quote

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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Wed Feb 21, 2018 7:26 pm
Reply with quote

Easy - what is your problem? And why use COBOL when you could use your sort product?
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed Feb 21, 2018 7:56 pm
Reply with quote

Maybe a candidate for the rookie forum ?
Back to top
View user's profile Send private message
SRUTHI DRAVIDAMANI

New User


Joined: 31 Jan 2018
Posts: 7
Location: INDIA

PostPosted: Wed Feb 21, 2018 8:41 pm
Reply with quote

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
View user's profile Send private message
SRUTHI DRAVIDAMANI

New User


Joined: 31 Jan 2018
Posts: 7
Location: INDIA

PostPosted: Wed Feb 21, 2018 10:22 pm
Reply with quote

Can someone tell the program logic? i need to do this in COBOL only that is the requirement.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Wed Feb 21, 2018 10:44 pm
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Thu Feb 22, 2018 1:10 am
Reply with quote

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
View user's profile Send private message
rajesh_mbt

New User


Joined: 27 Mar 2006
Posts: 97
Location: India

PostPosted: Sat Jun 30, 2018 2:43 am
Reply with quote

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
View user's profile Send private message
rajesh_mbt

New User


Joined: 27 Mar 2006
Posts: 97
Location: India

PostPosted: Sat Jun 30, 2018 3:02 am
Reply with quote

[quote="Rohit Umarjikar[/quote]

This logic will not work for all the scenarios icon_sad.gif
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Sat Jun 30, 2018 3:34 pm
Reply with quote

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
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 Duplicate transid's declared using CEDA CICS 3
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Join multiple records using splice DFSORT/ICETOOL 5
Search our Forums:

Back to Top