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

How to convert comp-3/comp variable in csv file in cobol


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat Oct 26, 2013 7:18 pm
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
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
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat Oct 26, 2013 9:08 pm
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: 2455
Location: Hampshire, UK

PostPosted: Sun Oct 27, 2013 2:54 pm
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: 57
Location: chennai

PostPosted: Tue Oct 29, 2013 4:12 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
Search our Forums:

Back to Top