View previous topic :: View next topic
|
Author |
Message |
tecnokrat Warnings : 1 Active User
Joined: 22 May 2009 Posts: 160 Location: Bangalore
|
|
|
|
Hi all,
I have encountered a problem
i have a PIC X (02) FIELD which has the value say '03'.
Now i have to move this value to a PIC S9(04) COMP field
probably it should also have the same value +02 but its getting a value +00200 in it.
Can you please help me in this like how to get the same value as that of X(02). |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
tecnokrat wrote: |
i have a PIC X (02) FIELD which has the value say '03'. |
Say or really?
Quote: |
probably it should also have the same value +02 but its getting a value +00200 in it. |
Probably or really?
What is the value in the X(02) field and after the move, what is the value in the S9(04) COMP field?
Quote: |
Can you please help me in this like how to get the same value as that of X(02). |
A simple move should do it......
Please post the actual fields and the move statement. |
|
Back to top |
|
|
tecnokrat Warnings : 1 Active User
Joined: 22 May 2009 Posts: 160 Location: Bangalore
|
|
|
|
PIC X(02) FIELD has value exactly '02'
now if i move this field to a PIC S9(04) COMP FIELD
the value in this PIC S9(04) FIELD HAS '+00200' in it. |
|
Back to top |
|
|
Ranjithkumar
New User
Joined: 10 Sep 2008 Posts: 93 Location: India
|
|
|
|
With the following code,
Code: |
WORKING-STORAGE SECTION.
01 WS-TEXT-VAR PIC X(2).
01 WS-NUMB-VAR PIC S9(02).
01 WS-COMP-VAR PIC S9(04) COMP.
PROCEDURE DIVISION.
MOVE '03' TO WS-TEXT-VAR.
MOVE WS-TEXT-VAR TO WS-COMP-VAR WS-NUMB-VAR.
DISPLAY 'TEXT FORMAT -- ' WS-TEXT-VAR.
DISPLAY 'COMP FORMAT -- ' WS-COMP-VAR.
DISPLAY 'NUMB FORMAT -- ' WS-NUMB-VAR.
MOVE WS-NUMB-VAR TO WS-COMP-VAR.
DISPLAY 'COMP FORMAT2-- ' WS-COMP-VAR.
STOP RUN. |
I got the following display in SYSOUT.
Code: |
TEXT FORMAT -- 03
COMP FORMAT -- 00003
NUMB FORMAT -- 0C
COMP FORMAT2-- 00003 |
It should be working fine. Can you show us the code as well as variable definition you have used in your program? |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
77 FROM-FIELD PIC X(02) VALUE '02'.
77 TO-FIELD PIC S9(04).
DISPLAY '*' FROM-FIELD '*'.
MOVE FROM-FIELD TO TO-FIELD.
DISPLAY '*' TO-FIELD '*'.
*02*
*0002*
Where does the above code differ from your code? |
|
Back to top |
|
|
tecnokrat Warnings : 1 Active User
Joined: 22 May 2009 Posts: 160 Location: Bangalore
|
|
|
|
Hi all, i found the cause for it
Thanks for the input.
The fields was of X(04) which was having '02__'
and now if this field was moved to a S9(04) COMP field it was taking '+0200' in it.
So the possible answer i got was to reference modification.
taking the first two bytes of a X(04) variable and moving into a S9(04) COMP field.
possible learning from this : X field are left justified and 9 fields are right justified. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
your POSSIBLE LEARNING is actually basic knowledge
that would be acquired by reading a manual before trying to lay code.
why don't you use NUMVAL? - which is also in the manual that you have not read. |
|
Back to top |
|
|
|