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

Strange output with COMP-3 variable. Expecting SOC7 but got


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Harsh Pawar

New User


Joined: 04 Jun 2008
Posts: 25
Location: Noida

PostPosted: Fri Feb 17, 2012 10:26 am
Reply with quote

I found a strange thing in one of our code. Although it seems very basic but I could not understand why it is not giving SOC7:

Code:
05 I-AM-COMP3               PIC S9(4)  COMP-3.             
05 ABCD                     PIC X(3).                     
 
PROCEDURE DIVISION.       
     DISPLAY  I-AM-COMP3                         
*SOC7                                             
     MOVE 'XYZ'                  TO ABCD         
     MOVE ABCD                   TO I-AM-COMP3   
     DISPLAY  'ABCD : '          ABCD             
     DISPLAY  'I-AM-COMP3: '     I-AM-COMP3       
     ADD  2                      TO I-AM-COMP3   
     DISPLAY  'I-AM-COMP3:+2 '     I-AM-COMP3     
*                                             


It compiled and run without any abend. I was expecting a SOC7 since 'XYZ' is getting moved to a packed field. I got following output:

Code:
0000                                       
ABCD : XYZ                 
I-AM-COMP3: 0789           
I-AM-COMP3:+2 0791         
 

This could be because XYZ = hex of E7E8E9 and if we pack XYZ it gives 789E which is a positive number. But should;nt it give SOC7 in COBOL ??
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Fri Feb 17, 2012 11:15 am
Reply with quote

Please go through below links of similar topics that have been discussed on the forum before.
http://ibmmainframes.com/archive/o_t__t_23275__start_0__index.html
http://www.ibmmainframes.com/viewtopic.php?t=19789

Let us know if you have further questions.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Fri Feb 17, 2012 12:27 pm
Reply with quote

Almost 4 years on the forum and you do not know how to search? And you have not read the other threads on this topic which comes up every month or so with COMPLETE information as to what is going on? If you visit the forum every day and read ALL the new stuff, even if it is not related to what you do, you will learn. I am always learning from the fora
Back to top
View user's profile Send private message
Harsh Pawar

New User


Joined: 04 Jun 2008
Posts: 25
Location: Noida

PostPosted: Fri Feb 17, 2012 1:06 pm
Reply with quote

My Apologies Nic.
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 TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Joinkeys - 5 output files DFSORT/ICETOOL 7
No new posts Build a record in output file and rep... DFSORT/ICETOOL 11
Search our Forums:

Back to Top