Page 1 of 1

Editing data going to an output file

PostPosted: Sun Jun 14, 2009 6:09 pm
by nyydmg15
HI,

I have a question that revolves around editing dollar amounts going to a flat file.

How do you edit the leading zeros from dollar amounts when those amounts are going to a data field and not a report?

Thanks

Re: editing data going to an output file

PostPosted: Sun Jun 14, 2009 10:08 pm
by dick scherrer
Hello and welcome to the forum,

One way is to move the value to an edited "work" variable, redefine that variable as alpha and move the alpha field to the output.

I won't have an internet connection again until Tuesday night - so good luck and i'll check back when i get re-connected :)

Re: editing data going to an output file

PostPosted: Tue Jul 21, 2009 10:09 pm
by MtClimber
Hi;
I have a similar problem. I need to modify an Easytrieve to extract a dollar amount from a database and write a comma delimited output file. I need the dollar amount to be zero filled with a decimal point. Example: $157.00 should be written in the output file as: 00157.00

I am a COBOL programmer struggling with an Easytrieve. This is what I've tried per Dick's suggestion.
(I'm only showing the lines relavant to my question)

Input field:
CT05-CHRG 92 4 P 2

Output field:
EXTRO-CHRG 84 8 A

Work Fields:
W-CHRG W 7 N 2 MASK ('99999.99')
W-CHRG-RD W-CHRG 7 A

Additional Code:
W-CHRG = CT05-CHRG
EXTRO-CHRG = W-CHRG-RD
PUT EXTRO

I'm getting 0015700 (no decimal point)

Please let me know what I'm doing wrong. Thanks.
Dan

Re: editing data going to an output file

PostPosted: Fri Aug 28, 2009 8:31 pm
by nosource
You could do something like...

WSLR-CURR-BAL WSLR-ACCOUNT-LOAD-RECORD +00236 15 A +
HEADING ('CURR-BAL')
WSLR-CURR-BAL-SIGN WSLR-CURR-BAL 1 A
WSLR-CURR-BAL-DOLLARS WSLR-CURR-BAL 12 N
WSLR-CURR-BAL-DEC WSLR-CURR-BAL +12 1 A
WSLR-CURR-BAL-CENTS WSLR-CURR-BAL +13 2 N


WSLR-CURR-BAL-DOLLARS = WS-BALCUR
WSLR-CURR-BAL-DEC = '.'
WSLR-CURR-BAL-CENTS = WS-BALCUR * 100
IF WS-BALCUR LT 0
WSLR-CURR-BAL-SIGN = '-'
END-IF

Re: editing data going to an output file

PostPosted: Sat Aug 29, 2009 11:13 pm
by dick scherrer
Hello,

Please post the results of running this. . .

Re: editing data going to an output file

PostPosted: Sun Jan 30, 2011 3:52 am
by BillyBoyo
nyydmg15 wrote:I have a question that revolves around editing dollar amounts going to a flat file.

How do you edit the leading zeros from dollar amounts when those amounts are going to a data field and not a report?


An ETP "MASK" is only processed for printed output (either DISPLAY, or PRINT).

One way you might want to look at is to DISPLAY to a file. The output will be "edited" as per any MASKs you put on numeric fields, including currency, decimal, sign, comma seperator if you use it. Of course, if you want a CSV file to ship off somewhere, don't put the comma seperators into the numbers (for thousands, millions, etc).

Re: editing data going to an output file

PostPosted: Sun Jan 30, 2011 4:07 am
by BillyBoyo
MtClimber wrote:I need to modify an Easytrieve to extract a dollar amount from a database and write a comma delimited output file. I need the dollar amount to be zero filled with a decimal point. Example: $157.00 should be written in the output file as: 00157.00


MtClimber wrote:W-CHRG W 7 N 2 MASK ('99999.99')
W-CHRG-RD W-CHRG 7 A


You can use DISPLAY instead of PUT to output your record, this will process the MASK. Or,

These are "redefining" on your W-CHRG from above.
W-CHRG-UNITS W-CHRG 5 A
W-CHRG-DECIMALS W-CHRG +5 2 N

W-CHRG-FOR-OUTPUT W 8 A
W-CFO-UNITS W-CHRG-FOR-OUTPUT 5 A
W-CFO-DECIMAL-POINT W-CHRG-FOR-OUTPUT +5 1 A
W-CFO-DECIMALS W-CHRG-FOR-OUTPUT +6 2 N

Then
W-CFO-DECIMAL-POINT = "." (you only need to do this once, but somewhere obvious)
W-CFO-UNITS = W-CHRG-UNITS
W-CFO-DECIMALS = W-CHRG-DECIMALS + 0 (you will need to do this to ensure your last byte is an Fx (unsigned) not Cx (positive)