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

Move LOW VALUES to COMP-3 Variable


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

New User


Joined: 24 Jan 2006
Posts: 12

PostPosted: Tue Apr 04, 2006 11:25 am
Reply with quote

Hi,

CAN I MOVE LOWVALUES TO A COMP-3 VARIABLE.

Thanks
Madhu K
Back to top
View user's profile Send private message
harish_mf

New User


Joined: 31 Jul 2005
Posts: 18
Location: bangalore

PostPosted: Tue Apr 04, 2006 11:58 am
Reply with quote

i think its not possible, u may get some soc error.
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Tue Apr 04, 2006 2:44 pm
Reply with quote

u can move low values to comp-3.
Back to top
View user's profile Send private message
perez_a

New User


Joined: 02 Feb 2006
Posts: 25
Location: Italy

PostPosted: Tue Apr 04, 2006 5:08 pm
Reply with quote

I Madhu, U CAN MOVE LOW-VALUE TO A COM-3 VARIABLE.
BELOW I SEND U AN EXAMPLE.
BYE BYE.

WORKING-STORAGE SECTION.

01 NUMA PIC 9(05) COMP-3 VALUE 3.

PROCEDURE DIVISION.
MOVE LOW-VALUE TO NUMA
ADD 1 TO NUMA
DISPLAY 'NUMA ' NUMA
MOVE 3 TO NUMA
DISPLAY 'NUMA ' NUMA
--------------------------------------------------------------------
RESULT:

NUMA 00001
NUMA 00003
Back to top
View user's profile Send private message
martin9

Active User


Joined: 01 Mar 2006
Posts: 290
Location: Basel, Switzerland

PostPosted: Tue Apr 04, 2006 6:02 pm
Reply with quote

hy madhugoodboy,

if you have a comp-3 unsigned,
just move zero to the variable.
if you look at the hex-value,
it is low-value...

martin9

PS: madhu = honey??
Back to top
View user's profile Send private message
ap_mainframes

Active User


Joined: 29 Dec 2005
Posts: 181
Location: Canada

PostPosted: Tue Apr 04, 2006 6:21 pm
Reply with quote

yes..martin is spot on.
you can move low-values in comp3.
also for unsigned just move zeroes.

ap_mainframes
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Tue Apr 04, 2006 7:13 pm
Reply with quote

Madhu K,

In response to perez_a. At least under the Enterprise Cobol 3.1.0 you cannot move low-values to a comp-3 field, and I believe this is not possible under any IBM Cobol compiler.

perez_a, What compiler version are you running under?

Code:


     005800 WORKING-STORAGE SECTION.                                           
     004515                                                                   
     002710 01 NUMA PIC 9(05) COMP-3 VALUE 3.                                 
     002800                                                                   
     015900 LINKAGE SECTION.                                                   
                                                                               
IBM ENTERPRISE COBOL FOR Z/OS AND OS/390 3.1.0     COBPTR    DATE 04/04/2006  T
 SL  ----+-*A-1-B--+----2----+----3----+----4----+----5----+----6----+----7-|--
     041400 PROCEDURE DIVISION.                                               
     033300                                                                   
     042110     MOVE LOW-VALUE TO NUMA                                         
                                                                               
IGYPA3005-S "LOW-VALUE" AND "NUMA (PACKED INTEGER)" DID NOT FOLLOW THE "MOVE"              STATEMENT COMPATIBILITY RULES.  THE STATEMENT WAS DISCARDED.       
                                                                               
     042120     ADD 1 TO NUMA                                                 
     042130     DISPLAY 'NUMA ' NUMA                                           
     042140     MOVE 3 TO NUMA                                                 
     042150     DISPLAY 'NUMA ' NUMA                                           
     042130                                                                   
                MOVE 0           TO RETURN-CODE.   



And, in response to martin9. Moving zero (0) to an unsigned comp-3 field does not result in vow-values. It results in an unsigned comp-3 value x?00000F?. The redefines below is in place so there is no data conversion during the ?DISPLAY?.


Code:

  000019         005800 WORKING-STORAGE SECTION.                     
  000020**       004515                                               
  000021**       002710 01 NUMA PIC 9(05) COMP-3 VALUE 3.             
  000022         002720 01 NUMX REDEFINES NUMA PIC X(3).             
                                                                     
  000023         002800                                               
  000024         015900 LINKAGE SECTION.                             
SARPAGE 20                                                           
PP 5655-G53 IBM ENTERPRISE COBOL FOR Z/OS AND OS/390 3.1.0     COBPTR
  LINEID  PL SL  ----+-*A-1-B--+----2----+----3----+----4----+----5---
  000026         041400 PROCEDURE DIVISION.                           
  000027**       033300                                               
  000028         042110     MOVE 0         TO NUMA                   
  000029         042120     DISPLAY 'NUMX = ' NUMX.                   
  000030         042130                                               
  000031                    MOVE 0           TO RETURN-CODE.         
  000032         042140                                               
  000033**       006731     GOBACK.                                   
  000034         006732                                               

Result of running the above code.

Code:

.NUMX = ...       
0DEDE474000       
154470E000F       


One way to get low-values to a comp-3 field is to redefine it as above and move low values to the ?PIC X? field. But, this does not satisfy your question.

Another way is if the COMP-3 is defined as an elemental item, then you can move ?LOW-VALUES? to the group item (that is defined by default as ?PIC X?) example below

Code:


.  000019         005800 WORKING-STORAGE SECTION.                               
.  000020**       004515                                                       
.  000021**       002701 01  WS-GROUP1.                                         
.  000022         002710     05 NUMA                PIC 9(05) COMP-3 VALUE 3.   
.  000023         002720     05 NUMX REDEFINES NUMA PIC X(3).                   
.                                                                               
.  000024         002800                                                       
.  000025         015900 LINKAGE SECTION.                                       
.SARPAGE 20                                                                     
.PP 5655-G53 IBM ENTERPRISE COBOL FOR Z/OS AND OS/390 3.1.0     COBPTR    DATE 0
.  LINEID  PL SL  ----+-*A-1-B--+----2----+----3----+----4----+----5----+----6--
.  000027         041400 PROCEDURE DIVISION.                                   
.  000028**       033300                                                       
.  000029         042110     MOVE LOW-VALUES         TO WS-GROUP1.             
.  000030         042120     DISPLAY 'NUMX = ' NUMX.                           
.  000031         042130                                                       
.  000032                    MOVE 0           TO RETURN-CODE.                   
.  000033         042140                                                       
.  000034**       006731     GOBACK.                                           
.  000035         006732   



Result of running the above code

Code:


.NUMX = ...
0DEDE474000
154470E0000



Dave
Back to top
View user's profile Send private message
martin9

Active User


Joined: 01 Mar 2006
Posts: 290
Location: Basel, Switzerland

PostPosted: Tue Apr 04, 2006 7:28 pm
Reply with quote

hy alll,

yeah i was not completely right,
i just forgot, that on an odd-length comp-3 field
the compiler will use one half-byte more to get an even-length
field. try it with pic 9(06) comp-3 or if you just use the initial
value of that field, which is low-values.

but it's very right, with redefining the comp-3
is probably the easiest way.... s.above

martin9
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Apr 05, 2006 5:22 am
Reply with quote

Every comp-3 field in mainframe IBM COBOL has a sign nibble (4 bits), whether it's positive (C), negative (D) or unsigned (F) regardless of its length.
Back to top
View user's profile Send private message
madhugoodboy

New User


Joined: 24 Jan 2006
Posts: 12

PostPosted: Wed Apr 05, 2006 11:02 am
Reply with quote

Thanks all,

Now it has been confirmed that we can move the low values to comp-3 variable.


Regards
Madhu
Back to top
View user's profile Send private message
martin9

Active User


Joined: 01 Mar 2006
Posts: 290
Location: Basel, Switzerland

PostPosted: Wed Apr 05, 2006 2:17 pm
Reply with quote

hy madhugoodboy,

but do not use it.
move some zeros as value, it's the better way
and you will be always on the sure side....

martin9
Back to top
View user's profile Send private message
harish_mf

New User


Joined: 31 Jul 2005
Posts: 18
Location: bangalore

PostPosted: Thu Jul 27, 2006 2:46 pm
Reply with quote

Hi,

How to display comp-3 variables
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 INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Variable Output file name DFSORT/ICETOOL 8
Search our Forums:

Back to Top