View previous topic :: View next topic
|
Author |
Message |
jijesh
New User
Joined: 09 May 2006 Posts: 4
|
|
|
|
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 |
|
|
annujp
New User
Joined: 31 Aug 2005 Posts: 39 Location: St Paul,MN
|
|
|
|
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.... |
|
Back to top |
|
|
UmeySan
Active Member
Joined: 22 Aug 2006 Posts: 771 Location: Germany
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
jijesh
New User
Joined: 09 May 2006 Posts: 4
|
|
|
|
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 |
|
|
UmeySan
Active Member
Joined: 22 Aug 2006 Posts: 771 Location: Germany
|
|
|
|
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 |
|
|
jijesh
New User
Joined: 09 May 2006 Posts: 4
|
|
|
|
Thanks Umey
i'll try the same. |
|
Back to top |
|
|
|