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

Moving a COMP-2 variable


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

New User


Joined: 11 Nov 2008
Posts: 52
Location: Hyderabad

PostPosted: Tue Sep 29, 2009 4:54 pm
Reply with quote

Hi,
Oflate i got a small problem while handling a COMP-2 variable. I have an input file which has amount variable declared as COMP-2 and this has to be moved in one of the programs to an output copyboko variable which is X(30). But, this is not allowed....does any one know how can i move the COMP-2 , a double precision value, to X(30) without losing data or getting junk values. Thanks for ur help in advance!

Thanks and Regards,
Mambo!
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Sep 29, 2009 5:08 pm
Reply with quote

Code:
           05  VAR-1                   COMP-2.
           05  VAR-2                   PIC 9(30).
           05  VAR-2-R                 REDEFINES VAR-2
                                       PIC X(30).
      /
       PROCEDURE DIVISION.
       S1000-MAIN       SECTION.
           MOVE 123456789              TO  VAR-1.
           MOVE VAR-1                  TO  VAR-2.
           DISPLAY 'VAR-1 ' VAR-1.
           DISPLAY 'VAR 2 ' VAR-2-R.
prodcues results of
Code:
 VAR-1  .12345678900000000E 09
 VAR 2 000000000000000000000123456789
For error processing, handling data values that are too large for the output field is recommended.
Back to top
View user's profile Send private message
mambopras

New User


Joined: 11 Nov 2008
Posts: 52
Location: Hyderabad

PostPosted: Wed Sep 30, 2009 9:03 pm
Reply with quote

Thanks a lot Robert....the solution worked though i can't use 9(30). The maximum i could declare was 9(18). So i did that and the results were satisfactory for me. But the main idea was yours...thanks a lot!
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Sep 30, 2009 9:10 pm
Reply with quote

Quote:
the solution worked though i can't use 9(30). The maximum i could declare was 9(18).
Compiler option ARITH(EXTEND) extends the maximum digits from 18 to 31; this is not the default. This works on the Enterprise COBOL compilers; I'm not sure how far back it goes.

But I'm glad you got it working.
Back to top
View user's profile Send private message
mambopras

New User


Joined: 11 Nov 2008
Posts: 52
Location: Hyderabad

PostPosted: Wed Sep 30, 2009 9:27 pm
Reply with quote

icon_biggrin.gif thanks for that
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
Search our Forums:

Back to Top