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

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


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 8697
Location: Dubuque, Iowa, USA

PostPosted: Tue Jun 02, 2009 7:30 pm
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: 8797
Location: Welsh Wales

PostPosted: Tue Jun 02, 2009 7:31 pm
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
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
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
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
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
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: 8697
Location: Dubuque, Iowa, USA

PostPosted: Wed Jun 03, 2009 7:41 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts Generate output lines (SYSIN card for... DFSORT/ICETOOL 4
Search our Forums:

Back to Top