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
 

 

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: 7241

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: 7241

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: 1717
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 Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Convert +9999999999999.99 to S9(12)V9(3) vnktrrd DFSORT/ICETOOL 8 Thu Nov 17, 2016 8:15 pm
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm


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