Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

HOW TO ADD TWO S9(11)V9(04) VALUES

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

New User


Joined: 20 May 2009
Posts: 38
Location: India

PostPosted: Tue Jun 02, 2009 7:27 pm    Post subject: HOW TO ADD TWO S9(11)V9(04) VALUES
Reply with quote

HI EVERYONE,


I HAVE

var1 PIC S9(11)V9(04) VALUE 0.
var2 PIC S9(11)V9(04) VALUE 0.
var3 PIC S9(11)V9(04) VALUE 0.

is it possible to add var1 and var2 and giving var3?
var3=var1+var2

if so,how to code it?

when i add i am getting 0 values to var3.
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7935
Location: Bellevue, IA

PostPosted: Tue Jun 02, 2009 7:30 pm    Post subject:
Reply with quote

Show your exact code, please.

If var1 has a value of zero, and you add a zero in var2 to it, you SHOULD get a value of zero in var3. Based on what you've posted, there's no problem here.

Code:
COMPUTE VAR3 = VAR1 + VAR2
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Tue Jun 02, 2009 7:31 pm    Post subject:
Reply with quote

I can recall using the COMPUTE statement back in the dark and distant past when I last played COBOL.

COMPUTE VAR3 = VAR1 + VAR2.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Jun 02, 2009 7:38 pm    Post subject: Re: HOW TO ADD TWO S9(11)V9(04) VALUES
Reply with quote

services wrote:
HI EVERYONE,


I HAVE

var1 PIC S9(11)V9(04) VALUE 0.
var2 PIC S9(11)V9(04) VALUE 0.
var3 PIC S9(11)V9(04) VALUE 0.

is it possible to add var1 and var2 and giving var3?
var3=var1+var2

if so,how to code it?

when i add i am getting 0 values to var3.


Have you looked in the cobol manuals?

Code:
ADD VAR1 TO VAR2 GIVING VAR3.
or
COMPUTE VAR3 = VAR1 + VAR2.

If var1 and var2 are zero then var3 would be zero!
Back to top
View user's profile Send private message
Itanium

Active User


Joined: 22 Jan 2006
Posts: 114
Location: India

PostPosted: Wed Jun 03, 2009 6:42 pm    Post subject:
Reply with quote

opened this question out of curiosity... still wondering why such question was raised and surprisingly there were 3 replies. hari, you are lucky.
Back to top
View user's profile Send private message
services

New User


Joined: 20 May 2009
Posts: 38
Location: India

PostPosted: Wed Jun 03, 2009 6:57 pm    Post subject:
Reply with quote

i had doubt for adding two PIC S9(11)V9(04) and i got the result is zero, that is the reason i raised this question..
Back to top
View user's profile Send private message
Itanium

Active User


Joined: 22 Jan 2006
Posts: 114
Location: India

PostPosted: Wed Jun 03, 2009 7:00 pm    Post subject:
Reply with quote

still you are fuzzy, can you post the code relvant to this for others to get into a conclusion and find a solution.
Back to top
View user's profile Send private message
services

New User


Joined: 20 May 2009
Posts: 38
Location: India

PostPosted: Wed Jun 03, 2009 7:29 pm    Post subject:
Reply with quote

Code:
MOVE WS-RECEIVING-ORP TO WS-COST-POOL.                     
COMPUTE WS-SET-MATERIAL-COST ROUNDED =                     
  RECEIVING-BASE OF WS-SCHEDULE-TABLE                     
        (DLV-IDX, CUST-IDX, RATE-IDX, SHOP-IDX, MATL-IDX).
MOVE 'M' TO WS-WRITE-COST-TYPE-SW.                         
PERFORM 7000-WRITE-TO-COST-FILE THRU 7000-EXIT.           

above is the code

when i receive the WS-RECEIVING-ORP = 697
i have to add the price of WS-RECEIVING-ORP = 523 and WS-RECEIVING-ORP = 512 and replace the price values
WS-RECEIVING-ORP = 697
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7935
Location: Bellevue, IA

PostPosted: Wed Jun 03, 2009 7:41 pm    Post subject:
Reply with quote

The benefits of posting actual code instead of interpreting! Conflicting with the original post, what you posted has no additions in it, so the question becomes exactly what do you think this code is doing?
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 SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts Overlaying one set of charater values... Kevin Lindsley SYNCSORT 7 Sat Nov 05, 2016 3:21 am
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm
No new posts Using 'parm' to vary SORTOUT record v... Sysaron DFSORT/ICETOOL 13 Wed Sep 07, 2016 9:24 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us