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
 
Performing calculations using Signed variables

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

New User


Joined: 09 May 2006
Posts: 4

PostPosted: Mon Oct 30, 2006 4:50 pm    Post subject: Performing calculations using Signed variables
Reply with quote

Hi I need some light to be thrown on using Signed variables.

in my program i am using signed variables for calculation. in the input file has the amount field is defined as:
IN-AMT-VAR 9(9)V99
IN-AMT-SIGN X(01)
the amount and its sign are defined seperately. i have to do some calculations by taking them together. i redefined the layout and tried to read input record into a signed variable IN-AMT-TEMP S9(9)V99.

while computing i am getting SOC7 error. How should i proceed???

Also i want to read the signed variable back to the same input layout i.e. as amount seperate and sign seperate.
Back to top
View user's profile Send private message

annujp

New User


Joined: 31 Aug 2005
Posts: 39
Location: St Paul,MN

PostPosted: Mon Oct 30, 2006 5:06 pm    Post subject:
Reply with quote

What you can do is
set a flag (positive or negative) by checking the sign variable. If the sign variable is "-" then you can multiply the amount value variable by -1 and store it the result in a signed variable.
At the end of the program, you can check the value of this variable. If <0 move "-" to the sign variable and write it into the file.

Guys...please let me know if there is any other method to do this.... icon_biggrin.gif
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 757
Location: Germany

PostPosted: Mon Oct 30, 2006 5:41 pm    Post subject:
Reply with quote

Hi !

Use comp-3 fields.

Before moving test your sign-flag and if negative do multipy with -1.
Then for all other aritmethic funktions use the comp-3 fields.

Regards, UmeySan
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Tue Oct 31, 2006 7:34 am    Post subject:
Reply with quote

You could also define your 2 fields as subordinate to an 01 level then redefine it as a sign is separate trailing variable:
Code:

01  var-w-sign.
      05  IN-AMT-VAR   pic 9(9)V99.
      05  IN-AMT-SIGN  pic X(01).   
01  sign-is-sep-var    redefines
      var-w-sign       pic 9(9)v99 sign separate trailing.
Back to top
View user's profile Send private message
jijesh

New User


Joined: 09 May 2006
Posts: 4

PostPosted: Tue Nov 07, 2006 4:26 pm    Post subject: Re: Performing calculations using Signed variables
Reply with quote

Thanks guys for the suggestions.

i tried the first one and it worked. thanks a lot.

i had previuosly tried the 3rd option also (i.e.) redefining the structure but didnt work.

i have another similar issue, where i did the following operation

C = A/B

where
C = V9(6)
A = 9(07)V99
B = 9(10)V99

i tried
(i) redefining the structure of A as similar to B.
(ii) declared a new group varaible D and tried to move the values in A to D as:
01 D-varaible
05 D1-var 9(10).
05 D2-var V99.
01 A-varaible
05 A1-var 9(07).
05 A2-var V99.
and then tried to move the A values to the respective D values and finally used D in place of A in the formula.

both the approaches didnt work. what can i do to do the manipulation.????
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 757
Location: Germany

PostPosted: Tue Nov 07, 2006 4:37 pm    Post subject:
Reply with quote

Hi !

Coming back to my suggestion.
Why don't using signed comp-3 fields.

Field Pic S9(16)V9(02)

Before moving test your sign-flag and if negative do multipy with -1.
Then for all other aritmethic funktions use the comp-3 fields.

Plse, prefer simple solutions. Do not make it too complicated.

Regards, UmeySan
Back to top
View user's profile Send private message
jijesh

New User


Joined: 09 May 2006
Posts: 4

PostPosted: Tue Nov 07, 2006 6:16 pm    Post subject:
Reply with quote

Thanks Umey

i'll try the same.
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 DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 8 Wed Jan 25, 2017 8:24 pm
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 0 Wed Jan 25, 2017 8:23 pm
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 0 Wed Jan 25, 2017 8:21 pm
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 37 Tue Dec 06, 2016 8:04 pm
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm

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