View previous topic :: View next topic
|
Author |
Message |
hnharish
New User
Joined: 30 Aug 2005 Posts: 23
|
|
|
|
I have packed decimal data in the input file and i have to unpack the data and write into output file.Ex: If i have a 100.00 dollars amount stored in the packed decimal field after the data is moved into the output field it has to display 100.00 in the readable format.So how to declare the output field.
Ex:
Input File:
FILE FILEIN1 FB(730 27740)
FILEIN1-TOTPYMT 64 8 P
Output File:
FILE FILEIN2 FB(73 0)
FILEIN2-TOTPYMT ? |
|
Back to top |
|
|
anandinmainframe
Active User
Joined: 31 May 2007 Posts: 171 Location: India
|
|
|
|
Hi,
you can declare the working storage as FILEIN2-TOTPYMT 10 N |
|
Back to top |
|
|
hnharish
New User
Joined: 30 Aug 2005 Posts: 23
|
|
|
|
anandinmainframe wrote: |
Hi,
you can declare the working storage as FILEIN2-TOTPYMT 10 N |
As mentioned earlier FILEIN1-TOTPYMT 64 8 P corresponds to S9(13)V99 COMP-3 in cobol.So i have to declare FILEIN2-TOTPYMT as FILEIN2-TOTPYMT 48 15 N. But this is not working becuase in the input file if COMP-3 data contains 82.55 in the output i m getting 000000000008255 the decimal dot is missing. |
|
Back to top |
|
|
hnharish
New User
Joined: 30 Aug 2005 Posts: 23
|
|
|
|
hnharish wrote: |
anandinmainframe wrote: |
Hi,
you can declare the working storage as FILEIN2-TOTPYMT 10 N |
As mentioned earlier FILEIN1-TOTPYMT 64 8 P corresponds to S9(13)V99 COMP-3 in cobol.So i have to declare FILEIN2-TOTPYMT as FILEIN2-TOTPYMT 48 15 N. But this is not working becuase in the input file if COMP-3 data contains 82.55 in the output i m getting 000000000008255 the decimal dot is missing. |
Also if i declare
FILEIN2-TOTPYMT 48 15 N MASK(A '9999999999999.99')
and display the data in the FILEIN2-TOTPYMT i m getting proper result i'e., 0000000000082.55.But in the output file i m getting 000000000008255 the decimal dot is missing. |
|
Back to top |
|
|
anandinmainframe
Active User
Joined: 31 May 2007 Posts: 171 Location: India
|
|
|
|
Hi,
Declare this as FILEIN2-TOTPYMT 48 15 N 2 |
|
Back to top |
|
|
hnharish
New User
Joined: 30 Aug 2005 Posts: 23
|
|
|
|
anandinmainframe wrote: |
Hi,
Declare this as FILEIN2-TOTPYMT 48 15 N 2 |
This is also giving the result 000000000825500 here also the dot is missing.I think we have to look for any alphanumeric data type like x in cobol. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
To do what you want, use change your MASK.
Try 'ZZZZZZZZZZZ9.99' and adjust if you want punctuation with commas or if you want a minus sign. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Hi Harish,
I believe easytrieve as such cannot generate signs/decimal points by itself while writing to a file and we need to provide them explicitly. I ran a small test and that worked fine for me. May be you can give it a try.
Code: |
FILE INFILEI1
IN-REC 1 80 A
IN-COST 1 8 P
FILLER-1 9 72 A
FILE OUTFILE1
OUT-REC 1 80 A
OUT-COST 1 16 A
WS-COST W 15 N
COSTA WS-COST 13 N
COSTB WS-COST +13 2 N
WS-COST-D W 16 A
COSTX WS-COST-D 13 A
COSTD WS-COST-D +13 1 A VALUE '.'
COSTY WS-COST-D +14 2 A
*
JOB INPUT(INFILEI1)
WS-COST = IN-COST
COSTX = COSTA
COSTY = COSTB
OUT-COST = WS-COST-D
PUT OUTFILE1 |
INFILEI1
Code: |
IN-COST FILLER
8/P 72/AN
(1-8) (9-63)
1--------------- 2-----
***********************
1234567890123.45 |
OUTFILE1
|
|
Back to top |
|
|
anandinmainframe
Active User
Joined: 31 May 2007 Posts: 171 Location: India
|
|
|
|
Hi,
If FILEIN1-TOTPYMT 64 8 P 2 then if you give declare
FILEIN2-TOTPYMT 48 15 N 2 then it will do what you want. |
|
Back to top |
|
|
|