Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
tecnokrat
Warnings : 1

Active User


Joined: 22 May 2009
Posts: 158
Location: Bangalore

PostPosted: Mon Apr 05, 2010 12:16 pm    Post subject: Movement of X field to a S9(04) comp field
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: 2150
Location: At my coffee table

PostPosted: Mon Apr 05, 2010 12:39 pm    Post subject:
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: 158
Location: Bangalore

PostPosted: Mon Apr 05, 2010 12:48 pm    Post subject:
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: 94
Location: India

PostPosted: Mon Apr 05, 2010 12:59 pm    Post subject: Reply to: Movement of X field to a S9(04) comp field
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: 2150
Location: At my coffee table

PostPosted: Mon Apr 05, 2010 1:01 pm    Post subject:
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: 158
Location: Bangalore

PostPosted: Mon Apr 05, 2010 2:52 pm    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts INVALID FIELD OR CONSTANT IN SORTOF ?? Ron Klop DFSORT/ICETOOL 8 Wed Jan 11, 2017 3:44 pm
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 31 Tue Dec 06, 2016 8:04 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us