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
 
Cobol addition with comma delimited inputs

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
rajaseelan j

New User


Joined: 05 Apr 2012
Posts: 1
Location: India

PostPosted: Thu Apr 05, 2012 11:43 am    Post subject: Cobol addition with comma delimited inputs
Reply with quote

How to add 5 numbers in cobol with input 1,2,3,4,5 in the same line?

Reading input delimited by comma in same line in cobol so that input is like

For EX:

Input: 1,2,3,4,5 using keyboard

And the output should come as 15
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7314

PostPosted: Thu Apr 05, 2012 12:14 pm    Post subject: Reply to: Cobol addition with comma delimited inputs
Reply with quote

If you browse the Cobol forum where you have posted you'll see some relevant topics.

Look at things like UNSTRING, STRING, INSPECT and NUMVAL in the Cobol manuals (link at the top of the page).
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7314

PostPosted: Thu Apr 05, 2012 12:47 pm    Post subject: Reply to: Cobol addition with comma delimited inputs
Reply with quote

OK, I assume you've done all that now.

Can be tricky and is error-prone.

Go back to the spec-writer and see if you can get this done.

"Pre-process" your input file with your SORT product. Use PARSE to put the fields into fixed positions of fixed length. In your program, check that each is numeric, rejecting appropriately if not, then add them all up in the normal way. It'll make things easier all around, especially if the input file is used in more than one place.
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
This topic is locked: you cannot edit posts or make replies. Cobol to fetch the content by using s... arunc55 COBOL Programming 4 Fri Nov 17, 2017 1:25 pm
No new posts VBS and VB, COBOL syntax is the same ... natt.sut COBOL Programming 3 Sun Nov 12, 2017 6:36 am
No new posts COBOL - EXIT statement weird behavior anthony.pangestu COBOL Programming 0 Fri Oct 27, 2017 9:57 am
No new posts IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts Addition of two records on 2 fields amar143 SYNCSORT 8 Tue Oct 03, 2017 11:14 am

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