Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
how to add the amount for duplicate records and write

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: how to add the amount for duplicate records and write
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: 2033
Location: UK

PostPosted: Wed Feb 21, 2018 7:26 pm    Post subject:
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: 8697
Location: Back in jolly old England

PostPosted: Wed Feb 21, 2018 7:56 pm    Post subject:
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    Post subject: Hi Nic
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    Post subject:
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

Senior Member


Joined: 14 Mar 2007
Posts: 10487
Location: italy

PostPosted: Wed Feb 21, 2018 10:44 pm    Post subject: Reply to: how to add the amount for duplicate records and write
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

Senior Member


Joined: 21 Sep 2010
Posts: 1940
Location: NY,USA

PostPosted: Thu Feb 22, 2018 1:10 am    Post subject:
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    Post subject:
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    Post subject:
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: 2033
Location: UK

PostPosted: Sat Jun 30, 2018 3:34 pm    Post subject: Reply to: how to add the amount for duplicate records and write
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    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 Need Help to Create 4 Output Records ... satish.ms10 DFSORT/ICETOOL 4 Thu Jul 19, 2018 1:55 am
No new posts Remove duplicate record with condition rajiv rengasamy DFSORT/ICETOOL 4 Wed Jul 11, 2018 3:55 pm
No new posts MXG - Processing Compressed DB2 SMF r... vasanthz All Other Mainframe Topics 2 Thu May 10, 2018 12:47 am
No new posts Duplicate PARM on OUTFIL sancraig16 SYNCSORT 11 Thu Apr 05, 2018 10:25 pm
No new posts Extract the records with a PD field's... sudhakar84 DFSORT/ICETOOL 11 Mon Apr 02, 2018 7:26 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us