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
 

 

Moving a COMP-2 variable

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Moving a COMP-2 variable
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: 7997
Location: Bellevue, IA

PostPosted: Tue Sep 29, 2009 5:08 pm    Post subject:
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    Post subject: Reply to: Moving a COMP-2 variable
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: 7997
Location: Bellevue, IA

PostPosted: Wed Sep 30, 2009 9:10 pm    Post subject:
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    Post subject:
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    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 Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts Moving a PD to PD spoorni DFSORT/ICETOOL 8 Fri Oct 07, 2016 9:52 pm
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm


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