View previous topic :: View next topic
|
Author |
Message |
Mainforum
New User
Joined: 30 May 2013 Posts: 8 Location: India
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Mainforum
New User
Joined: 30 May 2013 Posts: 8 Location: India
|
|
|
|
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 |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
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 |
|
|
Mainforum
New User
Joined: 30 May 2013 Posts: 8 Location: India
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
You should also specify a "real" decimal point as Excel knows nothing aout an "assumed" decinmal point hece
instead of
|
|
Back to top |
|
|
Purnendu.it
New User
Joined: 11 May 2007 Posts: 57 Location: chennai
|
|
|
|
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 |
|
|
|