Editing data going to an output file



Unicenter CA-Easytrieve Plus Report Generator: CA's information retrieval and data management tool

Editing data going to an output file

Postby nyydmg15 » Sun Jun 14, 2009 6:09 pm

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
nyydmg15
 
Posts: 1
Joined: Sun Jun 14, 2009 6:02 pm
Has thanked: 0 time
Been thanked: 0 time

Re: editing data going to an output file

Postby dick scherrer » Sun Jun 14, 2009 10:08 pm

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 :)
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6269
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: editing data going to an output file

Postby MtClimber » Tue Jul 21, 2009 10:09 pm

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
MtClimber
 
Posts: 4
Joined: Tue Jul 21, 2009 9:51 pm
Has thanked: 0 time
Been thanked: 0 time

Re: editing data going to an output file

Postby nosource » Fri Aug 28, 2009 8:31 pm

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
nosource
 
Posts: 4
Joined: Fri Aug 28, 2009 8:13 pm
Has thanked: 0 time
Been thanked: 0 time

Re: editing data going to an output file

Postby dick scherrer » Sat Aug 29, 2009 11:13 pm

Hello,

Please post the results of running this. . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6269
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: editing data going to an output file

Postby BillyBoyo » Sun Jan 30, 2011 3:52 am

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).
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: editing data going to an output file

Postby BillyBoyo » Sun Jan 30, 2011 4:07 am

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)


BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times


Return to CA-Easytrieve

 


  • Related topics
    Replies
    Views
    Last post