MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

moving values to comp-3 value

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
vijay_bc
Beginner


Joined: 22 Aug 2006
Posts: 4
Topics: 2

PostPosted: Tue Aug 22, 2006 12:10 pm    Post subject: moving values to comp-3 value Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Aug 22, 2006 12:26 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Tue Aug 22, 2006 1:26 pm    Post subject: Reply with quote

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
View user's profile Send private message
js01
Beginner


Joined: 13 Oct 2005
Posts: 84
Topics: 32
Location: INDIA

PostPosted: Tue Aug 22, 2006 11:38 pm    Post subject: Reply with quote

kolusu,

why the VALUE clause is not working for first variable.
is there any restriction, plz advise.

thank you
Back to top
View user's profile Send private message
vijay_bc
Beginner


Joined: 22 Aug 2006
Posts: 4
Topics: 2

PostPosted: Wed Aug 23, 2006 5:59 am    Post subject: Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Aug 23, 2006 7:35 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Aug 23, 2006 7:39 am    Post subject: Reply with quote

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
Code:

-000022.50


Now you can move this directly to comp-3 variable.

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vijay_bc
Beginner


Joined: 22 Aug 2006
Posts: 4
Topics: 2

PostPosted: Wed Aug 23, 2006 11:08 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group