View previous topic :: View next topic |
Author |
Message |
vijay_bc Beginner
Joined: 22 Aug 2006 Posts: 4 Topics: 2
|
Posted: Tue Aug 22, 2006 12:10 pm Post subject: moving values to comp-3 value |
|
|
Hi,
I want to do the below move operation.
**********************
01 disp-Variable01 PIC -9(6).9(2) value -000022.50.
01 comp-variable01 PIC S9(6)V9(2) usage comp-3.
Move disp-variable01 to comp-variable01.
**********************
But i'm gettin' an abend '4038'. Is it possible to do the above move operation? Please suggest me your options.
Thanks
Vijay |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Tue Aug 22, 2006 12:26 pm Post subject: |
|
|
vijay_bc,
try this
Code: |
01 DISP-VARIABLE01 PIC -9(6).9(2).
01 COMP-VARIABLE01 PIC S9(6)V9(2) USAGE COMP-3.
MOVE -22.50 TO DISP-VARIABLE01
MOVE DISP-VARIABLE01 TO COMP-VARIABLE01.
|
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
shekar123 Advanced
Joined: 22 Jul 2005 Posts: 528 Topics: 90 Location: Bangalore India
|
Posted: Tue Aug 22, 2006 1:26 pm Post subject: |
|
|
vijay_bc,
If you try printing the values you will get:
Code: |
DISP-VARIABLE01 -000022.50
COMP-VARIABLE01 0000225}
|
Use this sheat to interpret the values:
Code: |
**********************************************************************
* VALUES: *
* 1 = A -1 = J EXAMPLES: NUMBER REPRESENTATION *
* 2 = B -2 = K 10 00000001{ *
* 3 = C -3 = L 105 00000010E *
* 4 = D -4 = M 0 00000000{ *
* 5 = E -5 = N -234 00000023M *
* 6 = F -6 = O -30 00000003} *
* 7 = G -7 = P *
* 8 = H -8 = Q *
* 9 = I -9 = R *
* 0 = { -0 = } *
**********************************************************************
For example:
0000225} would be -00002250 as -0 stands for } and the sign is punched on the last nibble byte.
21L would be -21.3
04E would be 4.5
+---------------------------------------------------------------+
| Last Character will be | |
| represented as below for.. | 0 1 2 3 4 5 6 7 8 9 |
+---------------------------------------------------------------+
| If the Number is +ve | { A B C D E F G H I |
+---------------------------------------------------------------+
| If the Number is -ve | } J K L M N O P Q R |
+---------------------------------------------------------------+
|
_________________ Shekar
Grow Technically |
|
Back to top |
|
 |
js01 Beginner
Joined: 13 Oct 2005 Posts: 84 Topics: 32 Location: INDIA
|
Posted: Tue Aug 22, 2006 11:38 pm Post subject: |
|
|
kolusu,
why the VALUE clause is not working for first variable.
is there any restriction, plz advise.
thank you |
|
Back to top |
|
 |
vijay_bc Beginner
Joined: 22 Aug 2006 Posts: 4 Topics: 2
|
Posted: Wed Aug 23, 2006 5:59 am Post subject: |
|
|
Hi
thnx for ur inputs. the above examples are absolutely fine.
here we have the actual scenario where we want to store the comp-3 value in db2.
VAR-01 is retreived from a java front end. it sends it as string.
***********************
01 var-01 pic -9(6).9(2)
01 var-02 pic 9(6)V9(2)
01 var-03 pic s9(6)v9(2) comp-3.
Move var-01 to var-02
Move var-02 to var-03.
*************************
Is there a way to acheive this? I guess we need to manipualte the DOT. but still, without that, is there any way where we can directly acheive this? i feel the cobol should allow this as this is very normal in real time sceanrio. Guys, please give ur imputs.
thanks
Vijay |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Wed Aug 23, 2006 7:35 am Post subject: |
|
|
js01 wrote: | kolusu,
why the VALUE clause is not working for first variable.
is there any restriction, plz advise.
thank you |
says who ? if the item is defined as PICTURE +999.99 and the value is to be +12.34, then the VALUE clause should be specified as VALUE "+012.34".
so in this case it would be
Code: |
01 DISP-VARIABLE01 PIC -9(6).9(2) VALUE '-000022.50'.
|
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Wed Aug 23, 2006 7:39 am Post subject: |
|
|
vijay_bc wrote: | VAR-01 is retreived from a java front end. it sends it as string.
***********************
01 var-01 pic -9(6).9(2)
01 var-02 pic 9(6)V9(2)
01 var-03 pic s9(6)v9(2) comp-3.
Move var-01 to var-02
Move var-02 to var-03.
*************************
Is there a way to acheive this? I guess we need to manipualte the DOT. but still, without that, is there any way where we can directly acheive this? i feel the cobol should allow this as this is very normal in real time sceanrio. Guys, please give ur imputs.
|
Vijay,
Just make sure that you receive the string from JAVA with padded zeroes. ie. the string should be as follows
Now you can move this directly to comp-3 variable.
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
vijay_bc Beginner
Joined: 22 Aug 2006 Posts: 4 Topics: 2
|
Posted: Wed Aug 23, 2006 11:08 am Post subject: |
|
|
Hi Kolusu,
java front end always sends a complete string (with padded zeros).
The above stuff is working fine with the below piece of code
Code: |
01 var-01 pic X(10)
01 filler redefines var-01.
05 ws-cde-sign Pic x(1)
05 ws-6-digits Pic 9(6)
05 ws-decimal Pic x(1)
05 ws-2-digits Pic 9(2)
01 var-02 Pic 9(08)
01 var-03 redefines var-02 pic 9(6)V9(2).
01 var-04 pic s9(6)v9(2) comp-3.
compute var-02 = (100 * ws-6-digits) + ws-2-digits
move var-03 to var-04
If ws-cde-sign = '-'
compute var-04 = var-04 * -1
end-if
**************************
|
Thanks for all of ur inputs.
Cheers
Vijay |
|
Back to top |
|
 |
|
|