Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How to convert comp-3/comp variable in csv file in cobol

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

New User


Joined: 30 May 2013
Posts: 8
Location: India

PostPosted: Sat Oct 26, 2013 7:04 pm    Post subject: How to convert comp-3/comp variable in csv file in cobol
Reply with quote

Hi,
I have written a cobol program where I should read a VSAM file and convert the file into CSV format. So I just read a file and write it into the output file with commas. But my input file has COMP/COMP-3 variables. When I export the file into excel, I am seeing junk values for COMP/COMP-3 variables. Can any one help me in code how to convert the comp variables to numeric and write into a file to avoid junk in excel sheet?
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Sat Oct 26, 2013 7:18 pm    Post subject: Reply to: How to convert comp-3/comp variable in csv file in
Reply with quote

Just MOVE them to PIC 9(n) USAGE DISPLAY fields.


Code:
01  a-nice-name PIC 9(7)V99
01  another-nice-name PIC 9(4).


Then use those fields in your CSV.
Back to top
View user's profile Send private message
Mainforum

New User


Joined: 30 May 2013
Posts: 8
Location: India

PostPosted: Sat Oct 26, 2013 7:31 pm    Post subject: Reply to: How to convert comp-3/comp variable in csv file in
Reply with quote

If my understanding is wrong correct me.

Example:

INPUT FILE:
01 OUT-AMT PIC S9(9)V(2) COMP-3

Program:

W-S VARIABLES.
01 WS-AMT PIC 9(9)V(9) USAGE DISPLAY.

P.D

MOVE OUT-AMT TO WS-AMT.
MOVE WS-AMT TO OUTPUT-FILE.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Sat Oct 26, 2013 7:52 pm    Post subject: Re: Reply to: How to convert comp-3/comp variable in csv fil
Reply with quote

Mainforum wrote:
If my understanding is wrong correct me.

Example:

INPUT FILE:
01 OUT-AMT PIC S9(9)V(2) COMP-3

Program:

W-S VARIABLES.
01 WS-AMT PIC 9(9)V(9) USAGE DISPLAY.

P.D

MOVE OUT-AMT TO WS-AMT.
MOVE WS-AMT TO OUTPUT-FILE.


Both the out-amt and ws-amt pic's are invalid, are there any negative values?
Back to top
View user's profile Send private message
Mainforum

New User


Joined: 30 May 2013
Posts: 8
Location: India

PostPosted: Sat Oct 26, 2013 8:29 pm    Post subject: Reply to: How to convert comp-3/comp variable in csv file in
Reply with quote

No. As of now am not seeing any negative values in my report. But input has amount fields with S9(9) comp-3
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Sat Oct 26, 2013 9:08 pm    Post subject: Reply to: How to convert comp-3/comp variable in csv file in
Reply with quote

If you have signed input fields, look at SIGN IS SEPARATE or setting the sign sepately yourself. Even if you have yet to see any negatives, if your fields are signed, you should cope with them.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1894
Location: UK

PostPosted: Sun Oct 27, 2013 2:54 pm    Post subject:
Reply with quote

You should also specify a "real" decimal point as Excel knows nothing aout an "assumed" decinmal point hece
Code:

999.99

instead of
Code:

999V99
Back to top
View user's profile Send private message
Purnendu.it

New User


Joined: 11 May 2007
Posts: 59
Location: chennai

PostPosted: Tue Oct 29, 2013 4:12 pm    Post subject:
Reply with quote

Excel won`t be able to understand the comp fields so while you are importing your data into excel it is showing junk value.It only understand numeric or character fields.So best way to import correct value of the comp field into excel is to first store your comp field either in a pure PIC 9 or PIC X field and then create the output file and subsequently you can import it in excel.That is what i do while i transfer any MF file which contains comp data into excel.
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 IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts Execute JCL step based on the content... sprikitik JCL & VSAM 2 Tue Oct 03, 2017 10:03 am
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am
No new posts Garbage on output file Hervey Martinez SYNCSORT 4 Wed Sep 27, 2017 12:50 am
No new posts File Aid tool to compare numeric data balaji81_k Compuware & Other Tools 2 Tue Sep 26, 2017 3:35 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us