IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Movement of X field to a S9(04) comp field


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
tecnokrat
Warnings : 1

Active User


Joined: 22 May 2009
Posts: 160
Location: Bangalore

PostPosted: Mon Apr 05, 2010 12:16 pm
Reply with quote

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

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Mon Apr 05, 2010 12:39 pm
Reply with quote

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
View user's profile Send private message
tecnokrat
Warnings : 1

Active User


Joined: 22 May 2009
Posts: 160
Location: Bangalore

PostPosted: Mon Apr 05, 2010 12:48 pm
Reply with quote

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

New User


Joined: 10 Sep 2008
Posts: 93
Location: India

PostPosted: Mon Apr 05, 2010 12:59 pm
Reply with quote

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

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Mon Apr 05, 2010 1:01 pm
Reply with quote

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
View user's profile Send private message
tecnokrat
Warnings : 1

Active User


Joined: 22 May 2009
Posts: 160
Location: Bangalore

PostPosted: Mon Apr 05, 2010 2:52 pm
Reply with quote

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

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Apr 05, 2010 5:08 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Join 2 files according to one key field. JCL & VSAM 3
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts S0C7 - Field getting overlayed COBOL Programming 2
Search our Forums:

Back to Top